Hey everyone! Sharing another free workflow from my collection — this one automatically classifies incoming emails, filters out spam, and drafts context-aware replies using Ollama. Runs entirely on your own machine, no API keys or cloud services needed.
What It Does
Every 5 minutes → Check for unread emails (IMAP)
↓
Ollama classifies each email (inquiry / support / spam / newsletter / personal)
↓
Spam gets filtered out automatically
↓
Ollama drafts a professional reply based on the email content
↓
Draft is prepared for your review before sending
```
**Key features:**
- **Smart classification** — AI categorizes emails into 5 types so you can prioritize
- **Spam filtering** — Automatically removes junk before it wastes your time
- **Context-aware replies** — Drafts actually reference what the sender wrote about
- **Human-in-the-loop** — Drafts are prepared for review, never auto-sent (you stay in control)
- **Runs every 5 minutes** — Set it and forget it
## Requirements
- n8n (self-hosted, v1.0+)
- Ollama running on localhost:11434
- Any model — `llama3:8b` recommended
- An email account with IMAP access (Gmail, Outlook, Fastmail, etc.)
## The Workflow
The workflow uses 6 nodes:
1. **Schedule Trigger** — Checks every 5 minutes
2. **IMAP Read** — Fetches unread emails
3. **Ollama Classification** — Classifies each email by type (inquiry/support/spam/newsletter/personal)
4. **Spam Filter** — Removes spam-classified emails from the pipeline
5. **Ollama Draft Reply** — Generates a professional reply based on the email content and classification
6. **Prepare Draft** — Formats the draft for your review
## Getting Started
1. Install Ollama: `curl -fsSL https://ollama.ai/install.sh | sh`
2. Pull a model: `ollama pull llama3:8b`
3. Import the workflow JSON into n8n (grab it from [my GitHub repo](https://github.com/bonskari/n8n-ollama-email-responder))
4. Configure your IMAP credentials in n8n
5. Activate the workflow — done!
## Tips
- For Gmail, you'll need an [App Password](https://support.google.com/accounts/answer/185833) (not your regular password)
- Larger models (13B+) give better classification accuracy, but 8B works fine for most emails
- You can customize the classification categories by editing the Ollama prompt in node 3
- Add a "Send Email" node after the draft step if you want to auto-send certain categories (like newsletter unsubscribes)
## Free on GitHub
Full workflow JSON + detailed README with setup instructions:
:point_right: **[github.com/bonskari/n8n-ollama-email-responder](https://github.com/bonskari/n8n-ollama-email-responder)**
---
This is one of 11 workflows I've built for n8n + Ollama. The others cover blog writing, social media content, lead scoring, document summarization, competitor monitoring, meeting notes, and more. I've packaged them all together as a [Self-Hosted AI Workflow Pack](https://bonskari.github.io/n8n-ai-workflows/) if you're interested in the full set.
Would love to hear if anyone tries this out — happy to help with setup questions!