AI Agents & Multi-Agent Systems
Agents are the most hyped piece of the current n8n conversation and the most commonly misused. This layer draws a hard line between "workflow with an AI step in it" and "agent," then builds a real multi-agent personal assistant so the distinction stops being theoretical.
What an agent actually is
Three tiers, in order of how much autonomy you're handing over. A raw LLM call is input in, output out — you still do everything else by hand. A workflow with AI in it (everything built so far in this guide) automates the retrieval and delivery around that call, but the sequence of steps is fixed by you at build time. An agent is given a goal, a set of tools, and a memory, and decides for itself, at run time, which tools to call and in what order — closer to hiring an employee than to writing a script.
When to use one (and when not to)
Autonomy is a trade-off, not a strict upgrade: a model deciding the order of operations can also decide it wrong. Reserve agents for genuine ambiguity, and use a deterministic workflow (IF/Switch) everywhere the logic is actually fixed.
Skip the agent
Classifying a file as PDF vs. image by its MIME type — a plain IF gets this right 100% of the time; an agent introduces a failure mode that didn't need to exist. Same for anything you'd otherwise run unattended on a schedule with no one "in the loop" to correct it.
Reach for an agent
Tasks with a genuinely variable number of steps in a genuinely variable order — "find this contact, then check the calendar for conflicts, then create the event, then confirm by email" — where hard-coding every possible sequence would mean building dozens of near-duplicate workflows.
Anatomy: brain, memory, tools
Every n8n AI Agent node has exactly three attachment points:
- Chat Model (the brain) — the LLM doing the reasoning. Any provider works; OpenAI, Anthropic, and Google are all one dropdown away.
- Memory — usually Simple Memory, keyed on a session ID so the agent remembers earlier turns in the same conversation. Get the session ID wrong (or leave it on the default, which only matches n8n's own built-in chat trigger) and the agent forgets everything the instant you switch to Telegram, a webhook, or any other entry point.
- Tools — anything the agent is allowed to actually do: send an email, look up a contact, create a calendar event, call a sub-agent, call a sub-workflow.
Build: a basic conversational agent
- Trigger → On Chat Message (n8n's built-in test chat).
- Add AI Agent, attach a Chat Model, and a Simple Memory (session ID defaults correctly here since you're using the matching chat trigger).
- Add a tool — e.g. Gmail → Send a message — and for every field, click the star icon to let the agent decide the value itself rather than hard-coding it.
- Chat: "Can you email Jonno confirming coffee at 2pm tomorrow?" Watch the agent ask a clarifying question before acting if it's missing information (an email address, a time zone) — this self-correcting behavior is the actual point of an agent.
Writing a system prompt that works
A vague system prompt is the #1 cause of agents calling tools in the wrong order or hallucinating information they should have looked up. Structure every agent prompt with the same six sections:
# Role
You are a personal assistant for {{name}}, helping manage email and calendar.
# Goal
Complete the user's request accurately, asking only when truly ambiguous.
# Tools
1. Send Email — call when the user wants to send an email.
2. Find Contact — call to look up someone's email before sending to them.
3. Find Calendar Event — call before updating or deleting an event.
4. Create Calendar Event — call to book a new event.
# Rules
1. Always find a contact's email before sending — never guess it.
2. Always search for an existing event before updating or deleting one.
3. Always check for conflicts before creating a new event.
4. Never send two emails for one request; if replying, reply — don't also send new.
# Notes
Today's date is {{ $now.format('yyyy-MM-dd') }}. Resolve "tomorrow," "next
Tuesday," etc. relative to this date, not your training data.
# Output
Respond in plain, friendly text — no markdown, no headers.
{{ $now }} into every agent prompt that reasons about time.
Multi-agent pattern 1: sub-agent tools
A single agent juggling ten tools and a sprawling rulebook degrades in reliability. Instead, build one manager agent whose only tools are other agents — a "Gmail agent" and a "Calendar agent," each with its own focused prompt and only the tools it actually needs. The manager's job is purely to route: "does this belong to Gmail or Calendar?" Each employee agent then reasons independently about its own steps. Both the manager and every sub-agent's memory must share the same session ID, or the sub-agent won't have any context from earlier in the conversation.
Multi-agent pattern 2: sub-workflow tools
The sub-agent pattern above is still limited to whatever actions the AI Agent node's tool picker supports. A Call n8n Workflow tool instead delegates to a fully separate n8n workflow — which can be deterministic (no AI at all), or contain its own nested agent, and has access to every one of n8n's thousand-plus regular actions, not just the trimmed AI-tool subset.
- Build the target workflow with trigger → When Executed by Another Workflow, and define its expected input as JSON (e.g.
{ "id": "", "prompt": "" }). - Back in the manager agent, add tool → Call n8n Workflow, select that workflow, map
idto the shared session ID, and let AI define thepromptfield. - Pin realistic sample input on the sub-workflow's trigger while building it in isolation — you don't need the manager agent running to iterate on it.
Build: a personal assistant
Combine both patterns into one assistant reachable over Telegram, capable of handling both voice notes and text:
- Trigger → Telegram → On Message Received. Add an IF checking whether the message contains a
voiceobject. - Voice branch: Telegram → Get a File → OpenAI → Transcribe a Recording. Text branch: an Edit Fields node that just copies the text into a shared
textkey. - Merge both branches so downstream nodes always find the same
textkey regardless of input type. - Feed
textinto the manager AI Agent as its prompt, with memory keyed on the Telegramchat.id. - Attach the Gmail sub-agent (Send, Find, Reply, Label tools + a Google Contacts lookup tool) and the Calendar sub-agent (built as a sub-workflow: Create, Find, Update, Delete Google Calendar event tools).
- Add a final Telegram → Send Message back to the same chat with the agent's output — unlike the built-in chat trigger, Telegram does not auto-reply for you.
Embedding a chat widget on a website
The same On Chat Message trigger used for testing can be made public and embedded directly on a client's site: in the trigger's settings, toggle Make Chat Publicly Available and set mode to Embedded. n8n hands you a script snippet (installed via npm's public CDN, no build step) that drops a working chat bubble into any HTML page — including a static site hosted on Vercel like this one.
Variations worth selling
- Add a "Documents" sub-agent that reuses the pattern from Layer 04 as a callable tool.
- Package the personal assistant as a productized "AI executive assistant" retainer — see pricing guidance in Layer 10.
- Ground the assistant in a client's own knowledge base with a retrieval tool — covered next in Layer 07.
Sources
| Source | Used for |
|---|---|
| Jono Catliff (Automatable), "n8n 8 Hour Masterclass — Build & Sell AI Agents (Automate Anything)" | Primary source for this layer's concepts & build |
| n8n docs, "What's an agent in AI?" | Workflow-vs-agent distinction |
| n8n docs, AI Agent node | Brain/memory/tools anatomy |
| n8n docs, Simple Memory node | Session-ID-based conversation memory |
| Telegram, Bot API | Voice/text message routing for the assistant build |