Workflow · Productivity
Build an AI Email Assistant
An assistant that drafts replies in your voice, classifies incoming mail, and surfaces only what needs you.
Problem
A 200-email morning eats 90 minutes before real work starts. Most of those emails don't need you — they need a triage and a fast acknowledgment. Manual triage is the bottleneck.
Final output
Background process that runs locally on a 5-minute timer. Outputs: actual Gmail drafts on emails that need a reply, plus a daily 8am digest of urgents + FYIs + archives done. Send is always manual.
Architecture
Cron (every 5 min)
→ Pull new unread from Gmail
→ For each: classify (urgent/reply/fyi/archive) via LLM
→ If reply_needed: draft reply in your voice using sent-email examples
→ Save as Gmail Draft (uses Gmail's native UX)
→ Daily 8am: digest email with links to drafts + summaryStep-by-step
- 01
Auth and Gmail API setup
OAuth with scopes gmail.readonly, gmail.modify, gmail.compose. Save tokens locally.
- 02
Build the voice corpus
Pull ~50–100 of your sent emails. Cluster by recipient type (boss/customer/friend/vendor) and length. Save as few-shot examples.
- 03
Classifier
Cheap LLM call per incoming email. Returns bucket + one-line summary. Cache by message ID.
- 04
Drafter
For reply_needed emails: strong LLM call with your voice examples. Outputs plain text. Save as actual Gmail draft.
- 05
Daily digest
8am cron: assemble urgents + summaries + drafts-ready into one email. Send to yourself.
What you'll build
A daemon that runs in the background, watches your inbox, and:
- Triages every email into:
urgent / reply needed / fyi / archive. - Drafts replies for the "reply needed" bucket in your voice.
- Surfaces the daily list each morning, drafts pre-loaded for one-click send.
It's not a replacement for you. It's a first-pass filter that turns a 200-email morning into a 20-decision morning.
Architecture
Cron (every 5 min)
→ Pull new unread from Gmail
→ For each: classify + draft (LLM)
→ Save draft as actual Gmail Draft (Gmail's UX is fine)
→ Daily digest at 8am: link to drafts, summary of FYIs, archives done
Privacy and safety
- Run locally. Don't send your inbox through random APIs.
- Don't auto-send. The drafts wait for you — this is non-negotiable for a real inbox.
- Cap blast radius. A bug that mass-replies is recoverable, but ugly. Always require a human send.
Extensions
- Calendar integration — proposes meeting times when relevant.
- CRM sync — auto-attach replies to the right deal in Pipedrive / HubSpot.
- Follow-up tracker — flag threads with no reply after N days.
Prompt examples
Copy any of these, replace the placeholders, run.
Triage classifier
You are an email triage assistant for {{user_name}}.
Classify this email into one bucket:
- urgent: action needed today
- reply_needed: requires a response within a few days
- fyi: informational, no action
- archive: newsletter, notification, marketing, automated
Also return a one-line summary (under 80 chars).
Output JSON: { "bucket": "...", "summary": "..." }
From: {{sender}}
Subject: {{subject}}
Body: {{body}}Draft a reply in your voice
Draft a reply in {{user_name}}'s voice.
Voice examples:
{{few_shot_sent_emails}}
Constraints:
- Match length of similar replies above (usually 2–5 sentences)
- Plain text, no signature (Gmail adds it)
- If the email requires info you don't have, leave a [BRACKET] placeholder
- Do NOT promise anything specific without a placeholder
- Never use "Hope this helps!" or similar AI-tells
Incoming email:
"""
{{email_body}}
"""Cost estimate
| Line item | Approx. cost |
|---|---|
| Triage (100 emails, mini/Haiku) | $0.30 |
| Draft (30 replies, Sonnet/GPT) | $0.90 |
| Daily digest generation | $0.05 |
| Total per run (approx.) | ~$1.25 |
Costs depend on model choice, content length, and how aggressively you cache.
Optimizations
- Use the cheapest model for triage — accuracy on the 4-bucket task is high even with Haiku/Mini.
- Cache classifier outputs by message ID — never re-triage.
- Prompt-cache the system prompt and voice examples across drafts (big savings).
- Skip drafting on threads where you've already replied (search for sent-thread parent).
- Add a 'voice score' — if the draft drifts from your style, flag it for manual review.
Common mistakes
- Auto-sending — never do this. A bug that mass-replies is recoverable but ugly. Always require human send.
- Skipping voice corpus — generic LLM voice sounds like a bot.
- Triggering on read emails — duplicates and waste; only act on unread.
- Forgetting to handle threads — drafts on top of existing threads need different prompts than fresh replies.
- Triaging your own sent emails — exclude messages where from == you.
Frequently asked questions
Related on AIKnowHub
Concept
AI Agents Explained
Agents are LLMs that can take actions in a loop. Here's what that actually means, where they shine, and where they fall over.
Concept
Prompt Engineering Basics
The actual techniques that move the needle — role priming, structured output, few-shot examples, and why specificity always wins.
Comparison
Cheapest AI APIs
Per-million-token cost comparison across providers, with notes on where the cheap models are actually good enough.
Learning Path
AI Automation Engineer Roadmap
Become the person who turns manual workflows into AI-powered automations. Highly hireable, instantly useful.
Case Study
Case Study: Solo Founder Cuts Email Time 70% with an AI Assistant
How a bootstrapped SaaS founder used a local email triage + draft pipeline to get mornings back — without auto-sending a single message.
Tool Guide
Claude Code Guide
The definitive guide to Anthropic's terminal-native AI coding agent — install, configure, MCP, hooks, skills, sub-agents, plan mode, cost, security, limitations.