How to Build an AI Agent in n8n: Step-by-Step Guide
A working walkthrough of n8n's AI Agent node: wiring up a chat model, memory, and tools so the agent decides what to do instead of following a fixed sequence.
Quick answer
An n8n AI agent is built around the AI Agent node — it connects a language model (OpenAI Chat Model, for instance) to one or more "tools," and the model decides on its own which tool to call to get the job done, instead of following a rigid sequence of steps you defined in advance. Unlike a normal workflow where every step is fixed, an agent makes that decision dynamically based on whatever the user actually asked.
Below is a working example: an agent that answers in a chat panel, can do exact math, and can look up current information online.
What an AI agent actually is, before you build one
The AI Agent node in n8n is a cluster node — a root node with child sub-nodes of three kinds attached to it:
- Chat Model — the language model itself (OpenAI, Anthropic, or another provider) — required
- Tools — the capabilities the agent can call on (a calculator, web search, an HTTP request to your own API, a database lookup) — you need at least one
- Memory — conversation memory so the agent recalls earlier messages within a session — optional, but without it every message gets treated as the first contact
One detail worth knowing as of 2026: before n8n version 1.82.0, there were several agent types to choose from (Conversational Agent, Tools Agent, and others). Every AI Agent node now defaults to working as a Tools Agent — the previously-recommended option became the only standard.
Step 1 — Add a trigger
- New workflow → + Add first step
- Choose Chat Trigger — it opens a built-in chat panel right inside n8n, which is the fastest way to test an agent without building a separate front end
Step 2 — Add the AI Agent node
- Connect the Chat Trigger to an AI Agent node
- On the canvas, the AI Agent node shows up with empty slots underneath for Chat Model, Memory, and Tool
Step 3 — Connect a chat model
- Click the model slot → add a sub-node, e.g. OpenAI Chat Model
- Create or select a saved credential (your provider API key)
- Pick the specific model from the sub-node's settings dropdown
Step 4 — Add memory (optional, but recommended)
- Click the Memory slot → add Simple Memory
- Skip this and the agent forgets context after every single message — fine for one-off lookups, awkward for an actual back-and-forth conversation
Step 5 — Wire up tools
For this basic build, two tools:
- Calculator — a built-in tool for exact math (language models are notoriously unreliable at arithmetic on their own)
- A web search tool (via SerpApi or another connected search service) — lets the agent answer questions about current events that fall outside the model's training data
Each tool attaches as its own sub-node to the same Tools slot on the AI Agent node — you can add several at once.
Step 6 — Test it in the chat panel
- Click Chat at the bottom of the canvas (available because of the Chat Trigger)
- Ask something that needs computation ("what's 347 × 289?") — the agent recognizes it needs the Calculator instead of guessing at an answer
- Ask about something current — the agent recognizes it needs the search tool instead of answering from memory
The entire setup — Chat Trigger, AI Agent, OpenAI Chat Model, Simple Memory — is configured entirely through point-and-click, no code required.
Using it beyond the chat panel
Chat Trigger is great for testing, but real deployments usually start the agent a different way:
- Webhook — an outside service (a website contact form, say) sends a request, and the agent decides what to do with it — see what a webhook actually is for the mechanism underneath
- Slack Trigger — a message in a Slack channel or DM fires the agent directly; this is the most common way teams deploy an internal support or ops agent, since it lands where people are already working instead of a separate chat UI
- Schedule Trigger — the agent periodically checks a data source and decides on its own whether action is needed
A more realistic build: a Slack support agent with real memory
The Chat Trigger example above is disposable — its memory resets if the workflow restarts. A support agent that needs to hold a real conversation with a real customer needs a persistent memory backend instead of Simple Memory: swap the Memory sub-node for Postgres Chat Memory, keyed on a session ID (a Slack thread ID or a website visitor ID work well), so context survives across messages and n8n restarts alike.
The other piece production support agents almost always add is an escalation path: a conditional branch after the AI Agent node that checks the model's confidence or looks for specific phrases in its answer, and routes anything uncertain to a Slack channel or email alert for a human instead of letting the agent guess. Treat this the same way as the "don't give it autonomy over real consequences" point below — an agent answering FAQs on its own is low-risk; an agent that's the last line before a customer gets a wrong answer needs a human backstop.
Common mistakes
Forgetting to attach at least one tool. The AI Agent node technically requires at least one tool connected to the Tools slot — without it, the node won't run correctly even if the Chat Model and Memory are configured perfectly.
Expecting the agent to remember things across separate chat sessions. Memory only holds context within a single session/conversation, not permanently across every interaction — long-term storage needs a separate database or spreadsheet integration wired in as its own tool.
Giving the agent too many tools at once. The more tools you attach, the harder it is for the model to pick the right one — in practice, 2-4 clearly distinct tools work more reliably than a dozen loosely-defined ones.
Not limiting what the agent can do autonomously. If any of the tools have real consequences — sending emails, charging money, modifying customer data — add a human-confirmation step before those actions fire, rather than giving the agent full autonomy straight into a production scenario.
When an AI agent is the right call — and when it's overkill
An agent earns its complexity when the sequence of actions isn't known ahead of time — the model genuinely has to decide which tool to call, and in what order, based on the specific request. If the sequence is always the same ("get form data → write to sheet → send confirmation"), a plain linear workflow without an AI Agent is simpler, cheaper (no LLM tokens burned on every run), and more predictable. Reserve AI for the point in the automation where the decision genuinely depends on context — not every step "just in case."
FAQ
Do I need a paid OpenAI API key to get started?
Yes — the Chat Model slot needs a credential for whichever language model provider you connect (OpenAI, Anthropic, or another one supported in n8n). The model itself is called through a paid API, billed separately from n8n based on tokens used per request.
How is the Tools Agent different from n8n's older agent types?
As of version 1.82.0, every AI Agent node in n8n runs as a Tools Agent. Older types (like Conversational Agent) remain functional in existing workflows for backward compatibility, but there's no longer a separate agent-type choice when building something new.
How many tools can I attach to one agent?
There's no hard technical limit, but 2-4 clearly distinct tools is the practical recommendation — too many tools makes it harder for the model to pick correctly and raises the odds of it calling the wrong one.
Can I use a different language model instead of OpenAI?
Yes — the Chat Model slot supports multiple providers (Anthropic and others, depending on what's installed), and picking a model happens at the sub-node level. The AI Agent node itself and the tools/memory logic stay the same regardless of which provider you choose.
What's the right memory backend for a customer-facing support agent, not just a demo?
Simple Memory is in-process and doesn't survive an n8n restart, which is fine for testing but not for production. For a real support agent, use Postgres Chat Memory with a session ID tied to something stable on your side (a Slack thread, a logged-in user ID) — that keeps each conversation's context isolated and durable across restarts.
Should the agent be allowed to answer customers without a human checking it?
For low-stakes FAQ-style answers, yes, that's the point. For anything where a wrong answer has a real cost — refunds, account changes, medical or legal-adjacent questions — add a confidence-check branch after the AI Agent node that routes uncertain answers to a Slack channel or email for human review instead of sending them straight to the customer.
Last fact-checked: August 18, 2026. n8n's AI Agent functionality is under active development — check the official AI Agent documentation before building a production scenario.