Put a Simple AI Agent Inside a Workflow
In a workflow, you choose the path. With an agent, the AI chooses which tools to call and in what order. The safest way to use an agent is as one step inside a workflow, with a small set of tools and firm limits. This lesson adds that step to the project.
To learn how agents think and act, take How AI Agents Work first. This lesson is about building one.
What You'll Learn
- When an agent is better than fixed steps
- How to build an agent step in n8n
- How to limit what the agent can do
- How to require approval for one specific tool
Use an Agent Only When the Path Changes
If you can draw every path in advance, you do not need an agent.
| Criteria | Fixed workflow | Agent step |
|---|---|---|
| Best when | The steps are the same each time | The next step depends on what it finds |
| Example | Classify, look up, draft | Investigate why an order is late |
| Cost | Predictable | Varies, with several model calls per run |
| Testing | Check each step | Check many runs, because paths differ |
Fixed workflow
- Best when
- The steps are the same each time
- Example
- Classify, look up, draft
- Cost
- Predictable
- Testing
- Check each step
Agent step
- Best when
- The next step depends on what it finds
- Example
- Investigate why an order is late
- Cost
- Varies, with several model calls per run
- Testing
- Check many runs, because paths differ
In our project, most messages follow fixed steps. Shipping questions are different. The answer may need the order record, then the carrier status, then the store's delay policy. Only some of those are needed each time. So shipping messages go to an agent, and everything else stays on fixed paths.
- Switch: shippingOnly this path uses the agent
- AI AgentCalls a few read-only tools
- Fields outFindings and a draft reply
- Approval stepA person checks before sending
Build the Agent in n8n
- Add the AI Agent node on the shipping path.
- Connect a chat model.
- Connect tools. A tool can be an app node, an HTTP request, or a sub-workflow. Your "Find customer" sub-workflow from the first lesson can become a tool.
- Write a clear description for each tool. The agent uses these descriptions to choose.
- Turn on Require Specific Output Format and add a Structured Output Parser, so the agent's final answer has fields.
Here is a good set of tools for this project:
| Tool | Description for the agent | Type |
|---|---|---|
| get_order | Get order status and dates by order number | Read |
| get_carrier_status | Get the latest tracking event by tracking number | Read |
| get_delay_policy | Get the store's rules for late orders | Read |
All three tools only read data. The agent cannot change anything. This is the most useful limit you can set.
Write the System Prompt
The system prompt should state the job, the tools, the limits and when to stop. You can test the wording here. The playground does not call real tools, so the sample tool results are in the prompt.
Set Firm Limits
Agents can loop, call the wrong tool, or use many tokens. Add these controls:
- Max Iterations. This option on the AI Agent node limits how many times the agent can go round its loop. Keep it low, then raise it only if real tasks need more.
- Few tools. Three or four focused tools work better than twenty.
- Read-only first. Add tools that change data only when you have tested the agent on real cases.
- Error handling. Use the same retry and On Error settings from the errors lesson, and add a path for when the agent reaches its limit.
To see what the agent did, turn on Return Intermediate Steps. You can also view each tool call in the execution log.
Add Approval for One Tool
Sometimes you want the agent to do one risky thing, such as creating a replacement order. n8n can require approval for a single tool. On the connection between the AI Agent and the tool, click + and choose Add human review step. Then pick a review channel, such as Slack, Gmail or Telegram.
When the agent tries to use that tool, the workflow pauses. If the person denies it, the action is canceled and the agent is told. Mention this in your system prompt, so the agent knows which tools need approval and what to do after a denial. This feature arrived in n8n 2.6, so update older installs.
In Make and Zapier
Make has its own AI agents. Their tools can be modules, MCP servers or Make scenarios, so your existing scenarios can become tools. Zapier has merged Zapier Agents into the AI by Zapier step, which can use tools and can require approval before it runs one. The same limits apply on every platform: few tools, read-only first, a person before risky actions.
Check It Before You Trust It
Run the agent on at least 20 real past cases. For each run, check whether it used sensible tools, whether the answer is right, and how many model calls it needed. If most cases follow the same path, replace the agent with fixed steps. They are cheaper and easier to test.
Key Takeaways
- Use an agent only when the next step depends on what it finds.
- Keep the agent as one step inside a fixed workflow.
- Start with read-only tools and write clear tool descriptions.
- Set Max Iterations and a path for when the agent reaches its limit.
- In n8n, use a human review step on any tool that changes something.
Quiz
Up next ยท Lesson 7 of 7
Costs, Monitoring and Launch Checklist
3 min read
6 of 7 lessons done

