How to Build AI Agents in n8n
n8n lets you build AI agents on the same visual canvas you use for the rest of your automations. Instead of writing orchestration code, you drop an AI Agent node onto a workflow, attach a chat model, give it tools and memory, and connect it to whatever trigger fires your workflow. This guide walks through the pieces that make up an n8n agent: how the AI Agent node differs from a plain LLM call, the agent types and tools you can choose, which chat models plug in, and a step-by-step build you can follow on the canvas. n8n's advanced AI is built on LangChain (vendor-reported), so the concepts here carry over if you ever drop down to code.
What you will build: A single AI Agent node wired to a chat trigger, a chat model, conversation memory, and a small set of tools (Calculator plus a web search) that answers questions and shows its tool calls on the canvas.
Prerequisites
You do not need to write code to build an agent in n8n, but you do need a working n8n instance and at least one model provider key. Confirm the following before you start.
The AI Agent Node vs a Plain LLM
n8n gives you two distinct ways to call a language model, and choosing the right one is the first decision in any AI workflow. The Basic LLM Chain takes a prompt and returns a text response. That is all it does: prompt in, completion out. It is the right choice when you want a model to rewrite text, classify a message, or summarize a document in a single pass.
The AI Agent node is goal-oriented. Instead of generating a one-shot response, an agent reasons about a task, decides which tools it needs, calls them, reads the results, and keeps going until it has met its goal. If you ask a plain LLM "what is 4,318 times the current EUR to USD rate," it will guess. An agent with a Calculator tool and a search tool will look up the rate, run the multiplication, and return a grounded answer.
Both are cluster nodes: a root node (the agent or chain) plus sub-nodes that attach to it for the model, memory, and tools. This root-plus-sub-nodes pattern is how all of n8n's advanced AI is wired together, and it is what lets you swap a chat model or add a tool without rebuilding the workflow.
Agent Types
The AI Agent node exposes several agent types. Each one uses a different reasoning strategy under the hood, and the right choice depends on your model and your task.
| Agent Type | How It Reasons | Use When |
|---|---|---|
| Conversational | Maintains a back-and-forth dialogue with the user | Chatbots and assistants that hold context across turns |
| Tools | Uses the model's native tool-calling to pick and invoke tools | The default for modern tool-capable models |
| OpenAI Functions | Uses OpenAI function-calling to select tools | OpenAI models with function-calling support |
| ReAct | Interleaves reasoning steps with actions (Reason + Act) | Models without native tool-calling |
| Plan and Execute | Builds a multi-step plan, then executes each step | Complex tasks that benefit from upfront planning |
| SQL | Translates natural-language questions into SQL queries | Querying a database conversationally |
Start with Tools. If your chat model supports native tool-calling (most current OpenAI, Anthropic, and Gemini models do), the Tools agent is the most reliable default. Reach for ReAct only when your model lacks tool-calling support.
Chat Models
The chat model is the sub-node that supplies the agent's reasoning. n8n ships chat model sub-nodes for a wide range of providers, so you can pick one based on cost, latency, privacy, or the capabilities you need.
- Hosted providers: OpenAI, Anthropic, Google Gemini, Mistral Cloud, Groq, DeepSeek, xAI Grok, Moonshot Kimi, and NVIDIA Nemotron
- Local and self-managed: Ollama, for running open models on your own hardware
- Gateways: OpenRouter and Vercel AI Gateway, which route a single credential to many underlying models
The gateway option is worth a second look if you want to test several models without managing a key for each. An LLM gateway like OpenRouter gives you one credential and one billing relationship while letting the agent reach dozens of models behind it. You attach the gateway as the chat model sub-node and select the underlying model from a dropdown.
Because the chat model is a swappable sub-node, you can prototype an agent against a fast, cheap model and later switch to a more capable one without touching the rest of the workflow. Only the sub-node changes; the agent, tools, and memory stay in place.
Chains and Tools
Not every AI task needs a full agent. n8n also offers purpose-built chains for common single-purpose jobs, and a library of tools that agents call to reach outside themselves.
Chains for single-purpose tasks
Chains do one job well and skip the agent's tool-selection overhead. Reach for these when the task is fixed and you do not need autonomous reasoning.
- Basic LLM Chain – prompt-to-text, the simplest building block
- Question and Answer Chain – answers questions against retrieved context (the core of a RAG setup)
- Summarization Chain – condenses long documents
- Information Extractor – pulls structured fields out of unstructured text
- Text Classifier and Sentiment Analysis – label and score incoming text
Tools agents can call
Tools are how an agent acts on the world. You attach one or more tool sub-nodes to the agent, and the agent decides when to call each based on the tool's name and description.
| Tool | What It Does | Requires |
|---|---|---|
| Calculator | Performs reliable arithmetic the model would otherwise guess | Nothing |
| SerpApi | Runs a Google search and returns structured results | SerpApi key |
| Wikipedia | Looks up and returns Wikipedia article content | Nothing |
| Wolfram|Alpha | Answers computational and factual queries | App ID |
| Custom Code Tool | Runs your own JavaScript or Python as a tool | Nothing |
| Call n8n Workflow Tool | Lets the agent invoke another n8n workflow as a tool | A target workflow |
| MCP Client Tool | Connects the agent to external MCP servers and their tools | An MCP server |
The MCP Client Tool is the bridge to the wider Model Context Protocol ecosystem: it lets an n8n agent use tools exposed by any MCP server. n8n can also run as an MCP server itself, which is covered in the dedicated n8n and MCP breakdown.
Memory and Vector Stores
By default an agent treats every run as a blank slate. Two sub-node families change that: memory gives an agent recall of the current conversation, and vector stores give it access to your own documents.
Memory
Attach a memory sub-node so the agent remembers earlier turns in a conversation. The Simple Memory option keeps recent messages in n8n itself and needs no external service, which makes it the right starting point. For memory that survives restarts or scales across many sessions, n8n offers backends including MongoDB, Redis, Postgres, Xata, Motorhead, and Zep.
Vector stores for retrieval
To ground an agent in your own knowledge, you store document embeddings in a vector database and let the agent query them. n8n connects to a broad set of vector stores: Pinecone, Chroma, Qdrant, Milvus, PGVector, Redis, Supabase, Weaviate, and Zep. Pair a vector store with the Question and Answer Chain to build a retrieval-augmented assistant that answers from your content rather than the model's training data.
Match the store to the workload. If you already run Postgres, PGVector keeps everything in one database. If you want a managed service with no infrastructure, a hosted store like Pinecone is the faster path.
Build Your First Agent
Here is the full build, following n8n's own "Build an AI workflow" tutorial. Each step is something you do on the canvas; no code is required.
Step 1: Add a trigger
Create a new workflow and add a trigger that gives it an entry point. The Chat Trigger opens a chat panel you can talk to directly, which is ideal for testing an agent. A Manual Trigger also works if you just want to run it once.
Step 2: Add the AI Agent node
Add the AI Agent node and connect the trigger to it. The agent appears as a root node with empty sub-node slots beneath it for the model, memory, and tools.
Step 3: Attach a chat model
Click the model slot and add a chat model sub-node, for example OpenAI Chat Model. Create or select the provider credential (your API key), then choose a model from the dropdown.
Step 4: Attach memory and tools
Add a Simple Memory sub-node so the agent remembers the conversation. Then add tool sub-nodes; for this build, attach the Calculator tool and the SerpApi tool so the agent can do math and search the web.
Step 5: Write the system prompt
Open the AI Agent node and set its system instructions. Tell the agent what its job is and when to use each tool. An explicit prompt produces far more reliable tool use than a vague one.
Step 6: Test the workflow
Run the workflow from the canvas. With the Chat Trigger, type a question into the chat panel and watch the agent work. n8n shows each step: which tool the agent called, what it sent, and what came back, so you can see the reasoning rather than just the final answer.
Cloud vs Self-Host
The AI Agent node works the same on n8n Cloud and on a self-hosted instance, so the choice comes down to who manages the infrastructure and where your data goes.
n8n Cloud is the fastest way to start: n8n runs and scales the platform for you, and AI features are available out of the box. n8n recommends Cloud for anyone who is not an infrastructure specialist.
Self-hosting gives you maximum control and keeps workflow data on your own servers, which matters when you process sensitive information. You can start an instance in minutes with Docker or npm, and the editor opens at localhost:5678.
Without a license key, a self-hosted instance runs as the free Community edition, which is enough to build and run the agent in this guide. A Business or Enterprise license key unlocks those editions. For high-volume production workloads, n8n uses queue mode, which adds worker processes and a broker to run executions in parallel. A self-hosted AI Starter Kit is also available to bootstrap a local AI stack.
Limitations and Gotchas
Building agents on a visual canvas removes a lot of friction, but there are tradeoffs worth knowing before you put one in front of users.
Troubleshooting
These are the issues that most often come up when wiring an AI Agent in n8n.
Video Resources
Go Deeper
Resources from across Tech Jacks Solutions
Agent Frameworks Compared
Side-by-side analysis of LangChain, CrewAI, AutoGen, and more
Agent Threat Landscape
Security risks specific to autonomous AI agents
FREEAgentic AI Compliance Assessment
Compliance checklist for autonomous agent deployments
PREMIUMPre-Deployment Safety Gate
27-point checklist before any AI tool goes live
IAPP AIGP Certification
The AI governance certification for privacy professionals