If you're new to the tool itself, start with What is n8n?. This article is about using it specifically for AI automation, and about the parts beginners skip.
What n8n gives you for AI
According to n8n's Integrate AI documentation, you can connect LLM providers such as OpenAI, Anthropic and Google, add tools and memory, use MCP servers and combine several models in one workflow. In practice that breaks into a few building blocks:
| Building block | What it does | When you use it |
|---|---|---|
| Chat model | The LLM that reads and writes | Every AI step |
| Chain | A fixed AI step: prompt in, output out | Classify, extract, summarize, draft |
| Agent | A model that decides which tools to call | Open-ended tasks with several possible steps |
| Tools | Actions an agent may take (search, CRM lookup, HTTP request, another workflow) | Giving an agent abilities |
| Memory | Keeps conversation history across turns | Chat-style agents |
| Vector store | Stores content by meaning for retrieval (RAG) | Answering from your own documents |
n8n's docs describe an agent as a chain that can make decisions. That one line is the key design choice in every AI workflow you build: do you need a fixed step or a decision-maker? We cover that choice in AI agents vs automation. The short version: use a chain unless you have a clear reason for an agent.
The anatomy of an n8n AI workflow
MitHub breaks every AI automation into six layers: Trigger → Data → Decide → Act → Record → Alert (explained in What is AI automation?). Here's how each maps to n8n.
1. Trigger
Common triggers are a schedule, an app event (a new row, a new CRM record) or a webhook.
The Webhook node gives you a URL that starts the workflow when another system sends data to it. It has two URLs:
- Test URL: active while you listen for a test event; incoming data appears in the editor so you can build against it.
- Production URL: registered when you publish the workflow; runs show up in the Executions tab, not in the editor.
Habit to build: develop against the test URL, switch the source system to the production URL only after testing, and write down which URL each external system points to. Many "it stopped working" problems are a source still pointing at the test URL.
2. Data
n8n passes data between nodes as a list of items, each carrying its fields under a json key, as described in Understand n8n's data structure. Nodes generally run their operation once per item.
This matters for AI because every item can be a model call. Send 500 rows into an AI node and you've made 500 calls. Filter, deduplicate and clean before the AI step. Use rules nodes (filters, IF, Switch) to remove anything that doesn't need a model.
3. Decide
This is where rules and AI split the work.
- Rules first: IF and Switch nodes for anything you can write as a condition.
- AI step: a chain with a tight prompt and structured output: a fixed label, a score, specific fields. Not a paragraph.
- Agent: only when the step truly needs the model to choose tools.
Then validate. If the model returns a label that isn't in your allowed list, route it to a human instead of letting it continue.
4. Act
Update the CRM, send the Slack message, create the task. For risky actions, add a human.
n8n supports human-in-the-loop for tools: when an agent wants to run a tool that requires review, the workflow pauses and sends an approval request through a channel such as n8n Chat, Slack, Teams, Telegram or email. If approved, the tool runs with the parameters the AI chose. If denied, it's cancelled and the AI is told. You can require review on specific high-risk tools only, leaving safe read-only tools free.
5. Record
Write the input, the AI's decision and the outcome somewhere a person can check: a CRM note, a log table, a sheet. A workflow that acts without leaving a trace can't be trusted or improved.
6. Alert
n8n lets you handle errors with a separate error workflow that starts with an Error Trigger node. You pick it in the main workflow's settings, and when an execution fails it receives details such as the failed node, the error message and a link to the execution. One error workflow can serve many workflows. You can also force it on purpose with a Stop And Error node, for example when the AI returns something outside your allowed values.
A worked example: inbound lead triage (hypothetical)
Imagine a company whose website form sends leads with a free-text message. Today someone reads every message and routes it by hand. Here's an n8n design.
- Webhook receives the form submission.
- Set / Edit Fields normalizes it: trims whitespace, lowercases the email, formats the phone.
- CRM lookup checks if the contact already exists. IF it exists, update and stop; otherwise continue.
- Filter drops obvious junk with rules (empty message, test email domains). No model needed.
- AI chain reads the message and returns structured output:
{
"intent": "sales",
"urgency": "high",
"locations_mentioned": 3,
"summary": "Asks for pricing for 3 locations and wants a call this week."
}
- IF
intentis not one ofsales,support,spam→ route to a human review queue. - Switch on
intent:sales→ create lead and assign by territory;support→ create a ticket;spam→ log only. - For high-urgency sales leads: send the rep a Slack message with the summary and a drafted first reply that the rep approves before anything reaches the prospect.
- Record: write the original message, the AI output and the route taken to a log.
- Error workflow alerts a channel if any node fails.
Of ten steps, one uses a model. That's normal. The AI step removes the manual reading; everything else makes it safe.
Testing AI steps: evaluations
A workflow with rules can be checked by reading it. An AI step can't. n8n's evaluation docs explain that because models behave like black boxes, you build confidence by running a dataset of test cases (sample inputs, often with expected outputs) through the workflow. The docs name three benefits: testing across a range of inputs including edge cases, iterating without accidentally breaking something that worked, and comparing models or prompts.
A practical way to start:
- Collect 30–50 real past inputs (anonymized) including the weird ones.
- Label the correct answer for each by hand.
- Run them through the AI step and count how many match.
- Change one thing (prompt, model, examples) and run again.
- Keep the version that scores best, and keep the test set for next time.
That score is also your proof. "It works" becomes something like "it matched the human label on 44 of 50 real cases" (an illustrative figure), which is a claim a manager or client can verify.
Memory and RAG in n8n, briefly
- Memory keeps the history of a conversation so a chat agent doesn't forget earlier messages. Start with simple built-in memory; move to an external database when conversations need to persist or scale. Memory is for agents in conversation, not for one-off classification steps.
- RAG lets an agent answer from your documents. You load content, split it into chunks, turn it into embeddings and insert it into a vector store; at query time, the agent (or a direct vector store query) retrieves the most relevant chunks. Quality depends heavily on how you chunk and what you load. Bad documents in, confident wrong answers out.
n8n AI workflow checklist
Before you publish, check every box:
- The trigger was tested on the test URL; the source now points at the production URL.
- Data is filtered and deduplicated before any AI node.
- Each AI step has a single job and returns structured output.
- Unexpected AI output routes to a human or an error, never silently onward.
- Agents have the fewest tools possible; write actions require approval.
- Credentials live in n8n's credential store, never pasted into prompts or nodes.
- Every run writes a record a non-builder can read.
- An error workflow is attached and alerts a real person.
- An evaluation set exists for each AI step, with a current score.
- Someone else could understand the workflow from its node names and notes.
Where n8n fits in a revenue stack
n8n is the orchestration layer: it connects systems and moves data between them. It usually works alongside a CRM (the system of record), an enrichment tool like Clay and communication tools. If you're deciding which tool should own which job, see Clay vs n8n.
To choose your first workflow, don't start from n8n's node list. Start from the money: MitHub's Follow the money chapter maps the process backwards from the payment, and Prove value fast helps you pick the automated workflow that shows results soonest. If you want the concepts behind agents first, read What is an AI agent?
