n8n tutorial - Lesson 25: Build Your First AI Agent in n8n: ReAct Pattern Explained
Hi everyone, in this n8n AI agent tutorial, you'll build your first working AI agent using the ReAct pattern — complete with multiple tools, memory, and an orchestrator that triggers sub-workflows. This is part of the n8n Workflow Automation Tutorial series, and it's the session where things shift from simple automation to agents that can reason and act on their own.
How to do:
Step 1 — Understand the ReAct Pattern and Agent Architecture
Before building anything, you need to know what makes an agent different from a regular n8n workflow — the ReAct loop is the core of it.- The ReAct pattern stands for Thought → Action → Observation, repeated in a loop until the agent reaches a final answer.
- An n8n AI agent has exactly three components:
- Agent node — the brain that decides what to do
- Tools — actions the agent can call (HTTP requests, spreadsheets, Telegram, etc.)
- Memory — stores conversation context across turns
- Know the difference between the three execution models:
- Regular workflow — fixed, hard-coded flow; great for simple, predictable tasks
- Chain — LLM calls in sequence, but no tool-calling or dynamic decisions
- Agent — decides which tool to call, in what order, and handles unexpected situations using natural language
Note — A regular Schedule + Google Sheets + Telegram workflow can send automated reports — but it only follows the exact path you hard-coded. An agent handles variable flows: if a step fails or a new condition appears, it reasons through it instead of breaking.
Step 2 — Create the Workflow and Add the Chat Trigger
Create a new workflow namedT7-B1-First-Agent and set up the entry point.
- In n8n, click New Workflow and name it
T7-B1-First-Agent. - Add a Chat Trigger node as the starting node — this lets you send messages to the agent directly from the n8n chat interface during testing.
- This workflow runs in Manual/Chat mode, so you do not need to set it to Active.
Step 3 — Add the AI Agent Node and Configure the Model
The AI Agent node is the core of this n8n AI agent tutorial — wire it to the Chat Trigger and set the language model.- Add an AI Agent node and connect it to the Chat Trigger output.
- Inside the Agent node, set the model to Claude Haiku 4.5 as the default — it's fast and cost-efficient for most tool-calling tasks.
- Upgrade to Claude Sonnet 4.6 on demand when a task requires stronger reasoning (complex multi-step orchestration, ambiguous instructions).
Tip — Starting with Haiku keeps costs low during development and testing. Only swap to Sonnet when you notice the agent making wrong tool choices or failing to chain steps correctly.
Step 4 — Attach Simple Memory
Memory lets the agent remember context across messages in the same conversation — without it, every message is treated as a fresh start.- Inside the AI Agent node, find the Memory sub-section and add a memory module.
- Select Simple Memory (this is the current name in newer n8n versions — older guides may call it "Window Buffer Memory", but the functionality is identical).
- To verify memory works, test this sequence:
- Send: "What is 500 USD in VND?"
- Then send: "Double that amount."
- The agent should resolve "that amount" as 500 USD from context and return the doubled result.
Note — The name change from "Window Buffer Memory" to "Simple Memory" is a known n8n UI update. If you follow an older n8n tutorial and can't find the node, look for Simple Memory in the memory selector instead.
Step 5 — Add Tool 1: Calculator
The Calculator tool is built into n8n and requires zero configuration — it's the easiest way to confirm your agent can call tools.- In the AI Agent node, go to the Tools section and click Add Tool.
- Select Calculator from the list — no credentials or additional settings needed.
- Test it by asking: "What is 1234 multiplied by 56?" — the agent should invoke the Calculator tool and return the correct answer.
Step 6 — Add Tool 2: HTTP Request for Exchange Rates
This tool gives the agent the ability to fetch live exchange rate data from a free public API — no authentication required.- Add a new tool and select HTTP Request.
- Set the tool name to
get_exchange_rate. - Configure the request:
- Method:
GET - URL:
https://api.exchangerate-api.com/v4/latest/USD - Authentication: None (this is a public, free endpoint)
- Method:
- Write a clear tool description so the agent knows when to use it — for example: "Get the latest USD exchange rates against all major currencies."
Tip — The tool description is not cosmetic — the agent reads it to decide whether to call this tool for a given user request. Write it as a one-sentence summary of what the tool returns and when it's relevant.
Step 7 — Add Tool 3: Google Sheets for Pending Blog Topics
This tool connects the agent to a real Google Sheet to retrieve blog topics that are queued for writing.- Add a new tool and select Google Sheets.
- Set the tool name to
get_pending_topics. - Configure it to read from the sheet named
T4-B5-Blog-Topics. - Set a filter so it only returns rows where the status column equals
pending. - Connect your existing Google Sheets credential — reuse whatever credential you set up in earlier sessions of this n8n workflow automation series.
Step 8 — Add Tool 4: Telegram for Sending Reports
This tool lets the agent send a summary message to a Telegram chat after completing a task — the key here is using$fromAI() correctly.
- Add a new tool and select Telegram, action: Send Message.
- Set the tool name to
send_telegram_report. - Configure the Chat ID field with your Telegram chat ID (static value — does not change).
- For the Text field, do NOT leave it blank — n8n marks this field as required and will throw a validation error. Set it to:
$fromAI('message', 'The message to send')
Note — The $fromAI('param', 'description') syntax tells n8n to let the agent decide what value to fill in at runtime. Use it for any field whose value depends on what the agent is doing — message text, topic names, row numbers, etc. Without it, n8n either errors out (required fields) or always sends the same static text.
Step 9 — Test Multi-Tool Calling and Memory Together
Run a real test that forces the agent to call more than one tool in a single response — this confirms the ReAct loop is working end-to-end.- Open the Chat panel and send: "What are the pending blog topics, and what is 500 USD in VND?"
- Watch the execution — the agent should call both
get_pending_topicsandget_exchange_ratein the same run, either in parallel or sequentially. - Follow up with: "Double the USD amount." — the agent should remember 500 USD from the previous message and return 1000 USD without you repeating it.
Tip — If the agent only calls one tool when you expected two, rephrase the request to make both needs explicit. The agent uses your prompt and the tool descriptions together to decide what to call — vague prompts produce vague tool choices.
Step 10 — Add the Orchestrator Tool: Call n8n Workflow Tool
This is where the agent becomes an orchestrator — it can trigger an entire sub-workflow as if it were just another tool.- Add a new tool and select Call n8n Workflow Tool (older guides may call this "Execute Sub-workflow" — the correct name in the Agent node's tool menu is Call n8n Workflow Tool).
- Set the tool name to
generate_blog_content. - Point it at the existing sub-workflow
T6-Content-Child-Blog(built in a previous session of this n8n tutorial series). - For any input fields the sub-workflow expects (topic, row number, etc.), set the values using
$fromAI('field_name', 'description')so the agent decides what to pass at runtime. - Write a tool description like: "Generate and publish a blog post for a given pending topic. Pass the topic name and row number from the Google Sheet."
Step 11 — Test the Full Orchestration Flow
Send a single natural language command and watch the agent read the sheet, trigger the content factory, publish to Blogger, and report back.- In the Chat panel, send something like: "Pick the first pending topic from the sheet and publish a blog post for it."
- The agent should execute this sequence automatically:
- Call
get_pending_topics→ read the Google Sheet - Call
generate_blog_content→ triggerT6-Content-Child-Blog - Sub-workflow generates content and posts to Blogger
- Call
send_telegram_report→ send you the Post ID and published link
- Call
- Check the final Telegram message — it should contain the full result: Post ID and a live link to the published post.
Production tip — The agent decides when to call the orchestrator tool and what data to pass — you don't hard-code that logic anywhere. This is the fundamental difference between agent-based automation and a regular n8n workflow: the flow isn't predetermined, it's reasoned at runtime.
Step 12 — Understand the Human-in-the-Loop Limitation
During this session, Telegram Send and Wait was tested as a way to pause the agent and wait for human approval before continuing.- Add a Telegram: Send and Wait node to your workflow and attempt to use it as an approval gate.
- You will find it does not work on
localhost:5678— Telegram's callback cannot reach a local n8n instance, so the workflow hangs indefinitely waiting for a response that never arrives. - This is a known localhost limitation:
- Human-in-the-Loop via Telegram requires n8n to have a public URL
- Solutions: use ngrok to expose localhost, or deploy n8n to a VPS
- For now, remove the Send and Wait node and note it for a future session when n8n is deployed with a public URL.
Note — This is a real production consideration, not just a tutorial limitation. Any n8n workflow that needs webhook callbacks — including Human-in-the-Loop approvals — must run on a publicly accessible URL. Local development environments will always block these flows.
Key Lessons from This Session
- ReAct = Thought → Action → Observation loop. The agent repeats this cycle until it has a final answer — it doesn't execute a fixed path like a regular workflow.
- An n8n AI agent has three components: Agent node, Tools, and Memory. Remove any one of these and you have a chain or a regular workflow, not an agent.
- Use
$fromAI('param', 'description')for any field the agent must decide at runtime. Required fields left blank will cause a validation error; static values defeat the purpose of using an agent. - Tool descriptions are instructions, not labels. The agent reads them to decide which tool to invoke — write them as clear, one-sentence functional summaries.
- "Call n8n Workflow Tool" is the correct node name for triggering sub-workflows from an agent. The older name "Execute Sub-workflow" no longer appears in the Agent tool menu.
- "Simple Memory" is the current name for what older guides call "Window Buffer Memory." The functionality is identical — only the UI label changed.
- Human-in-the-Loop via Telegram requires a public URL. Localhost cannot receive Telegram callbacks; use ngrok or a VPS deployment for this feature.
- An agent beats a regular workflow when the flow cannot be predetermined. For simple, fixed-path tasks, a regular n8n workflow automation is still the better choice.
Conclusion:
In this n8n AI agent tutorial, you built a full ReAct-pattern agent with four tools, working memory, and an orchestrator that triggers a sub-workflow from a single natural language command — going from understanding the theory to watching it publish a real blog post and report back on Telegram. The key shift is moving from hard-coded workflow logic to an agent that reasons, decides, and acts dynamically. In the next session of this n8n workflow automation tutorial series, you'll go further with advanced agent patterns: an internal chatbot that queries live data, a scheduled autonomous agent, or custom tools built with code.
If you have any questions, feel free to leave a comment below. Thank you!
Tags: n8n AI agent tutorial, n8n tutorial, n8n workflow automation, ReAct pattern n8n, n8n tools setup, AI agent orchestrator, n8n beginner guide, n8n automation tips
Maybe you are interested!
- Getting Started with n8n: Interface & Your First Manual Trigger
- n8n HTTP Request Node: Connect Any API Without Code
- Branching Workflows: IF, Switch & Merge Nodes in n8n
- n8n Expressions & Built-in Variables: The Complete Guide
- Comparing AI Models in n8n: Claude vs Gemini vs ChatGPT
- Connect Gmail to n8n: OAuth Setup & Reading Emails
- Build an AI Email Classifier with n8n
- Automated Email Digest to Telegram with n8n
- Google Sheets Automation with n8n: 4 Key Operations
- Auto-Generate Google Docs from Data with n8n
No Comment to " n8n tutorial - Lesson 25: Build Your First AI Agent in n8n: ReAct Pattern Explained "