Build a Custom AI Email Response System Using Claude API and n8n (No-Code Automation)
This article mentions a tool I use; the link at the end is an affiliate link.
Automating customer support emails with AI can save hours each week, but most businesses don't need expensive enterprise solutions. In this guide, I'll show you how to build a custom AI email response system that reads incoming emails, generates contextual replies using Claude API, and sends them for your review before sending.
What You'll Build
A workflow that:
- Monitors a specific email inbox (Gmail, Outlook, etc.)
- Sends new emails to Claude API with custom instructions
- Generates draft responses based on your business context
- Sends drafts to you for approval via Slack or email
- Tracks which emails have been processed
Prerequisites
- Gmail or Outlook account (free)
- Anthropic API account (pay-as-you-go, ~$0.01 per email)
- n8n account (free tier available)
- Basic understanding of JSON (helpful but not required)
Step 1: Set Up Your n8n Workspace
n8n is an open-source workflow automation tool. Create a free account at n8n.io or self-host using Docker.
Once logged in:
- Click "Create New Workflow"
- Name it "AI Email Response System"
- Save the empty workflow
Step 2: Configure Email Trigger
Add an Email Trigger (IMAP) node:
- Click the "+" button and search for "IMAP Email"
- Connect your Gmail account (you'll need to enable IMAP in Gmail settings)
- Set the trigger to check every 5 minutes
- Configure filters:
- Mailbox: "INBOX"
- Search criteria: "UNSEEN" (only unread emails)
- Mark as read: False (we'll do this later after processing)
Test the node to ensure it retrieves emails correctly.
Step 3: Create Your AI Prompt Template
Add a Set node to prepare data for Claude:
-
Extract these fields from the email trigger:
-
{{ $json.from }}→ sender email -
{{ $json.subject }}→ email subject -
{{ $json.text }}→ email body
-
Create a prompt template:
You are a helpful customer support assistant for [YOUR BUSINESS NAME].
Context about our business:
- We sell [PRODUCT/SERVICE]
- Our refund policy is [POLICY]
- Common issues include [LIST]
Customer email:
From: {{ $json.from }}
Subject: {{ $json.subject }}
Body: {{ $json.text }}
Generate a professional, friendly response that:
1. Addresses their specific question
2. Provides actionable next steps
3. Maintains our brand voice (professional but warm)
4. Is under 200 words
If you cannot answer with certainty, say so and suggest they contact us directly.
Store this in a variable called aiPrompt.
Step 4: Connect Claude API
Add an HTTP Request node:
- Method: POST
- URL:
https://api.anthropic.com/v1/messages - Authentication: Header Auth
- Name:
x-api-key - Value: Your Anthropic API key
- Name:
- Add header:
- Name:
anthropic-version - Value:
2023-06-01
- Name:
- Body (JSON):
{
"model": "claude-3-haiku-20240307",
"max_tokens": 500,
"messages": [
{
"role": "user",
"content": "{{ $json.aiPrompt }}"
}
]
}
Claude Haiku is the fastest and cheapest model, perfect for email responses. Test the node to verify it returns a response.
Step 5: Send Draft for Review
Add a Slack or Gmail node to send yourself the draft:
For Slack:
- Connect your Slack workspace
- Select a channel (e.g., #support-drafts)
- Message format:
📧 New Email Response Draft
From: {{ $node["Email Trigger"].json.from }}
Subject: {{ $node["Email Trigger"].json.subject }}
🤖 Suggested Response:
{{ $node["HTTP Request"].json.content[0].text }}
✅ Reply "approve" to send
❌ Reply "skip" to handle manually
Step 6: Add Conditional Logic
This is where you can enhance the workflow. Add an IF node to:
- Check for urgent keywords ("refund", "cancel", "urgent")
- Route urgent emails to a different channel
- Auto-approve simple responses (e.g., "What are your hours?")
Step 7: Optional Enhancement with Pre-Built Templates
When I was setting up email automation for multiple clients, I found that creating response templates from scratch was time-consuming. A tool that helped with streamlining the template creation process was Perpetual Income 365, which provided pre-built email frameworks that I adapted for AI prompts. It's completely optional, but it saved me a few hours of copywriting.
Step 8: Test End-to-End
- Send a test email to your monitored inbox
- Wait for the workflow to trigger (up to 5 minutes)
- Verify you receive the draft in Slack/email
- Check that the AI response is relevant and accurate
Monitoring and Costs
API Costs (approximate):
- Claude Haiku: ~$0.01 per email (100 emails = $1)
- n8n: Free tier covers ~5,000 executions/month
What to Monitor:
- Response quality (review first 50 emails closely)
- API errors (rate limits, authentication)
- False positives (emails that shouldn't be processed)
Next Steps
Once this basic system works:
- Add a knowledge base: Store FAQs in a Google Sheet and reference them in prompts
- Implement approval workflow: Use n8n's webhook node to create approve/reject buttons
- Track metrics: Log response times and approval rates to a database
- A/B test prompts: Try different prompt styles and measure customer satisfaction
Common Issues
Problem: AI responses are too generic
Solution: Add more specific business context to your prompt template. Include actual examples of good responses.
Problem: Workflow triggers multiple times for same email
Solution: Add a "Mark as Read" action in Gmail after processing.
Problem: API rate limits
Solution: Add a delay node between emails or upgrade your Anthropic tier.
Conclusion
This system processes emails for pennies each and can save 5-10 hours per week once tuned to your business. The key is starting simple, monitoring quality closely, and iterating based on real results.
The workflow I've described handles about 200 emails per week for my consulting business, with a 90% approval rate on AI-generated drafts. Your results will vary based on email complexity and how well you tune the prompts.
Start with one email category (e.g., pricing questions) before expanding to all support emails.
Affiliate disclosure: The link below is an affiliate link for a tool mentioned in this article.
The tool mentioned above is an affiliate link (disclosed at top): Perpetual Income 365
Top comments (0)