How to Build an AI Agent with n8n

Turn this article into takeaways for your work.

Each assistant summarizes the article only for you and suggests best practices for your work.

n8n is a workflow automation platform you can self-host or run in the cloud, and since 2024 it ships a dedicated AI Agent node for building agents inside the same visual canvas you'd use for any other workflow. You build an agent by dragging in the AI Agent node, connecting a chat model, one or more tools, and (usually) a memory component, then n8n hands the model that toolset and lets it decide what to call and in what order. The part that makes n8n distinct from most agent builders is that it's fair-code and self-hostable, so teams that care about owning their data and infrastructure often start here.

This guide covers why teams pick n8n for agent work, exactly what the AI Agent node is made of, a full build walkthrough, a worked example, real costs and limits, and when n8n is the wrong choice.

Why Teams Build Agents in n8n

n8n occupies a specific spot in the agent-platform landscape: more control than a pure no-code builder, less overhead than writing an agent from scratch. Three things drive that.

It's fair-code, not proprietary SaaS-only. n8n is distributed under its own Sustainable Use License, source-available and free to self-host, with a paid Enterprise License for the features larger teams need (SSO, environments, advanced permissions). That matters for a business agent specifically because self-hosting means your data, your ticket contents, your customer records, never has to leave infrastructure you control.

It mixes visual building with real code. Most of a workflow is drag-and-drop nodes. But when the AI Agent node's built-in tools aren't enough, you drop in a Code node and write JavaScript or Python inline, in the same canvas. You don't have to leave the platform to handle an edge case a no-code tool would block you on.

The AI layer is native, not bolted on. The AI Agent node is built on LangChain, and n8n now ships 400+ integrations plus memory, evaluation tooling, and multi-agent orchestration alongside it, the kind of layered design covered in stacking patterns to build AI agents. This isn't a chatbot bolted onto a workflow tool. It's an agent runtime with a workflow tool wrapped around it.

The demand for this kind of platform is real: n8n raised a $180 million Series C led by Accel in October 2025 at a $2.5 billion valuation, reporting more than 230,000 active users and over $40 million in annual recurring revenue at the time, driven largely by teams building agents rather than simple if-this-then-that automations.

What the AI Agent Node Is Made Of

The AI Agent node is different from n8n's plain LLM node, which takes one input and returns one output. The Agent node gives the model a list of tools and control over the loop: it can call a tool, read the result, decide to call another, and keep going until it has an answer. That loop is the same reason/act/observe cycle covered in how AI agents reason.

Component What it does Your options
Chat Model The LLM that powers the agent's reasoning OpenAI, Google Gemini, Anthropic, DeepSeek, Groq, Azure OpenAI, and others via community nodes
Tools What the agent can actually do, not just say Any n8n node wrapped as a tool, an HTTP Request to an API, a sub-workflow, or an external MCP server
Memory What it remembers between messages Simple Memory (session-only, clears on restart), Postgres Chat Memory (persistent, keyed by session ID), or other memory nodes

You must connect at least one tool for the Agent node to do anything beyond talk. This is the same distinction covered in how AI agents use tools: a model with no tools can only generate text, and generating text isn't the same as acting on your systems.

Memory is worth getting right early. Simple Memory is fine for a demo, but it's volatile and disappears on restart or redeploy. Anything customer-facing or long-running (a support thread that continues over days, for instance) needs Postgres Chat Memory or an equivalent persistent store, the same working-versus-persistent distinction covered in AI agent memory.

You can also connect a vector store node to give the agent retrieval over your own documents, the RAG pattern covered in depth in RAG for AI agents. Not every agent needs it. A ticket-routing agent mostly needs tools; a policy-question agent mostly needs retrieval.

The Build Walkthrough

  1. Start with a trigger. A webhook, a schedule, a form submission, or n8n's built-in Chat Trigger for testing in a chat panel.
  2. Add the AI Agent node and connect a Chat Model. Pick a model provider and set your system message here: the role and rules blocks from how to build an AI agent, stated plainly. "Answer inbound support questions using only the connected knowledge base; hand off anything you can't answer confidently."
  3. Attach Tools. Wrap the n8n nodes the agent needs as tools: an HTTP Request to your helpdesk API, a database lookup, a Slack message, a CRM update. Each tool needs a clear name and description, because the model picks tools based on that description, not on what the node secretly does.
  4. Add Memory if the agent needs to hold context across turns. Skip it for a single-shot task (classify this ticket and stop). Add Postgres Chat Memory for anything conversational.
  5. Add RAG if the agent needs to answer from your own documents. Connect a vector store node loaded with your knowledge base.
  6. Test in the chat panel before wiring a real trigger. n8n's built-in AI chat lets you run the agent conversationally and watch which tools it calls, which catches most obvious mistakes before anything touches production data.
  7. Turn on the real trigger and monitor the first runs closely. Watch for tool-selection mistakes and missing guardrails before you hand it real volume.

For a deeper walkthrough of writing the system message itself, how to build an AI agent covers all six building blocks (role, tools, rules, scenario playbook, decision logic, guardrails) that a well-specified agent needs, independent of which platform you build it on.

A Worked Example: An AI Support Triage Agent in n8n

Here's how a real function comes together on the platform, built from n8n's own pieces.

Trigger: a webhook fires when a new ticket lands in your helpdesk.

Tools: an HTTP Request node reads the full ticket and the customer's plan tier from your helpdesk API; a second HTTP Request checks the customer's account status in your CRM; a Slack node posts a summary to the right channel when the agent decides to escalate; a final HTTP Request updates the ticket's status and tags.

Memory: Postgres Chat Memory keyed by ticket ID, so if the customer replies again before the ticket closes, the agent has the full thread instead of starting cold.

Decision logic, written into the system message: classify severity and topic first. If it matches a known, low-risk pattern (password reset, billing question with a clear answer in the knowledge base), draft and send the reply directly. If it's high severity, mentions cancellation, or the agent's confidence is low, post to the escalation Slack channel with the ticket summary and stop, don't guess.

That escalation step is exactly the handoff pattern covered in multi-agent systems: a triage agent doesn't need to solve everything itself, it needs to solve what it can and hand off cleanly to a human or to a second agent, like the one described in the AI Escalation Manager Agent blueprint, for the rest. The AI Support Triage Agent blueprint has the full spec for this function, rules and guardrails included, if you want to copy the design rather than write it from scratch.

Cost and Limits

n8n itself is free to self-host under the fair-code license. The Cloud version has paid tiers priced on workflow executions. Either way, the cost that actually scales with usage is the model calls behind your Chat Model node, billed directly by whichever provider you connect (OpenAI, Anthropic, Google, and so on), not by n8n. Budget for that separately, and read AI total cost of ownership before you commit to a heavy, always-on agent, because token spend at real volume adds up faster than most first estimates.

The real limits aren't pricing, they're operational. n8n doesn't automatically retry a failed tool call or handle every edge case; you wire error handling yourself, the same way you'd wire it into any workflow. Self-hosting means you own uptime, backups, and security patching. And because an agent with tool access can be manipulated by what it reads, any n8n agent with a public-facing webhook trigger needs the same defense-in-depth thinking covered in AI agent security and prompt injection: treat inbound content as data to evaluate, not instructions to follow, and scope every tool's credentials to only what that specific agent needs.

When to Pick n8n vs Alternatives

If you want... Pick
Self-hosting, full control, and don't mind assembling more of the logic yourself n8n
A pure visual builder with the deepest catalog of app integrations Make
The fastest time to a working agent with no code at all Lindy
Full code control on top of OpenAI's own models, no visual layer OpenAI's Responses API

n8n sits between those poles. It's not the fastest path to a first demo, that's usually Lindy. It's not the broadest integration library, that's usually Make. What it offers instead is a workflow you fully own, on infrastructure you control, with an escape hatch into real code whenever the visual layer runs out of road. That trade-off, more assembly required in exchange for more control, is the same one weighed in the platform comparison in how to build an AI agent.

It's also worth remembering these aren't mutually exclusive. An agent built in n8n can call OpenAI's models as its Chat Model of choice. n8n is the orchestration layer; the model underneath is a separate decision.

Key Facts

  • n8n builds agents from an AI Agent node connected to a Chat Model, one or more Tools, and (usually) Memory, running on LangChain under the hood.
  • n8n is fair-code under its own Sustainable Use License: free to self-host, with paid Cloud and Enterprise tiers.
  • n8n raised a $180 million Series C led by Accel in October 2025 at a $2.5 billion valuation, reporting 230,000+ active users and $40 million-plus in ARR at the time.
  • The platform ships 400+ native integrations, plus custom Code nodes for JavaScript or Python when a built-in node isn't enough.
  • Model costs are billed separately by your chosen provider (OpenAI, Anthropic, Google, and others); n8n's own pricing covers hosting and executions, not tokens.

Frequently Asked Questions about Building an AI Agent with n8n

Do I need to know how to code to build an agent in n8n?

No, most agents can be built entirely with n8n's visual nodes: a trigger, the AI Agent node, a Chat Model, Tools, and Memory. Code becomes useful, not required, when you need custom logic a built-in node can't express, and n8n's Code node lets you write JavaScript or Python inline when that happens.

What's the difference between n8n's AI Agent node and its regular LLM node?

The plain LLM node takes one input and returns one output, a single pass. The AI Agent node gives the model a list of connected tools and lets it decide which to call, in what order, and whether to call more than one before answering, the reasoning loop that makes it an agent rather than a single completion.

Can I self-host n8n for free?

Yes. n8n is fair-code under its own Sustainable Use License, which means the source is available and self-hosting is free. A paid Enterprise License adds features larger teams need, like SSO and environment management, and n8n Cloud offers a fully hosted option priced on workflow executions.

What AI models can I use with n8n's AI Agent node?

The Chat Model sub-node supports OpenAI, Google Gemini, Anthropic, DeepSeek, Groq, and Azure OpenAI, among others, plus community-built connectors for additional providers. You can also switch models per workflow without rebuilding the agent's tools or memory.

How is memory handled in an n8n agent?

Through a Memory sub-node connected to the AI Agent node. Simple Memory stores conversation history in the workflow session and clears when n8n restarts, fine for testing. Postgres Chat Memory persists across restarts and keys conversations by session ID, which is what most production agents need.

Where to Go Next

n8n is one path to a working agent, not the only one. If your team wants the broadest app catalog and a more guided visual builder, see how to build an AI agent with Make. If you want the fastest possible first agent with zero assembly, see how to build an AI agent with Lindy. Whichever platform you choose, the automation tools roundup and the best no-code automation tools guide are useful references for comparing n8n against the rest of the category before you commit.

About the author

Victor Hoang

Victor Hoang

Co-Founder, Rework.com

Victor Hoang is Co-Founder and CMO of Rework. He spent 12+ years scaling B2B SaaS growth, building a lead engine that generated over 1 million leads and $10M+ in annual recurring revenue. Today he builds AI agents and MCP servers into Rework's products to empower customers across growth and operations. He writes about what actually works.