Most AI tutorials show you how to build chatbots. This one shows you how to build agents that do things — call APIs, send messages, even make phone calls.
There's a meaningful difference between an AI that responds and an AI that acts. A responding AI tells you the weather. An acting AI checks your calendar, finds a free slot, and books the appointment. That gap is where n8n lives.
What "calling agents" actually means
When people say "calling agents" in the context of AI, they mean two related things: agents that call external tools/APIs as part of their reasoning, and agents that can literally initiate phone calls or messages.
Both are about the same core idea: the LLM doesn't just generate text — it triggers real-world actions.
Here are four concrete examples of what this looks like:
- Order lookup: User asks "Where's my package?" The agent calls your orders database API with the order ID, gets back a status, and tells the user.
- Slack alert: A monitoring agent detects an anomaly in your logs and fires a Slack message to your on-call channel without any human prompting.
- Twilio SMS: A customer service agent sends a confirmation text to a phone number after booking an appointment.
- Phone call initiation: Using Twilio's Programmable Voice, an agent can trigger an outbound call and even read a message using text-to-speech.
The LLM is the brain. The tools are the hands.
Why n8n
n8n has over a million users and is one of the few automation tools that treats AI agents as first-class citizens — not an afterthought bolted on to a workflow builder.
Compare it to the alternatives. Make (formerly Integromat) and Zapier are great for deterministic automations. They added AI modules recently, but the mental model is still step-by-step: trigger → action → action. The AI is just one node in a linear sequence.
n8n has an actual AI Agent node where the LLM is the orchestrator. You give it tools, a memory backend, and a system prompt. The agent decides which tools to call and in what order based on the user's message. That's a fundamentally different architecture.
n8n is also open-source and self-hostable via Docker, which matters if you're dealing with sensitive customer data or just want to avoid per-task pricing.
Workflows vs agents in n8n
Before building, you need to understand the two modes in n8n.
Workflows are deterministic. Node A runs, passes output to Node B, Node B passes to Node C. You control the sequence. Great for ETL pipelines, scheduled reports, anything where you know exactly what should happen.
AI Agents are non-deterministic. You give the LLM a goal and a set of tools. The LLM decides which tool to call, observes the result, and decides what to do next. The execution path varies based on the user's input. The same agent handling "what's the status of order 1234?" and "send a refund confirmation SMS to +1-555-0100" will take completely different execution paths.
Use workflows for predictable tasks. Use agents for tasks where the steps depend on the input.
Step-by-step: building an order status + SMS agent
Let's build a real agent. It'll take a customer message, look up an order status via HTTP, and optionally send an SMS confirmation through Twilio.
Step 1: Set up n8n
The fastest way to get started is the cloud version at cloud.n8n.io. Free tier gives you enough to build and test.
If you want to self-host:
docker run -it --rm --name n8n -p 5678:5678 n8nio/n8n
Then open http://localhost:5678 in your browser.
Step 2: Create a Chat Trigger node
Start a new workflow. Add a Chat Trigger node as your entry point. This opens a built-in chat interface for testing — you can type messages to your agent directly in n8n without building a frontend.
Set the trigger mode to "Manually" for development. Later you can swap it for a Webhook trigger when you connect a real chat UI.
Step 3: Add an AI Agent node
Connect an AI Agent node to the Chat Trigger. In the node settings:
- Agent type: Conversational Agent (this is the ReAct-style agent that uses tools)
- Model: Connect an OpenAI or Anthropic credential. GPT-4o works well here; Claude 3.5 Sonnet is slightly better at following tool-calling constraints
- System message: We'll fill this in Step 6
The AI Agent node is where the LLM lives. Everything else plugs into it.
Step 4: Add a Simple Memory node
The agent needs memory to hold conversation context across turns. Connect a Simple Memory node to the AI Agent's Memory input.
Simple Memory stores the conversation in n8n's session state — it's scoped to a single execution session. Good enough for testing and for stateless customer service bots where each conversation is self-contained.
For persistent memory across sessions (returning users, long-running assistants), you'll want Redis or Postgres memory, covered in the memory section below.
Step 5: Add your tools
This is where it gets interesting. Connect two tool nodes to the AI Agent's Tools input:
Tool 1: HTTP Request (order lookup)
Add an HTTP Request node configured for your orders API:
Method: GET
URL: https://api.yourcompany.com/orders/{{ $fromAI('order_id', 'The order ID to look up') }}
Authentication: Header Auth (your API key)
The $fromAI() syntax is how n8n passes parameters from the LLM to the tool. The second argument is the description the LLM sees — write it clearly because the LLM uses it to decide when and how to call the tool.
Name this tool check_order_status and give it a description: "Look up the status of an order by its order ID. Returns current status, estimated delivery date, and tracking number."
Tool 2: HTTP Request (Twilio SMS)
Add a second HTTP Request node:
Method: POST
URL: https://api.twilio.com/2010-04-01/Accounts/{{ $env.TWILIO_ACCOUNT_SID }}/Messages.json
Authentication: Basic Auth
Username: {{ $env.TWILIO_ACCOUNT_SID }}
Password: {{ $env.TWILIO_AUTH_TOKEN }}
Body Type: Form-Data
Body:
To: {{ $fromAI('to_number', 'The phone number to send the SMS to, in E.164 format') }}
From: +15550100
Body: {{ $fromAI('message_body', 'The text message to send') }}
Name this tool send_sms. Description: "Send an SMS message to a phone number. Use E.164 format for the number (e.g. +15550100)."
No special Twilio n8n integration needed. Twilio's REST API is just HTTP + Basic Auth with your Account SID and Auth Token as credentials. Store those in n8n's credential manager or environment variables.
Step 6: Write the system prompt
In the AI Agent node, paste this system prompt:
You are OrderBot, a customer service agent for [Company].
Your job: Look up order status and send SMS notifications when requested.
Available tools:
- check_order_status: Look up an order by order ID
- send_sms: Send a text message to a phone number
Rules:
- Always confirm the order ID before looking it up
- Before sending an SMS, confirm the phone number and message content with the user
- If an order isn't found, apologize and ask them to double-check the order ID
- Keep responses concise — 2-3 sentences
Tone: Friendly and helpful.
The rules section is doing real work here. "Confirm before sending an SMS" prevents the agent from firing off messages without user approval. "If an order isn't found, ask them to double-check" handles the error case gracefully without you writing any error-handling code.
Step 7: Test it
Click the Chat Trigger's "Open Chat" button. Type:
What's the status of order #1234?
If everything's wired up correctly, the agent will:
- Parse the order ID from your message
- Call
check_order_statuswithorder_id = "1234" - Get back the API response
- Format it into a natural language reply
Then try:
Can you send me an SMS confirmation to +15550199?
The agent should ask you to confirm the message content before sending. That's the system prompt doing its job.
The ReAct loop under the hood
What you just built runs on a pattern called ReAct: Reason → Act → Observe → Repeat.
- Reason: The LLM reads the user message and thinks about what to do next
- Act: It calls a tool with specific parameters
- Observe: It reads the tool's output
- Repeat: It reasons about what to do next based on the observation
For "What's the status of order 1234?", a single cycle is enough — one tool call, one observation, one response. For more complex tasks like "Check the order status, and if it's delayed, send the customer an SMS apology," you get multiple cycles chained together.
The agent runs this loop until it has enough information to answer or decides it can't proceed. If you want to go deeper on ReAct, the ReAct prompting lesson covers the underlying mechanics.
The 4 memory options in n8n agents
Memory determines how much context the agent carries between turns.
Simple Memory (default): Stored in n8n's session state. Wiped when the session ends. Use this for single-session conversations where history doesn't need to persist.
Redis Memory: Persistent across sessions. Requires a Redis instance. Good for returning users — the agent remembers previous conversations. Connect via n8n's Redis credential.
Postgres/MySQL Memory: Persistent and queryable. Stores conversation history in a relational database. Use this if you want to analyze conversation logs or run queries like "show me all conversations where the agent failed to find an order."
Window Buffer Memory: Keeps only the last N messages in context, regardless of backend. Critical for long conversations that would otherwise overflow the model's context window. Set N conservatively — 10 messages is usually enough for customer service use cases.
For production deployments, Redis Memory + Window Buffer (last 10) is a solid combination. You get persistence without blowing up your context window on long conversations.
3 common failure modes and how to fix them
1. Infinite tool loops
The agent calls check_order_status five times for the same order ID. This happens when the tool returns an unexpected response format and the agent keeps retrying, hoping for something different.
Fix: set Max Iterations in the AI Agent node to 5-8. Then add this to your system prompt:
If you've called the same tool twice with the same parameters and gotten the same result,
stop and tell the user you're having trouble retrieving that information.
Both the hard limit and the soft instruction work together. The hard limit prevents runaway costs. The soft instruction gives the agent a graceful exit.
2. Missing tool definitions
The user asks "Can you refund my order?" and the agent confidently says "Sure!" — then fails because there's no refund tool. The LLM hallucinated a capability it doesn't have.
Fix: explicitly list what the agent cannot do in the system prompt:
You cannot: process refunds, modify orders, access payment information.
If asked to do any of these, tell the user to contact support at support@company.com.
Negative constraints work better than hoping the agent stays in scope.
3. Context window overflow
In long support conversations, the growing message history eventually exceeds the model's context window and the agent starts forgetting earlier parts of the conversation or failing with token limit errors.
Fix: switch from Simple Memory to Window Buffer Memory, capped at 10 messages. The agent only sees the last 10 exchanges, which is usually enough context for customer service while keeping token usage predictable.
For use cases where full history matters (legal, compliance, detailed project work), use Postgres Memory so the full history is persisted to the database even if the agent only loads the last N messages into context.
What to build next
When I first connected Twilio to n8n, the thing that surprised me wasn't that it worked — it was how fast it was to iterate. Changing the system prompt, adding a tool, swapping the LLM — it's all config, not code. You can rebuild this agent in under an hour.
From here, the natural next step is understanding the underlying concepts that make this work. The Agents track covers everything from agent components and function calling to multi-agent systems and evaluation frameworks. Start with what is an AI agent if you're newer to the space, or jump to function calling if you want to go deeper on the tool-calling mechanics.
For ready-to-use system prompts for n8n agents across different use cases (support bots, research agents, data pipeline agents), check out our n8n AI agent system prompt templates post.
The agent you built today handles two tools. The same architecture scales to ten, twenty, fifty. Add a database query tool, a calendar API, a CRM integration. The LLM figures out the orchestration. You just define the tools and the constraints.



