n8n Integration for Rain Automation: Build, Host, and Monitor Production Workflows
n8n is the workflow engine Rain Automation builds on. We run it self-hosted in queue mode with a Postgres backend, dedicated job runners, Prometheus metrics, and nightly backups that get restored and verified. This is a build and operate integration, not a one click marketplace connector: there is no OAuth consent screen for the n8n API. You either give us a scoped API key for an instance you already own, or we stand the instance up and run it, and then we build the workflows on it.
How to connect n8n
Step 1. Decide where n8n runs
There are three supportable answers and they change nothing about the workflows themselves, only who carries the operational load.
- n8n Cloud. Fastest to start. n8n owns uptime, upgrades, and storage.
- Your own server. You own the box, the Postgres backend, the TLS certificate, and the backups.
- Rain's managed stack. We run n8n in queue mode with a Postgres backend, separate job runners, Redis for the queue, Prometheus and Grafana for metrics, and nightly backups that are restored and integrity checked rather than assumed.
Step 2. Create an n8n API key
In n8n, open Settings, then n8n API, then Create an API key. Copy the key once. n8n will not show it again.
The REST API lives under /api/v1 and authenticates on the X-N8N-API-KEY header. There is no OAuth flow and no consent screen for the n8n API itself. A request that omits the header returns 401 Unauthorized, which is the quickest way to confirm your base URL is reaching n8n at all.
curl -s https://your-n8n-host/api/v1/workflows \
-H "X-N8N-API-KEY: $N8N_API_KEY"
An API key inherits the permissions of the account that created it. Create it from a service account rather than the owner login where your edition supports separate users.
Step 3. Hand Rain the base URL and the key
Credentials go into the environment file on the machine that runs the workflows. They never go into a workflow node, a repository, a ticket, or a chat message. If a key is ever pasted somewhere it should not be, rotate it in n8n and every consumer of it in the same sitting rather than noting it for later.
Step 4. Add a Webhook trigger for anything inbound
Drop a Webhook node at the front of the workflow and copy the production URL, not the test URL. The test URL only listens while the editor is open, which is the single most common reason a demo works and production goes silent.
Set authentication on the node (header auth or basic auth), then decide the response mode deliberately. The default returns an immediate acknowledgement, which is right for a Stripe or CRM webhook that only needs a fast 200. A browser form that shows a confirmation screen usually needs the response held until the last node finishes, or a dedicated Respond to Webhook node.
Step 5. Let Rain import and version the workflows
Workflows are created and updated over the REST API (POST /api/v1/workflows, then PUT to update an existing one). We never write to n8n's own database directly. Direct database edits bypass the running instance's in-memory state, so active triggers keep firing the old definition and the editor shows something that is not what is executing.
Every workflow we ship is exported to JSON and committed, so a bad change is a revert rather than an archaeology project.
Step 6. Turn on failure alerting before you turn on the workflow
Build the Error Trigger workflow first and point it at a channel a human actually reads. Then add the check most teams skip: a heartbeat that alerts when a scheduled workflow fails to run at all. A workflow that errors is loud. A workflow whose trigger quietly stopped firing after an upgrade is silent, and silence is the expensive failure mode.
Workflow walkthroughs
These three Rain tutorials cover the nodes doing the heavy lifting in the example workflows below.
- n8n webhook response mode guide sets up the form to CRM workflow in example one.
- n8n Send Email node tutorial covers the notification path in example two, including the SMTP settings that keep those messages out of spam.
- n8n Gmail node OAuth setup tutorial covers the credential flow behind the inbound reply triage in example three.
Example workflows
Website form to CRM with a real confirmation screen
A Webhook trigger receives the form post, a Set node normalizes the fields, an IF node drops obvious spam, the record is written to your CRM, and the response is held until the write succeeds so the visitor sees a confirmation that reflects what actually happened. If the CRM write fails, the visitor gets an error instead of a false thank you page and the failure branch pages a human.
Use case: Lead capture that does not silently lose submissions
New lead to a staged follow up sequence
A new CRM record starts a workflow that sends the first message immediately, then uses Wait nodes for the follow ups. Each step checks whether the lead has replied or booked before it sends, so the sequence stops itself. Sends run through SMTP or a transactional provider with the sending domain authenticated, not from a personal mailbox.
Use case: Speed to lead and follow up without a marketing suite
Inbound reply triage to pipeline stage
A Gmail trigger watches a shared inbox, an AI node classifies each message as a question, a booking request, an objection, or an unsubscribe, and the matching CRM contact moves to the right stage with the message body logged against it. Unsubscribes are written to the suppression list in the same run so nothing else in the system emails that address again.
Use case: Keeping the pipeline accurate without manual inbox triage
Scheduled two way sync between CRM and scheduling or invoicing
A Schedule trigger pulls records changed since the last successful run, matches them on a stable external ID rather than on name or email, and writes only the fields that differ. The cursor is stored so a failed run resumes instead of replaying from the beginning, and every record carries an idempotency key so a retry cannot create a duplicate.
Use case: Two systems of record that both have to be right
Dead man's switch for the workflows themselves
Every scheduled workflow writes a heartbeat row at the end of a successful run. A separate watchdog workflow reads those rows on its own schedule and alerts when a heartbeat is older than the interval that workflow is supposed to run on. This catches the failure that error alerting cannot see: a trigger that stopped firing after an upgrade, a credential expiry, or a paused workflow nobody resumed. Most automation outages are silence, not errors.
Use case: Catching the outage that never throws an error
AI drafted response with a human approval gate
An inbound message is drafted by an AI node against your service catalog and pricing rules, then parked. The workflow sends the draft to an approver with an approve link, and nothing reaches the customer until that link is clicked. The gate fails closed: if the draft is empty, malformed, or missing a required field, the run stops and a human is notified rather than sending a partial message.
Use case: AI speed with a human signature on anything customer facing
Pricing
The n8n licensing question and the Rain engagement question are separate, and it helps to price them separately.
n8n itself. The self-hosted Community Edition is open source and does not meter tasks, so your cost is the server it runs on plus the time to operate it. n8n's cloud and enterprise plans meter workflow executions rather than individual steps, which is the structural difference from per-task tools: a fifty step workflow counts once, not fifty times. That is why complexity is cheap here and expensive elsewhere. Current plan tiers are on n8n's own pricing page, which is the only source worth quoting since it changes.
Self-hosting costs that are easy to miss. Queue mode means a main instance plus worker processes, so size memory for concurrent executions rather than for the editor. Binary data (attachments, generated files, downloaded media) is written to the filesystem, not the database, so a database-only backup does not contain it and a polling trigger that downloads files will fill a disk over months if nothing prunes it. Execution history also grows without a retention policy.
Rain's part. Workflow builds are scoped as a project, and ongoing operation (monitoring, upgrades, backup verification, and fixing what breaks when a vendor changes an API) is a separate arrangement. See pricing for how engagements are structured, or contact us with the workflow you are trying to run and we will tell you whether it is a one week build or a one month one.