Tutorials n8n

n8n AI Agent Guide: Workflows That Pick Their Own Tools

n8n's built-in AI Agent node lets a workflow think: you supply the goal and tools, it picks the route. Build one step by step, with cost estimates and traps.

E
Eric Founder, Roamer Tech · · 8 min read

Want to start now? Deploy your n8n in 60 seconds

Workflow automation platform. From avg. NT$499/mo (billed yearly).

Subscribe to n8n

A normal n8n workflow is "when A happens, do B": a form is submitted so a row goes into a spreadsheet, or a report goes out every morning at eight. The path is fixed, and you drew every step in advance. An AI Agent is different: you give it a goal and a set of tools, and it decides the route itself. A customer asks "where is my order from last week", and the agent works it out on its own: check the order system, then check the shipping API, then turn both results into one plain-language reply. You drew none of those three steps; it worked them out.

This article walks you through building your first tool-using AI Agent in n8n from scratch. No programming required, but you do need an API key for a language model, and that cost is not included in the hosting fee. At the end we give you a rough budget figure.

The 30-second overview

ItemDetails
What you buildAn AI assistant that can converse and decides on its own when to look something up
How long it takesAbout 30 to 45 minutes the first time
What you needAn n8n instance (version 1.x) and one LLM API key (OpenAI, Gemini, or Claude)
DifficultyAnyone who has built one ordinary workflow can follow along; if you have never touched n8n, start with the first workflow tutorial

Before you start: instance and API key

The AI Agent node is built into n8n 1.x, with no community nodes to install. An n8n hosted instance from RoamerHost always runs the latest stable version, so you can use it as soon as you log into the editor. If you self-host, check that your version is 1.19 or above.

Get an API key from the matching platform: OpenAI at platform.openai.com, Gemini at Google AI Studio, Claude at console.anthropic.com. Any of the three works, and for a first attempt we suggest Gemini, since it has a free tier and testing costs almost nothing.

Step 1: create the workflow and a Chat Trigger

Create a new workflow and pick Chat Trigger as the first node (search for "chat" and it comes up). It gives you a chat window where you will do all your testing, so you do not have to decide which messaging app to connect yet.

Once it is added, an "Open chat" button appears at the bottom of the canvas. Leave it for now and press it after the agent is wired up.

Step 2: add the AI Agent node and attach a model

Add an AI Agent node after the Chat Trigger. It does not look like an ordinary node: it has three extra attachment points underneath, Chat Model (the brain), Memory, and Tool (the hands).

  1. Click the Chat Model attachment point and pick your model provider (for example Google Gemini Chat Model).
  2. In the Credential field, choose "Create new credential", paste in your API key, and save.
  3. Pick a cheap model to get things working, such as gemini-2.5-flash or gpt-4o-mini, and swap in a bigger one later if it is not smart enough.

Press "Open chat" now and type a few lines. The agent will already reply, but at this point it is only a chatbot with no tools at all.

Step 3: give it tools, which is what makes it an agent

The Tool attachment point takes more than one tool. The three common ones:

  • HTTP Request Tool — lets the agent call any API. Write the Description field in plain language, spelling out what this tool looks up and when it should be used, because the agent relies on that description to decide whether to call it.
  • Google Sheets Tool — for data that lives in a spreadsheet, such as stock levels or a price list.
  • Call n8n Workflow Tool — wraps an existing workflow of yours into a tool the agent can use. This is the most powerful one: make looking up an order, opening a ticket, and sending a notification into separate workflows, and the agent calls them itself when it needs them.

Attach just one to start. For example, attach an HTTP Request Tool pointed at a public weather API, with the description "look up the current weather for a given city". Go back to the chat window and ask "what is the weather in Taipei right now", and you will see in the execution log that the agent really did call that tool. That is the moment it stops being a chatbot and becomes an agent.

Step 4: system message and memory

The AI Agent node's Options contain a System Message, which sets its personality and boundaries. The three things that help most in practice:

  • Say who it is — "You are the customer support assistant for company X, and you only answer questions related to our services"
  • Say what to do when it cannot find something — this is the most important one, because without it the model will invent an answer
  • Say when to use the tools — "Always use the tool to look up an order, never answer from memory"

Attach a Simple Memory (formerly Window Buffer Memory) to the Memory attachment point, and the agent will remember the previous few lines of the same conversation, so a customer does not have to repeat their order number in every message. Note that this is memory for a single conversation: long-term memory across days or across users needs a separate database.

Step 5: test, debug, and go live

While testing, watch two places: the chat window for the replies, and the Executions log for which tools it actually called and what parameters it passed. When an agent answers the wrong question, nine times out of ten the tool description was too vague and it did not know which one to use.

Once it is stable, replace the Chat Trigger with (or add alongside it) the entry point you want:

  • Telegram Trigger — the fastest option, live as soon as you get a bot token. The approach is the same as the trigger section of the webhooks and third-party integration guide.
  • Webhook Trigger — for LINE, a website chat widget, or any service that can send an HTTP request.

Remember to flip the workflow to Active in the top right, or the trigger will not actually accept outside messages.

Cost and three common traps

Token costs are higher than ordinary chat. Every time the agent decides whether to use a tool, that is one round of model calls, and a single question may sit on top of three or five rounds. With a model at the level of gemini-2.5-flash or gpt-4o-mini, a few hundred conversations a month runs roughly NT$50 to NT$150. A flagship model is an order of magnitude more expensive, so get it working on a small model first.

Watch out for infinite loops. When a tool returns an unclear error message, the agent may retry the same tool over and over. The AI Agent node's Max Iterations defaults to 10; do not raise it, and state clearly in the System Message that "if a tool fails twice in a row, tell the user the lookup failed".

Do not let the agent touch irreversible operations. Looking up data and calculating numbers are safe to hand over. For things like deleting data, issuing refunds, or emailing every customer, have the tool go only as far as "create a pending-approval item" and leave the last step for a human to click.

n8n Agent or Dify Agent?

Both can build agents, and the split is actually clear. If the focus is connecting actions, choose n8n: it has hundreds of ready-made integrations, so after the agent looks something up it can go on to open a ticket, send a notification, or write to a database. If the focus is answering from a body of knowledge, choose Dify: it has a built-in RAG knowledge base, so uploading documents is enough to have the AI answer from them without assembling a retrieval pipeline yourself. Details are in the Dify Agent guide, and if you have never used Dify, start with Dify tutorial: building your first AI chatbot. The two are often used together: Dify answers, n8n acts.

Ready to build? Spin up a hosted n8n instance and you are in the editor in 60 seconds. If you would rather be guided through it, the n8n automation fundamentals course takes you from your first node to an AI Agent in production.

Want someone to build it for you?

If you would rather not assemble these workflows yourself, or the project is large enough that you want someone planning it with you, Roamer Tech (the company behind RoamerHost) takes on contract work for business process automation and AI agents:

Ready to get started with n8n?

60 seconds after you subscribe, n8n is installed for you — an isolated container with hard resource limits you never share, and HTTPS out of the box.

Subscribe to n8n

Billed yearly · no cancellation fee · cancel renewal anytime

Hi, I'm Roamer! Tap me anytime with a question and I'll help you out.

Roamer

Roamer - AI assistant

Online
Roamer

Ask me anything, anytime — I'll do my best to help!

Powered by RoamerHost AI