AI

How to Build an AI Agent in n8n: A Step-by-Step Guide

To build an AI agent in n8n, start a workflow with a trigger such as a chat message, add an AI Agent node and connect a chat model, memory and at least one tool. Write a system message that says when to use each tool, test it in the chat, require a person's approval for tools that change data, then publish the workflow.

  • Astro
  • Figma
  • Flutter
  • React
  • Webflow
  • Node.js
  • Python
  • n8n

Our core stack

An n8n workflow for website enquiries, where a webhook starts an AI Agent node that uses a chat model and three tools (the CRM, a calendar and Gmail), next to a Slack message asking a person to approve the agent's email before it is sent.

In n8n, an AI agent is a node in a workflow that decides some of its own steps: it reads a request, chooses which of your apps to use and works through the task with them. This guide shows how to build one, step by step, with an example agent that answers website enquiries, the safeguards a business needs and what it costs to run. n8n changes quickly, so every feature and price here was checked in n8n’s documentation and on n8n.io on 20 November 2026. TechNamah builds n8n workflows and agents for clients, and the last section says when getting help is worth it.

What is an AI agent in n8n?

An AI agent in n8n is an AI Agent node inside a workflow, connected to a chat model and at least one tool. The model reads the request, decides which tool to call, reads the result and carries on until it can finish the job.

A normal n8n workflow follows the steps you set when you built it: a new form entry goes into the CRM, then an email goes out. An agent chooses some of those steps itself. That helps when the right next step depends on what each request says, and it needs more care, because you no longer fix every step in advance. In n8n’s words (opens in a new tab), “The less of the process you can define, the more agent you need.”

Every n8n agent has four parts:

  • A trigger that starts it: a chat message, a form, a webhook, a new email or a schedule.
  • A chat model that does the thinking, such as Claude, GPT or Gemini.
  • Tools, the actions it may take: an n8n app node, a request to any API, another workflow or an MCP server. n8n requires at least one.
  • Memory, if people chat with it, so it remembers what was said earlier in the conversation.

What makes an agent different from a chatbot, and the risks that come with it, are in our guide to AI agent vs chatbot.

AI Agent node or n8n Agent: which should you use?

Use the AI Agent node when the agent does one job inside a business process. Use an n8n Agent when your team wants an assistant it can message from Slack or Microsoft Teams, as long as you accept that n8n Agents are still in preview.

n8n launched standalone n8n Agents (opens in a new tab) on 25 September 2026. They sit beside your workflows instead of inside them, persist between runs and are built in the Agents tab, where the n8n Assistant can draft one from a description for you to refine. The AI Agent node is one step that runs to completion inside a workflow.

Workflow with fixed steps Workflow with an AI Agent node n8n Agent (preview)
Who decides the next step You, when you build it The model, using the tools you connect The model, using its tools, skills and sub-agents
What starts it A form, webhook, schedule or app event The same, or a chat message Chat, Slack, Microsoft Teams, Telegram, Linear, a schedule or a workflow
What it remembers Nothing between runs Recent messages, with a memory node Each conversation, and earlier ones with episodic memory turned on
Best for Work you can list step by step A judgement call in a set process: sort, look up, draft A team assistant used again and again
How n8n counts it One execution per run One execution per run One execution per message and reply

Our advice: build business processes with the AI Agent node. Each run sits in a workflow you control, is logged in Executions and can hand its result to fixed steps. Try n8n Agents for internal helpers, and wait until they leave preview before customers rely on one. The rest of this guide uses the AI Agent node.

What do you need before you build an n8n agent?

An n8n account, a chat model, access to the apps the agent will use and one clearly defined job.

  • n8n: n8n Cloud, which n8n runs for you, or the free Community Edition on your own server. Cloud is quicker to start; self-hosting keeps your data on your own server. Our n8n vs Zapier guide compares the two ways to run it.
  • A chat model: an API key from a provider such as Anthropic, OpenAI or Google. On n8n Cloud Starter and Pro you can pay for models with n8n’s prepaid Gateway credits instead, without an account at the provider.
  • Access to each app the agent will use, such as your CRM, calendar and mailbox. Give the agent its own login where you can, with only the permissions its job needs.
  • One job, written down: what starts it, what it may do, what it must never do and when it must ask a person. A narrow job is easier to test and to trust.

To see the parts working before you build your own, copy n8n’s template Build your first AI agent (opens in a new tab): a chat agent with Gemini, memory and two tools, a weather forecast and a news feed.

How do you build an AI agent in n8n?

In seven steps: add a trigger, add the AI Agent node, connect a chat model, add memory if people will chat with it, connect its tools, write the system message, then put a person’s approval on the risky tools, test the agent and publish it.

The example is an agent that answers enquiries from a company’s website. It looks the sender up in the CRM, checks the calendar for two free meeting times and replies by email, and a person approves each email in Slack before it goes out.

1. Add a trigger

The trigger decides when the agent runs. While you build, use the Chat Trigger: it opens a chat panel in the editor where you can talk to the agent. For the live agent, use the trigger that fits the job, such as a Webhook or n8n Form trigger for a website form, a Gmail trigger for new emails or a Schedule trigger for a daily task. To let customers chat with the agent itself, keep the Chat Trigger and make the chat public, as a hosted page or embedded in your website.

In the example, the website’s enquiry form sends each enquiry to a Webhook trigger.

2. Add the AI Agent node

Add an AI Agent node after the trigger. With a Chat Trigger, it picks up each message by itself. With any other trigger, set its prompt (the user message) to Define below and point it at the fields that hold the request: in the example, the enquiry’s message, with the sender’s name and company.

There is no agent type to choose any more. Since n8n 1.82.0, every AI Agent node works as a Tools Agent, so a guide that asks you to pick a Conversational or ReAct agent was written for an older version.

3. Connect a chat model

Click the node’s Chat Model connector, choose a model node such as Anthropic, OpenAI or Google Gemini, and add your API key as a credential, or use Gateway credits on n8n Cloud. Start with a model that is good at calling tools. Once the agent works, run the same test requests through a cheaper model and switch only if the answers hold up.

4. Add memory, if people will chat with it

Memory lets the agent remember earlier messages in a conversation, so a follow-up such as “and on Friday?” makes sense. Simple Memory is the quickest start: it keeps the latest exchanges of each conversation, as many as you set in Context Window Length. It does not work when n8n runs in queue mode, which spreads heavy workloads across several workers; there, Postgres Chat Memory or Redis Chat Memory take its place.

The example needs no memory. Each enquiry is one run, and everything the agent needs arrives with it.

5. Connect the tools

Tools are what the agent can do. Click the Tool connector and add one tool for each action:

  • An app node used as a tool, such as Gmail, Google Calendar, HubSpot or Slack.
  • The HTTP Request tool for any app with an API.
  • The Call n8n Workflow Tool to run another of your workflows, for a step that needs several nodes.
  • The MCP Client tool to use the tools of an MCP server.

The model picks tools by their names and descriptions, so give each tool one small job and describe it plainly. Let the model fill in only the fields that must change with each request, using the button beside the field or n8n’s $fromAI() expression, and fix everything else. In the example, the email’s recipient is fixed to the person who wrote in, so the agent cannot email anyone else.

Tool n8n node What the model fills in What stays fixed
find_contact HubSpot The sender’s email address Read-only access
check_calendar Google Calendar The dates to check One calendar, read-only
send_reply Gmail The subject and the message The recipient, and a person’s approval (step 7)

6. Write the system message

The system message holds the agent’s standing instructions; you set it in the AI Agent node’s options. Write it like a brief for a new colleague:

  • Role and goal: who it works for and what a finished job looks like.
  • Tools: when to use each one, and in what order if the order matters.
  • Rules: what it must never do, such as quote prices or promise dates.
  • When to stop: what to do when information is missing, or when a person declines one of its actions.
  • The reply: its format, length and tone.

For the example agent:

You reply to enquiries sent through the contact form on our website.

  1. Look up the sender with find_contact. If they are an existing client, say so in your reply.
  2. Use check_calendar to find two free meeting slots on weekdays between 10:00 and 16:00.
  3. Write a short, friendly reply that answers their question and offers both slots.
  4. Send it with send_reply. A person approves every email before it goes out.

Never quote prices, discounts or delivery dates. If you cannot answer the enquiry, reply that a colleague will follow up, and send that instead. If a person rejects your email, stop.

The example agent's system message.

7. Add human review, test and publish

Decide which tools need a person’s approval before anything goes live. On the AI Agent node’s Tools connector, add a Human review (opens in a new tab) step and connect the risky tools to it. When the agent calls one, the workflow pauses and a person approves or denies the call, in n8n’s chat, Slack, Microsoft Teams, Gmail, Outlook, Telegram, Discord, Google Chat or WhatsApp Business. A denial cancels the action and tells the agent, which is why the system message says what to do next. In the example only send_reply goes through review, in the team’s Slack channel; the CRM and calendar lookups run freely, because reading changes nothing.

Then test. Send real requests in the chat, including awkward ones: a vague message, a request the agent should refuse, an angry customer. Open each run in Executions to see which tools the agent called and what they returned, and adjust the system message and the tool descriptions until it behaves. n8n’s evaluations can rerun a saved set of test requests after every change. When it passes, click Publish: since n8n 2.0, Save keeps your changes as a draft, and Publish puts the workflow live.

The example enquiry agent in n8n: a website form starts the workflow; the AI Agent node, with a chat model and a system message, looks the sender up in the CRM and checks the calendar freely; its email goes through human review in Slack before it is sent; each run counts as one execution and is logged in Executions.

How do you keep an n8n agent safe and reliable?

Give it no more power than the job needs, ask a person before anything that cannot be undone, and watch what it does.

  1. Small tools, limited access. One action per tool, each with a credential that can do only that: read-only for lookups, one mailbox, one calendar.
  2. A person approves what matters. Put sending, paying, deleting and anything a customer sees behind Human review until the agent has earned trust. An agent that drafts emails instead of sending them is a safe first version.
  3. A cap on every run. Max Iterations limits how many times the model runs for one request, 10 by default, so a confused agent cannot loop for ever.
  4. An error workflow. Set one in the workflow’s settings, so a failure sends an alert to Slack or email instead of going unnoticed.
  5. A look at the log. n8n keeps every run in Executions, with each tool call and its result. Read a sample regularly, most of all in the first weeks.
  6. Less personal data in prompts. Send the model only the fields the job needs, and check where your model provider processes data and whether it trains on it.

How much does an n8n AI agent cost to run?

Three things: the n8n plan, the AI model and the time to look after it. As of 20 November 2026, n8n Cloud Starter costs €24 a month, or €20 a month billed yearly, for 2,500 workflow executions. Each run of the workflow counts once, however many tools the agent calls.

Plan Price, as of 20 November 2026 What you get
n8n Cloud Starter €24 a month, or €20 billed yearly 2,500 executions, 5 running at once, the AI Agent node and n8n Agents, 1,600 Assistant credits a month, AI models without an API key
n8n Cloud Pro €60 a month, or €50 billed yearly 10,000 executions, up to 50 running at once, up to 9,600 Assistant credits a month, workflow history
n8n Business €800 a month, or €667 billed yearly 40,000 executions, self-hosted only, single sign-on, separate environments, Git version control
Community Edition Free Self-hosted; you pay for the server and for your model provider

Prices from n8n’s pricing page (opens in a new tab).

The model is paid for separately. With your own API key, your provider bills each request by the amount of text sent and returned. On n8n Cloud Starter and Pro you can buy prepaid Gateway credits (opens in a new tab) instead, charged per request at n8n’s rates; they are not available on Enterprise or self-hosted n8n. Our guide to what it costs to add AI to an app lists current model prices. For n8n Agents, each message and reply counts as one execution, from the same allowance as your workflows.

Example: the enquiry agent’s month

Line Figure How it is worked out
Enquiries 1,000 a month Each one starts one run
n8n executions 1,000 a month Inside Starter’s 2,500; the three tool calls and the wait for approval add nothing
n8n plan €24 a month Starter billed monthly, or €20 a month billed yearly
AI model Per request Your provider’s prices, or Gateway credits
An example, not a client's figures.

Usually the larger cost is people’s time: building and testing the agent, checking its work and fixing it when a connected app changes. Our guide to AI automation ROI shows how to weigh those costs against what the agent saves.

Can you build an n8n agent without code?

Yes. The trigger, the AI Agent node, the model and the tools are all set up in n8n’s visual editor, and the system message is plain language. The n8n Assistant, in preview, can draft a workflow or an n8n Agent from a description, using Assistant credits: 1,600 a month on Starter and up to 9,600 on Pro, as of 20 November 2026. Code is there when you need it: the Code node runs JavaScript or Python for logic that no node covers.

When should you get help building an n8n agent?

When the agent will talk to customers, handle money or personal data, connect several systems or run at volume, or when you want n8n on your own server. These builds depend less on clever prompts than on careful permissions, approvals, tests and monitoring.

At TechNamah, we build n8n workflows and AI agents for clients, on n8n Cloud or your own server, with the approvals, alerts and logs described above. On a free 30-minute strategy call we look at the job you want the agent to do, tell you if a fixed workflow would do it for less and quote the build, and you see a first prototype within 72 hours. See our n8n workflow automation and AI agent development pages, or book a free strategy call. We reply to every request within 24 hours.

How we write and check our articles: Editorial policy.

Got Questions

Frequently asked questions

Is n8n free for building AI agents?

The self-hosted Community Edition of n8n is free, AI Agent node included, under n8n's Sustainable Use License. You pay for the server it runs on and for the AI model it calls. n8n Cloud, which n8n runs for you, starts at €24 a month, or €20 a month billed yearly, for 2,500 workflow executions, as of 20 November 2026, with a free trial.

Does n8n AI cost money?

The AI model does, wherever n8n runs. With your own API key, the model provider bills you for each request; on n8n Cloud Starter and Pro you can pay with prepaid Gateway credits instead. On its paid plans n8n also counts workflow executions, and one run of an agent counts once, however many tools it calls.

Can you build an AI agent in n8n without coding?

Yes. You connect a trigger, an AI Agent node, a chat model and tools in n8n's visual editor, and write the agent's instructions in plain language. The n8n Assistant, in preview, can draft the workflow from a description. Code is only needed for custom logic, in the Code node, which runs JavaScript or Python.

Which AI model should you use for an n8n agent?

Start with a model that is good at calling tools, such as a current model from Anthropic (Claude), OpenAI (GPT) or Google (Gemini), all of which n8n connects to. Once the agent passes your test requests, run the same tests on a cheaper model and switch only if the answers hold up.

What is the difference between the AI Agent node and n8n Agents?

The AI Agent node is one step inside a workflow, so it runs when the workflow runs and finishes with it. n8n Agents, in preview since September 2026, are standalone. You build them in the Agents tab, they persist between runs, and people reach them from chat, Slack, Microsoft Teams, Telegram, Linear, a schedule or a workflow.

Have an Idea? Let's Build It.

Building your first product? Scaling an existing platform? Integrating AI workflows?

We deliver speed and precision. Book a free strategy call. No obligations, just honest advice.

Book a Free Strategy Call
  • No commitment required
  • Response within 24 hours
  • Free 30-min strategy session