Blog · · 5 min read
How to build your first AI agent in n8n (beginner's guide)
What an AI agent is and how to build your first one in n8n step by step: the chat trigger, the model, memory, the tools that let it take action and the instructions that stop it making things up.

You've probably heard about "AI agents", but plenty of people aren't sure how they differ from a regular chatbot. The idea is simple: a chatbot only answers; an agent can also do things. It checks your calendar, writes a line in a spreadsheet or looks something up, and it decides on its own when each of those is needed.
In this guide we build your first agent in n8n, an automation tool you can run for free on your own server. You don't need to know how to code: everything is done by connecting blocks on screen.
The four parts of an agent
Before starting, it helps to understand what an agent in n8n is made of. Everything revolves around the AI Agent node, and you plug these parts into it:
- The trigger: what starts the agent. Here we'll use a chat, but it could be a WhatsApp or Telegram message, an email or a form.
- The AI model (Chat Model): the "brain" that understands and writes, for example one from OpenAI.
- Memory: so it remembers what was said earlier in the conversation.
- Tools: the actions you allow it to take. Without tools it's a chatbot; with them, it's an agent.
What you need
- n8n up and running, in the cloud or on your own machine (if you don't have it yet, see how to install n8n for free with Docker).
- An API key for an AI model, for example from OpenAI.
- Optional: a Google account, if you want to give it tools such as Google Sheets or Google Calendar.
Step 1: the chat trigger
Create a new workflow and add the Chat Trigger node (it shows up as "When chat message received"). It's the easiest way to start, because n8n gives you a chat window to test with, without connecting anything else.
Step 2: the AI Agent node and the model
Connect an AI Agent node to the trigger. Underneath it you'll see several slots for plugging in parts:
- Under Chat Model, add OpenAI Chat Model (or another provider), create the credential with your API key and pick a model. To start with, a small, cheap one is usually enough.
- Under Memory, add Simple Memory. With the chat trigger there's nothing else to set up: each conversation gets its own memory.
That already gives you a working chatbot. Click the chat button at the bottom of the editor and send it a message to check.
Step 3: give it tools
This is where it gets interesting. In the agent's Tool slot you can plug in one or more tools. Some easy ones to start with:
- Calculator: so it does maths without mistakes. AI models slip up more easily when they calculate in their head.
- Google Sheets: so it reads or adds rows in a sheet, for example a price list or the contacts people leave.
- Google Calendar: so it checks free slots or creates an appointment.
- HTTP Request: so it can query any service that has an API.
Every tool has a description. Write it carefully and in plain language, because it's what the agent reads to decide when to use it. For example: "Use this tool to look up service prices. It returns one row per service."
In many tool fields you can let the agent fill in the value itself. n8n shows this with a button next to the field (or with the $fromAI() expression): so if someone asks how much a haircut costs, the agent looks up exactly that service.
Step 4: the instructions
In the agent's options, add System Message and explain who it is, what it can do and what it can't. An example for a business:
You are the assistant for [BUSINESS NAME].
Reply in the user's language, in 2-4 sentences, in a friendly tone.
For prices, always use the "Prices" tool; never guess them.
For appointments, first check the free slots in the calendar
and confirm the date and time with the person before booking.
If you don't know something, say so and offer to have the team get in touch.
Never make up prices, timelines or availability.
The two most important rules are the last ones: telling it what to do when it doesn't know something, and forbidding it from making things up. If you want to fine-tune them, we go into detail in the prompt for an AI customer service agent.
Step 5: test it like a customer would
Open the chat and ask it real questions, including the awkward ones: something it doesn't know, an odd request or an off-topic question. In the AI Agent node's panel you can see which tools it used for each reply, which helps you understand why it answered the way it did.
Once you're happy, save and activate the workflow. If you want customers to use it, swap the trigger for the channel you prefer: your website, WhatsApp or Telegram.
Common mistakes
- It doesn't use the tool. It's almost always the description: make it clearer and mention the tool by name in the instructions.
- It makes up data. Stress in the instructions that it should only use what the tools give it, and give it a way out when it doesn't know something.
- It doesn't remember the conversation. Check that the memory is connected to the agent. If the trigger isn't n8n's chat, you'll need to tell it which ID separates each conversation.
- Too many tools at once. Start with one or two and add more once they work. The more it has, the easier it is to pick the wrong one.
- Uncontrolled spending. Every message uses a little API credit. Set a spending limit in your AI provider account.
Shortcut: agents that are already built
If you'd rather start with something that already works, the AgentKiosk pack includes agents ready to import into n8n, with their instructions written and rules to avoid making things up. And if you'd like to try for free, download the WhatsApp agent and take a look at 7 AI automations for small businesses.


