Automation & MCPs

n8n AI Agent Tutorial: Build Your First Agent With Connected Tools

Learn how to build an n8n AI agent step by step: a chat trigger, an AI Agent node, connected tools, and a system prompt that actually holds up.
D
Founder, Asset Academy
·15 min read ·September 7, 2026
A diagram of an n8n AI agent tutorial workflow with a chat trigger, an AI Agent node, connected tools, and memory.
In this guide10 sections
  1. What is an n8n AI agent, and how is it different from a regular workflow?
  2. What do you need in place before you build one?
  3. How do you build a basic n8n AI agent, step by step?
  4. How do you connect tools so the agent can actually do something?
  5. How do you write a system prompt the agent will actually follow?
  6. How do you keep the agent from running wild on tool calls or cost?
  7. How do you test the agent before you trust it with real traffic?
  8. What's a good prompt for planning your agent before you touch the canvas?
  9. Where does an n8n AI agent break down, and when should you use a plain workflow instead?
  10. Frequently Asked Questions

Your workflow can move data all day, but the moment it needs to make a judgment call, it breaks. An n8n AI agent fixes that: a chat trigger feeds an AI Agent node, the node is wired to a model and a couple of tools, and the agent decides which tool to use, instead of you hardcoding every branch.

An n8n AI agent is a workflow built around the AI Agent node: a trigger passes a request in, the node is wired to a language model, optional memory, and one or more tools, and the model decides which tool to call, in what order, to answer the request.

This matters because most automation work stalls at the same wall: logic that depends on judgment, not just data movement. A support message that needs to be read before it's routed. A lead that needs to be qualified before it's logged. An agent handles that layer without you mapping every possible path with IF nodes. What decides whether it actually works isn't which model you pick, it's how precisely you write the system prompt and the tool descriptions, and how much you test before real traffic hits it.

What is an n8n AI agent, and how is it different from a regular workflow?

A regular n8n workflow runs the same sequence of nodes every time: node A feeds node B, which feeds node C. An AI agent breaks that on purpose: the AI Agent node asks a connected language model what to do next, which tool to call, in what order, and when it has enough to answer. That loop of reason, act, observe, reason again is what separates an agent from a workflow (agentic loops covers the mechanics if you want the theory first).

The node has up to four connection points: a Chat Model (required, the LLM doing the reasoning), Memory (optional, recall of earlier turns), Tool (optional, repeatable, how it takes action or pulls in outside data), and an Output Parser (optional, forces the answer into structured JSON instead of free text). A trigger feeds the agent a request, the agent decides what to do with it. That's the whole shape.

What do you need in place before you build one?

Four things, ready before you open the canvas: an n8n instance, cloud or self-hosted (n8n for beginners covers setup if you haven't touched it yet); an API key for a model that supports tool calling (most current OpenAI, Anthropic, and Google models qualify, a model without it can chat but can't act); credentials for whatever systems the agent needs to touch, an order API, a Slack webhook, a Google Sheet, whatever's relevant; and, most important, one narrow job written in a single sentence.

That last one is where most first builds go wrong. "Handle customer support" isn't a job you can build or test. "Look up an order by number and report its shipping status" is. Start narrow. Widen the job once the narrow version actually works.

How do you build a basic n8n AI agent, step by step?

Five pieces, wired in order, get you a working agent: a trigger, the AI Agent node, a chat model, memory if the job needs it, and at least one tool. Here's the build, using a running example: an agent that looks up an order by number and replies with its shipping status.

Drop a Chat Trigger on the canvas. The "When chat message received" trigger gives you a built-in test chat inside the editor, no separate front end needed yet.

Add the AI Agent node and connect it to the trigger. This is the node doing the orchestrating. Leave the system message blank for now, you'll write it once the rest is wired.

Connect a Chat Model. Click the Chat Model port on the Agent node, add a model node (OpenAI, Anthropic, whichever provider you've got a key for), and attach your credential. Pick one that supports tool calling.

Connect Memory, if the job needs it. A one-shot order lookup doesn't need memory. A support agent handling back-and-forth does. Add a Simple Memory node and wire it in if that's your case.

Connect one tool. For the order-lookup example, that's an HTTP Request Tool pointed at your order API, with the order number field set to "let the model fill this in" so the agent pulls it straight out of the message. Get one tool working end to end before you add a second.

Write the system message, then test. Give it a role, a job, and a boundary (more on this below), then run the built-in test chat with real and edge-case messages before you touch the toggle that activates the workflow.

How do you connect tools so the agent can actually do something?

Tools are what separate an agent from a chatbot with good manners. n8n gives you four practical ways to build one:

Whichever type you use, the description does more work than the tool itself: the agent reads it, not your code, and decides whether this sounds right for the step. Write it like you're briefing a new hire on when to use this tool over the similar one next to it. If you're wiring the agent into tools you already use for outreach, connecting an AI agent to your marketing tools walks through that setup, and MCP is a growing standard for plugging in a pre-built tool library instead of hand-building every connection.

How do you write a system prompt the agent will actually follow?

A system prompt that holds up has four parts, and none of them is "be helpful and friendly."

The role. One sentence: what this agent is, for whom. "You are a support agent for [COMPANY] that helps customers check the status of an existing order."

The job, stated narrowly. If the job is order status, say order status, not "assist with order-related questions," which quietly invites it to answer pricing or refund questions it has neither the tool nor the facts for.

The boundaries. What it should never do: never invent a status if the tool call fails, never discuss pricing or promise a refund, never wander past the topic it was built for. This is what keeps a narrow agent narrow.

The fallback. What it says when it can't help: hand off to a human, state plainly it doesn't have the information, don't guess. An agent that admits it's stuck beats one that answers confidently and wrong.

Keep it tight, under 200 words is a fair ceiling for a single-job agent: every extra sentence gets sent to the model on every turn, so a bloated prompt makes the agent slower and pricier, not smarter. Once it's earning its keep, version it: turning your best prompts into reusable skills means your next agent doesn't start from a blank page.

How do you keep the agent from running wild on tool calls or cost?

Three guardrails catch almost everything that goes wrong with a first agent.

Cap the iterations. The Agent node's max iterations setting caps how many tool-call rounds it gets before it has to stop and answer with whatever it's got. A confused agent with a vague tool description can loop without one, chasing an answer that isn't there; a hard cap turns that into a fast, visible failure instead of a silent, expensive one.

Watch what tool outputs cost you. Every tool call sends the growing conversation, tool result included, back to the model, and every round trip costs money and latency. A tool that dumps a full API response into context is slower and pricier than one that returns just the fields the agent needs.

Don't over-tool a single agent. More tools means more chances it picks the wrong one, especially when two sound similar. Keep a single agent's tool count small and specific to its one job. If the real job spans several concerns, split it into separate agents connected through Workflow Tools instead.

If the job doesn't need live chat at all, say a daily check against a report, a schedule trigger feeding the same Agent node works the same way; running an AI agent on a schedule covers that variant.

How do you test the agent before you trust it with real traffic?

Run the built-in test chat through three kinds of messages before you flip the workflow to active.

The happy path. A clean, normal request, the exact thing you built the agent for. If this doesn't work cleanly, nothing else matters yet.

The edge case. An order number that doesn't exist, a misspelled name, a question missing information the tool needs. This is where you find out whether your fallback instruction actually fires, or whether the agent guesses.

The out-of-scope ask. Something outside the narrow job on purpose: pricing, a different product, an unrelated question. This tests the boundary paragraph in your system prompt. If the agent answers instead of declining, the boundary isn't tight enough yet.

Open the execution log after each run and check what tool the agent actually called, not just the final reply. That trail is your only real visibility into an agent's reasoning, and it's usually where you catch a description vaguer than you thought, or a tool the agent never touches because a different one sounded more relevant. Fix the description, not the model. Once a spread of tests comes back clean, activate the workflow and watch the first real day of runs the way you'd watch a new hire's first shift.

What's a good prompt for planning your agent before you touch the canvas?

The best hour you can spend on this isn't inside n8n at all, it's five minutes with an AI model turning a vague idea into a system prompt, a tool list, and test messages you paste straight into the build above. It forces you to answer the questions n8n will ask anyway, what's the job, what tools does it need, what should it say when it doesn't know, before you're staring at a blank Agent node.

Prompt to plan your agent's system prompt, tools, and test cases before you build it.
You are a workflow architect helping me design an AI agent I'm about to build in n8n.

The job: [DESCRIBE THE JOB IN ONE OR TWO SENTENCES, e.g., "answer customer questions about order status by looking up our shipping API and replying in the same chat"]

The tools I can realistically connect: [LIST YOUR REAL TOOLS/APIS, e.g., "a REST API for order lookup, an internal FAQ doc, Slack for escalation to a human"]

Give me:
1. A system prompt (role, narrow job, explicit boundaries, what to say when it can't help). Under 200 words.
2. A tool description for each tool, written the way I'd paste it into n8n's "Tool Description" field, specific enough the model won't confuse two similar tools.
3. Five test messages, a normal request, an edge case, and something outside the agent's job, to paste into n8n's test chat before I turn this on for real traffic.
4. The single most likely way this agent misfires given the tools involved, and the guardrail (max iterations, a fallback line, a human handoff) that prevents it.

Be specific to my use case. No generic filler.

Paste the output straight into the build: the system prompt goes in the Agent node's System Message field, the tool descriptions go in each tool's description field, and the five test messages are your first test chat session.

Where does an n8n AI agent break down, and when should you use a plain workflow instead?

An agent is the wrong tool more often than the hype suggests. If a decision only ever has two or three real outcomes, an email containing "@gmail.com," an order total over $500, a plain workflow with an IF node is faster, cheaper, and identical every time. Reach for an agent when the input is genuinely open-ended, not when you're avoiding a few conditional branches.

The same request can take a slightly different path through an agent on two different runs, because the model makes a judgment call each time instead of executing a fixed script. That's fine for a support reply. It's not fine anywhere you need identical, auditable behavior: a compliance check, a financial calculation, a legal disclosure. Keep the agent at the ambiguous decision point and hand a deterministic workflow the rest.

Debugging an agent is a different, slower skill than debugging a workflow, too. When a normal workflow fails, you find the node that threw the error. When an agent gives a bad answer, nothing technically failed, it just reasoned its way somewhere you didn't want, and the execution log is your only window into why.

Frequently Asked Questions

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

No. The core build (trigger, AI Agent node, chat model, tools) is drag-and-drop. You'll want basic JavaScript only if you add a Code Tool; a working first agent doesn't require writing a line.

Which AI model should I connect to my n8n agent?

Any current model with tool-calling (also called function-calling) support works: recent OpenAI, Anthropic, and Google models all qualify. Brand matters less than whether it reliably follows your system prompt's boundaries, so test two or three against your real test messages rather than assume the newest or priciest one is the right fit.

Is n8n's AI Agent node free to use?

n8n has a free, self-hosted option alongside paid cloud plans, so the platform itself doesn't have to cost you anything beyond hosting. The model calls are separate and billed per token by your provider, so check that pricing directly rather than assume n8n's cost covers it.

How is this different from a custom GPT or a chatbot with plugins?

A custom GPT or plugin-based chatbot lives inside that provider's chat interface, built for a person to talk to. An n8n AI agent lives inside your automation platform, triggered by a webhook, schedule, or form instead of only a chat window, and wired directly into your own systems rather than a curated plugin store, fit for unattended or backend use a standalone chatbot isn't.

What happens if the agent picks the wrong tool?

It usually means the tool description is too vague or overlaps with another tool's, not that the model is broken. Check the execution log for what it actually called, compare the description against what a stranger reading it cold would assume, then sharpen it and re-test. A stricter system-prompt boundary helps too, especially when two tools sound similar.

None of this is complicated once you've built one: a handful of nodes, a system prompt that says exactly what it means, tool descriptions tight enough the model can't get confused. What takes reps is judgment: which jobs are narrow enough for a first agent, how to write a tool description that holds up, when to split into two agents instead of one. That's faster to learn alongside people shipping these into real businesses every week and comparing notes on what breaks. If you want to build it with operators doing exactly that, come build it inside Asset Academy.

D
Don Lyons is the founder of Asset Academy. He has been building and selling digital assets since 2007, and writes across every category with a bias toward the moves that actually move money.
Build it with us

Stop reading about copy. Write it with operators who ship.

Inside the Asset Academy community we build the copy, funnels, and offers together, with the prompts and the feedback. $96/mo, or save with annual.

Join the community →