Gallery

Contacts

405 W. Greenlawn Ave Lansing, Michigan 48910

contact@techjacksolutions.com

+1-616-320-4064

n8n

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.


6
Agent Types
1.19.4+
Min Version for AI
12+
Chat Model Providers
5678
Self-Host Editor Port

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.

Setup Checklist
An n8n instance on version 1.19.4 or later – AI features are available on n8n Cloud and on self-hosted instances from this version onward.
A chat model provider key – An API key for OpenAI, Anthropic, Google Gemini, or another supported provider. You add this as an n8n credential.
Keys for any external tools (optional) – The SerpApi tool needs a SerpApi key for web search. The Calculator and Wikipedia tools need no key.
For self-hosting: Docker or Node.js installed. Without a license key, n8n runs as the free Community edition, which is enough to follow this guide.

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.

2
Ways to call a model in n8n. The Basic LLM Chain does prompt-to-text in a single pass. The AI Agent node reasons, calls tools, and loops until the goal is met.

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
ConversationalMaintains a back-and-forth dialogue with the userChatbots and assistants that hold context across turns
ToolsUses the model's native tool-calling to pick and invoke toolsThe default for modern tool-capable models
OpenAI FunctionsUses OpenAI function-calling to select toolsOpenAI models with function-calling support
ReActInterleaves reasoning steps with actions (Reason + Act)Models without native tool-calling
Plan and ExecuteBuilds a multi-step plan, then executes each stepComplex tasks that benefit from upfront planning
SQLTranslates natural-language questions into SQL queriesQuerying 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
CalculatorPerforms reliable arithmetic the model would otherwise guessNothing
SerpApiRuns a Google search and returns structured resultsSerpApi key
WikipediaLooks up and returns Wikipedia article contentNothing
Wolfram|AlphaAnswers computational and factual queriesApp ID
Custom Code ToolRuns your own JavaScript or Python as a toolNothing
Call n8n Workflow ToolLets the agent invoke another n8n workflow as a toolA target workflow
MCP Client ToolConnects the agent to external MCP servers and their toolsAn 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.

System prompt (example) You are a research assistant. Use the SerpApi tool to search the web and the Calculator tool for any arithmetic. Cite a source URL for every factual claim. If you are unsure, say so rather than guessing.

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.

Guide Progress
0 of 10 sections complete

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.

Self-host with Docker docker volume create n8n_data docker run -it --rm --name n8n -p 5678:5678 -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n
Or self-host with npm npx n8n

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.

Tool descriptions drive behavior
An agent decides which tool to call by reading each tool's name and description. Vague descriptions lead to skipped or misused tools. Write a clear, specific description for every tool and a system prompt that states when to use each one.
Agent runs consume more tokens
Each reasoning step and tool call sends context back to the model, so an agent run costs more than a single LLM call. Keep the tool set small, give the agent clear stopping conditions, and monitor provider usage when an agent runs at scale.
Agents send data to model providers
Every prompt, tool result, and document the agent reads is sent to the chat model provider you configured. For sensitive data, choose a provider with a data processing agreement, use a local model through Ollama, or self-host n8n to keep workflow data on your own servers.

Troubleshooting

These are the issues that most often come up when wiring an AI Agent in n8n.

AI nodes require n8n version 1.19.4 or later. Check your version in the editor and upgrade if you are behind. On a self-hosted instance, pull the latest docker.n8n.io/n8nio/n8n image or update your npm install, then restart.
Confirm the tool sub-node is connected to the agent's tool slot, not left floating. Then tighten the tool's description and add a line to the system prompt telling the agent when to use it. If your model lacks native tool-calling, switch the agent type to ReAct.
Open the chat model sub-node and re-check its credential. A common cause is an expired or wrong-scoped API key, or a key with no billing enabled on the provider side. Re-enter the key in the n8n credential and test the connection before running the workflow.
Attach a memory sub-node. Without one, every run starts fresh. Simple Memory is the easiest option and needs no external service. If you need recall to survive restarts, switch to a persistent backend such as Postgres or Redis chat memory.
Fact-checked against n8n documentation and official sources, June 2026
n8n is a trademark of n8n GmbH. This article is an independent editorial resource by Tech Jacks Solutions. Not affiliated with or endorsed by n8n GmbH.
Before You Use AI
Your Privacy
An n8n AI agent sends prompts, tool results, and any documents it reads to the chat model provider you configure (OpenAI, Anthropic, Google, and others). Free-tier API plans may allow providers to use your data for model training, while enterprise plans typically include data processing agreements that restrict training use. To keep data on your own infrastructure, self-host n8n and use a local model through Ollama. Review each provider's data use policy before processing sensitive information.
Mental Health & AI Dependency
An n8n agent can produce outputs that feel authoritative but may contain hallucinated facts, fabricated sources, or incorrect analysis, especially when a tool fails silently. Over-reliance on agent output without human verification introduces real risk in professional and personal decisions. If you are experiencing distress:
  • 988 Suicide & Crisis Lifeline: Call or text 988
  • SAMHSA Helpline: 1-800-662-4357
  • Crisis Text Line: Text HOME to 741741
AI systems can produce plausible-sounding but incorrect guidance. For mental health, medical, legal, or financial decisions, always consult a qualified professional.
Your Rights & Our Transparency
Under GDPR and CCPA, you have the right to access, correct, and delete your personal data held by AI service providers. Tech Jacks Solutions maintains editorial independence from all vendors covered on this site. Some links may be affiliate links, which help fund independent research at no extra cost to you. The EU AI Act classifies AI agent and orchestration systems according to their intended use and risk level.