DEV Community

Paarthurnax
Paarthurnax

Posted on

How to Automate Email with an AI Agent (Without Losing Control of Your Inbox)

How to Automate Email with an AI Agent (Without Losing Control of Your Inbox)

A practical guide to email AI automation that's actually useful — not just another chatbot that reads your mail.


I get around 80-120 emails a day. Not spam — actual messages that need reading, categorising, sometimes responding to. For a while I treated this as just a fact of work life. Then I spent an afternoon figuring out how to automate email with an AI agent, and I haven't manually sorted my inbox since.

This post covers the specific setup I use, the problems it solves, and the parts that don't work as well as the blog posts promised.


The Problem with Most "AI Email" Solutions

Before I get into the how, let me address what's out there. Most AI email tools fall into two categories:

  1. SaaS tools (Superhuman, SaneBox, etc.) — they work, but they cost $15-30/month, they see all your email, and they don't integrate with anything else you do.

  2. GPT plugins and browser extensions — write one email with AI assistance. Not automation. Just a faster way to type.

Neither of these is what I mean when I say automate email with an AI agent. I mean: a system that runs automatically, without you being in the loop, and handles the boring 70% of email so you only touch what actually matters.


The Stack

Here's what I use:

  • Ollama — local AI model server (Llama 3.1 8B for most tasks)
  • n8n — the automation layer that connects everything
  • Gmail — where the email lives (works with Outlook too via different n8n nodes)
  • Notion — where processed email summaries and action items land

All of this runs on a Mac Mini M2 sitting in my home office. It runs 24/7 and costs me nothing per query.


Workflow 1: Morning Email Digest

Every morning at 7:45am, this workflow fires before I open my email client:

  1. n8n Schedule trigger → runs at 7:45am
  2. Gmail node → fetch emails from the past 18 hours, filter to inbox only
  3. Code node → format email data into a readable string
  4. Ollama node → summarise and prioritise
  5. Telegram bot → send me the digest on my phone

The Ollama prompt I use:

You are an email triage assistant. I'm a solopreneur who needs to quickly understand what requires my attention today.

Here are the emails received in the last 18 hours:
{{ $json.emails }}

Please:
1. Flag any emails that need a same-day response
2. Summarise each email in one line
3. List any specific action items mentioned
4. Note anything that looks like a payment, contract, or legal document

Keep it brief. No pleasantries.
Enter fullscreen mode Exit fullscreen mode

This lands on my phone as a Telegram message before I've had coffee. I know what needs attention before I open a single email.


Workflow 2: Auto-Label and Archive

This one runs continuously (triggered by new email). It's the high-volume workflow:

  1. Gmail trigger → fires on each new incoming email
  2. Ollama node → classify the email into a category
  3. Gmail node → apply label + optionally archive if "Low/FYI"

The classification prompt is intentionally simple:

Classify this email into exactly one category. Reply with only the category name, nothing else.

Categories:
- URGENT (needs same-day response, time-sensitive)
- CLIENT (from a current or potential client)
- NEWSLETTER (marketing, digest, update I subscribed to)
- RECEIPT (payment confirmation, invoice, order)
- ADMIN (internal, operational, not client-facing)
- SPAM (unwanted)

Email:
From: {{ $json.from }}
Subject: {{ $json.subject }}
Body preview: {{ $json.snippet }}
Enter fullscreen mode Exit fullscreen mode

By returning just the category name, I can use n8n's conditional branching to route each email without parsing a paragraph of AI reasoning.


Workflow 3: Draft Reply Generation

This is the one that felt like science fiction the first time it worked.

When a client email arrives (detected by the labelling workflow above), a second workflow fires that:

  1. Reads the full email
  2. Checks my Notion "About my business" document for context
  3. Sends everything to Ollama with a drafting prompt
  4. Creates a Gmail draft (not sent — I review and send manually)

I review the draft, usually make minor edits, and send. It takes me 30-60 seconds instead of 5-10 minutes. For standard client questions, the drafts are 70-80% ready to send as-is.


What Doesn't Work

I want to be honest here because most posts about how to automate email with an AI agent skip this part.

Thread context is tricky. Ollama sees individual emails, not full threads. If a client is following up on a conversation from last week, the draft might miss context. I've added a step that fetches the last 3 messages in a thread, but it's imperfect.

Tone calibration takes iteration. The first week of draft generation, about 40% needed significant rewrites because the tone was too formal. I added my own example emails to the prompt as style references and it improved significantly, but it still requires periodic prompt tuning.

Latency on first email of the day. Ollama cold-starts the model on first use, which adds ~15-20 seconds. Not a problem for batch processing, but the real-time labelling workflow occasionally lags on the first email after a quiet period.

None of these are dealbreakers — they're just the honest engineering tradeoffs.


The Time Math

I tracked this for three weeks. Before automation: email consumed about 45 minutes of focused time daily. After:

  • Morning digest review: 5 minutes
  • Reviewing AI-drafted replies: 10-15 minutes
  • Anything the AI missed or flagged for attention: 10 minutes

That's roughly 25-30 minutes saved per day, or about 2.5 hours per week. In a year, that's 130 hours — over three full work weeks. Not a small number.


Key Takeaways

  • To automate email with an AI agent, you need three things: a local model (Ollama), an automation layer (n8n), and your email provider (Gmail/Outlook)
  • Start with triage, not replies — getting a daily digest up and running is fast and immediately useful
  • Simple classification prompts beat complex ones — returning a single category label is more reliable than parsing long AI responses
  • Draft generation works best for structured, common requests — unstructured or emotionally nuanced emails still need human attention
  • Thread context is the main unsolved problem — plan for it in your prompt design
  • Local AI means no per-query cost and no email data leaving your machine

If you want the complete setup — including all my prompt templates and n8n workflow exports — I documented the full system in a guide here: The Home AI Agent Blueprint.

Top comments (1)

Collapse
 
c_nguynnh_56de361f0 profile image
Đức Nguyễn Đình

Quick personal review of AhaChat after trying it
I recently tried AhaChat to set up a chatbot for a small Facebook page I manage, so I thought I’d share my experience.
I don’t have any coding background, so ease of use was important for me. The drag-and-drop interface was pretty straightforward, and creating simple automated reply flows wasn’t too complicated. I mainly used it to handle repetitive questions like pricing, shipping fees, and business hours, which saved me a decent amount of time.
I also tested a basic flow to collect customer info (name + phone number). It worked fine, and everything is set up with simple “if–then” logic rather than actual coding.
It’s not an advanced AI that understands everything automatically — it’s more of a rule-based chatbot where you design the conversation flow yourself. But for basic automation and reducing manual replies, it does the job.
Overall thoughts:
Good for small businesses or beginners
Easy to set up
No technical skills required
I’m not affiliated with them — just sharing in case someone is looking into chatbot tools for simple automation.
Curious if anyone else here has tried it or similar platforms — what was your experience?