Blank canvas. API key ready. Still no agent.
To build an AI agent in n8n, connect Chat Trigger → AI Agent → chat model, add one tool, then attach Simple Memory to the chat session ID.
Steps match current n8n docs (checked mid-October 2026, research-only). Memory and tool blur are where first builds die.
Disclosure: some links are affiliate links. If you buy through them, we may earn a commission at no extra cost to you. Opinions stay ours.
What you will build
A chat-backed agent that can answer, call a tool when it must, and remember the last stretch of the conversation. Same pattern we map in AI agents vs traditional automation: the model chooses actions; a fixed Zap does not.

Who this is for (and who should wait)
Best for: builders who already know a bit of n8n (or Make/Zapier) and want their first tool-using agent without writing LangChain glue.
Not ideal for: people who only need a one-shot rewrite or summary. Use a Basic LLM Chain for that. Also wait if you have no API key yet for OpenAI, Anthropic, or OpenRouter.
- n8n Cloud account or a self-hosted instance you can edit
- An LLM API key (OpenAI, Anthropic, or OpenRouter)
- One simple tool target: Wikipedia is enough for the first pass
- About 30–45 minutes with the chat panel open
Agent vs workflow: the one idea to lock in
A normal n8n workflow is a path you drew. An agent is a loop that reads the user message, picks a tool from the ones you attached, runs it, and decides whether to stop or call another tool.
That is why our n8n review keeps calling out AI nodes as the reason to pick n8n over lighter automators when the job is open-ended. If your job is “when form submits, create row”, you want a workflow. If the job is “figure out which API to hit from this chat”, you want an agent.
In plain English: the Agent node is the project manager; the chat model is the brain; tools are the hands; memory is the notepad.
Prerequisites and credentials
Create the LLM credential under n8n Credentials before you touch the canvas. The chat-model sub-node will refuse to save without it. Keep keys out of the system message and out of tool URLs.
If you self-host, confirm your instance is recent enough that the Agent no longer shows the old agent-type dropdown. From 1.82.0 that setting is deprecated; everything behaves as a Tools Agent. Plan to move off v1 Agent nodes before n8n 3.0 removes them.
ℹ️ Info: Auth patterns for API keys and OAuth sit in our API authentication guide. Same habits apply when an HTTP Request Tool needs a header.
Build the agent in eight steps
Chat Trigger → AI Agent → model, tools, memory
-
Step 1 of 8
Create a blank workflow and add Chat Trigger
In n8n, create a new workflow. Search for Chat Trigger and drop it on the canvas. This gives you a built-in chat panel for testing. For Slack or a custom UI later, you can swap the trigger and keep the Agent cluster.
-
Step 2 of 8
Add the AI Agent node
Add an AI Agent root node and connect it to the Chat Trigger. From n8n 1.82 onward every Agent is a Tools Agent: you no longer pick agent type. Set the prompt source to the connected Chat Trigger so the user message flows through.
-
Step 3 of 8
Attach a chat model sub-node
On the Agent, open the Model slot and add OpenAI Chat Model, Anthropic Chat Model, or OpenRouter Chat Model. Paste your API credential. Pick a current chat model, not a completion-only model. This is the brain; without it the Agent cannot plan.
-
Step 4 of 8
Connect at least one tool
n8n requires one or more tool sub-nodes. Start simple: Wikipedia Tool for facts, Calculator for maths, or HTTP Request Tool for a public API you control. Write a clear tool name and description. Vague descriptions make the model call the wrong tool or none at all.
-
Step 5 of 8
Add Simple Memory and bind the session
Attach Simple Memory (Window Buffer) to the Agent memory slot. Set Session Key to the Chat Trigger
sessionId(or a stable Slackthread_ts). Raise Context Window Length from the default 5 toward about 50 so a real chat does not amnesia mid-thread. -
Step 6 of 8
Write a tight system message
In Agent options, open System Message. State the role, what tools exist, when to call them, and the output style. Example: you are a research helper; call Wikipedia for facts; never invent URLs; answer in short paragraphs. Bad prompts produce tool thrash.
-
Step 7 of 8
Test in the chat panel, then fix tool descriptions
Open the Chat Trigger test chat. Ask something that needs a tool and something that does not. Check the execution log: which tool fired, what arguments went in, what came back. If the Agent skips a tool, rewrite that tool description before adding more tools.
-
Step 8 of 8
Activate and gate risky tools
When the happy path works, activate the workflow. For tools that send email, write to a CRM, or delete data, turn on human approval where n8n offers it, or route those actions through a Call n8n Workflow Tool you review first.
A system message you can paste
Short beats clever. The model already knows how to write. Your job is to constrain tools and honesty.
You are a concise research assistant inside n8n.
Tools:
- wikipedia: look up factual background
- http_request: call only the allow-listed API base URL
Rules:
1. Prefer tools over guessing numbers or dates.
2. If a tool fails, say so and stop inventing.
3. Reply in short paragraphs. No filler.
How the pieces connect

Reading order on the canvas: Trigger feeds the Agent. Under the Agent you should see three kinds of sub-node wires: Model (required), Memory (optional but recommended), Tools (required, one or more). Output parsers are optional; skip them until the free-text agent works.
Dynamic tool inputs can use n8n’s $fromAI() helpers so the model fills arguments. Start with static tool schemas first. Add $fromAI() once you trust the tool choice.
Memory that survives more than one hello
Without memory, every chat turn is a stranger. Simple Memory stores the last N exchanges under a session key inside n8n’s store.
- Session Key: Chat Trigger
sessionId, or Slackthread_ts, or your own conversation UUID - Context Window Length: default 5 is tiny for real chat; start near 50
- Queue mode: do not use Simple Memory across workers; use Postgres or Redis Chat Memory
- Restarts: Window Buffer can go empty after an instance reload; plan durable memory for anything customer-facing
⚠️ Watch out: Tools do not inherit conversation memory. If a sub-workflow needs a fact from earlier in the chat, pass it explicitly through tool parameters.
Common mistakes and quick fixes
Fix the mistakes that kill first agents
Session keys, memory mode, and tool blur
-
Step 1 of 4
No tool attached
The Agent node expects at least one tool. If the canvas looks complete but the run fails immediately, check the Tools slot. A chain node is the right pick when you truly need zero tools.
-
Step 2 of 4
Session key changes every message
Memory buckets by session key. If you hard-code a random UUID per run, history never matches. Bind Chat Trigger
sessionIdor another stable ID and keep it identical across turns. -
Step 3 of 4
Simple Memory on queue mode
Docs warn that Simple Memory does not work reliably when n8n runs in queue mode across workers. Move to Postgres or Redis Chat Memory before you scale that instance.
-
Step 4 of 4
Tool descriptions that say nothing
A tool named helper with description does stuff will not get called correctly. Name the capability, the inputs, and when not to use it. The model chooses tools from those strings.
When to reach for Make, Zapier, or MCP instead
Stay in n8n when the agent must choose tools and keep chat state. Compare platforms on features in Make vs n8n and Zapier vs n8n if your workload is mostly fixed automations.
For a broader map of the category, skim what AI automation is. MCP servers are a later upgrade: connect registry tools to the Agent in one click once the first HTTP or Wikipedia tool already works. Our Model Context Protocol explainer covers the concept without the setup noise.
What good looks like in the execution log
A healthy first run shows: chat input received, model call, optional tool call with sane arguments, tool response, final message. If you see three tool calls for a yes/no question, tighten the system message. If you see zero tool calls when a fact was required, fix the tool description or say “you must use wikipedia for facts” in the system message.
Our take: ship the boring Wikipedia agent first. Fancy multi-tool graphs are how people stall for a week.
Frequently asked questions
Do I need to know LangChain to build an AI agent in n8n?
No. n8n wraps LangChain as visual cluster nodes. You pick a chat model, attach tools, and write a system message. You never open a LangChain notebook unless you want the Code node for a custom piece.
What is the minimum setup to build an AI agent in n8n?
A Chat Trigger (or webhook), one AI Agent node, one chat-model sub-node, and at least one tool sub-node. Without a tool, the Agent node refuses to run. Memory is optional but you will want it for multi-turn chat.
Why does my n8n agent forget earlier messages?
You either skipped Simple Memory, used a changing session key, or hit the context window length. The default window is only five exchanges. Raise it toward 50 for chat, and use Postgres or Redis memory if the instance restarts often.
Can I use Claude or OpenRouter instead of OpenAI?
Yes. Attach the Anthropic or OpenRouter chat-model sub-node under the same Agent. Store the key in n8n Credentials, not in the system message. Model choice changes cost and tone; the trigger, tools, and memory wiring stay identical.
Is n8n better than Make or Zapier for AI agents?
For agents that pick tools and keep memory, n8n is the practical pick among the three we cover. Make and Zapier shine at fixed workflows. Read our Make vs n8n and Zapier vs n8n posts if your job is classic automation, not an agent loop.
Does Simple Memory work in queue mode?
No. n8n docs warn that Simple Memory is unsafe in queue mode because a later turn can hit a different worker. Use Postgres or Redis Chat Memory before you put a customer-facing agent on a queued instance.
How is an AI agent different from a Basic LLM Chain in n8n?
A Basic LLM Chain is one shot: prompt in, text out. An Agent can call tools in a loop, keep memory across turns, and decide which action fits the request. If you only need a rewrite or summary, use the chain.
Do I need MCP to build my first agent?
No. Start with HTTP Request Tool, Wikipedia, Calculator, or Call n8n Workflow Tool. MCP servers are useful later when you want registry tools connected in one click. Learn the concept in our Model Context Protocol guide after this build works.
Build it, then tighten it
You now have the spine for your first n8n AI agent: Chat Trigger, Agent, model, one clear tool, and memory on a stable session key. Run three chats that need the tool and three that do not. Only then add a second tool.
Next step: open n8n, recreate the cluster above, and keep the system message short. When the log looks clean, read the full n8n review for hosting and pricing trade-offs, or jump to agents vs automation if you still need the mental model.



