Skip to content

Workflow · Productivity

Build an AI Email Assistant

An assistant that drafts replies in your voice, classifies incoming mail, and surfaces only what needs you.

Intermediate2–4 hoursStack: Claude or GPT-5, Gmail API, Node.js / Python, Local storage
EmailProductivityGmailAgent
Edited by The AIKnowHub team · Editorial team

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 + summary

Step-by-step

  1. 01

    Auth and Gmail API setup

    OAuth with scopes gmail.readonly, gmail.modify, gmail.compose. Save tokens locally.

  2. 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.

  3. 03

    Classifier

    Cheap LLM call per incoming email. Returns bucket + one-line summary. Cache by message ID.

  4. 04

    Drafter

    For reply_needed emails: strong LLM call with your voice examples. Outputs plain text. Save as actual Gmail draft.

  5. 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:

  1. Triages every email into: urgent / reply needed / fyi / archive.
  2. Drafts replies for the "reply needed" bucket in your voice.
  3. 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 itemApprox. 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

Reading and drafting via the Gmail API is allowed and well-supported. Sending high-volume automated mail can trigger rate limits. Personal-scale automation is fine.