Build AI agents with n8n: practical tutorial for SMBs

With n8n you build AI agents without a developer. Step by step create a working agent that reads emails, looks them up in your CRM, and drafts a response.
Years ago you needed a developer to build an AI agent. Not anymore in 2026: with low-code tools like n8n you can build working agents in a day. This tutorial gives you a working example: an agent that reads incoming emails, retrieves customer context from HubSpot, and writes a draft response.
What is n8n?
n8n is an open-source workflow automation tool. Comparable to Zapier or Make, but:
- Self-hosted option (data stays in your own environment)
- More powerful logic and code steps
- Hundreds of built-in integrations
- AI nodes for OpenAI, Anthropic, etc.
Ideal for SMBs who want more control than Zapier, but can't maintain a developer team.
What we're going to build
An agent that:
- Trigger: new email in inbox info@company.nl
- Reads subject and content
- Searches sender in HubSpot CRM
- Retrieves open deals and recent notes
- Generates a draft response via OpenAI/Claude
- Creates a draft in Outlook/Gmail for human sending
Step 1: Set up n8n
Option A: n8n cloud
- Go to n8n.cloud
- Create an account (€20-€50/month for SMB use)
Option B: Self-hosted
- Install Docker
- `docker run -it --rm -p 5678:5678 n8nio/n8n`
- Access via http://localhost:5678
- For production: deploy to a server (DigitalOcean, Hetzner) with SSL
Step 2: Add email trigger
In n8n:
- Create new workflow
- Trigger: "Gmail Trigger" or "IMAP Email Trigger"
- Connect your email account (OAuth for Gmail, IMAP credentials for others)
- Filter: for example only emails to info@
Step 3: HubSpot lookup
- Add node: "HubSpot - Contact - Get Many"
- Authenticate with API key from HubSpot
- Filter by sender email address:
- Field: email
- Value: `{{ $json.from.value[0].address }}`
Step 4: Retrieve deals
- Add node: "HubSpot - Deal - Get Many"
- Filter by contact ID from previous step
- Select relevant properties: deal name, deal stage, amount
Step 5: AI node for draft
- Add node: "OpenAI" or "Anthropic Claude"
- Model: GPT-4o-mini or Claude Haiku (cost/speed)
- System prompt:
- User prompt:
Step 6: Save draft in inbox
- Add node: "Gmail - Draft - Create" (or Outlook variant)
- To: `{{ $('Email').item.json.from.value[0].address }}`
- Subject: "RE: {{ $('Email').item.json.subject }}"
- Body: `{{ $('OpenAI').item.json.message.content }}`
Step 7: Test and activate
- Run "Test workflow" on a test email
- Check if the draft looks correct
- Activate the workflow (toggle in top right)
What does this cost?
- n8n cloud: €20-€50/month
- OpenAI API: approximately €0.01-€0.05 per email (depending on model)
- HubSpot: existing license
Budget €60-€150/month for a setup that handles 500-2000 emails per month.
Next steps
First version working? Then improve it:
- Add knowledge base: a database with FAQ answers the agent can draw from
- Sentiment routing: angry emails go straight to humans, neutral ones via AI draft
- Multi-language: detect language and respond in the same language
- Categorization: automatically tag emails (sales, support, complaint)
- Auto-send: for high confidence and simple questions, send directly instead of draft
Three pitfalls
- Let AI send directly without review: always start with "create draft", only upgrade to auto-send once quality is proven
- No logging: log every step, otherwise debugging is impossible
- Forget privacy: add GDPR disclaimer to your privacy statement for automated processing
Conclusion
With n8n you build a working AI agent in a day. For SMBs, it's the golden middle ground between "building a simple Zapier" and "hiring a developer". Start with one agent, measure hard, and scale. The ROI is proven in dozens of SME implementations.




