Skip to main content

Building the AI Email Assistant: Taming Inbox Overload

ยท 3 min read
Uday Tamma
Building AI-Powered Applications

The AI Email Assistant tackles a universal problem: email overload. Built with Google Gemini AI, it automatically categorizes, summarizes, and enables one-click actions on Gmail emails.

The Problemโ€‹

Professionals spend hours daily processing emails. Most of this work is repetitive:

  • Deciding what's urgent vs. informational
  • Deleting promotional content
  • Extracting action items from messages

The goal: reduce email processing time by 70% through AI-powered automation.

Core Featuresโ€‹

AI-Powered Categorizationโ€‹

Gemini AI classifies emails into 6 categories:

CategoryDescriptionExample
Need-ActionRequires responseBills, important tasks
FYIInformation onlyReceipts, confirmations
NewsletterRegular digestsWeekly newsletters
MarketingPromotional contentSales, offers
SPAMUnwanted messagesSuspicious content
OtherUncategorizedEverything else

Each email also gets:

  • Subcategory (Bill-Due, Package-Tracker, JobAlert, etc.)
  • AI Summary (one sentence, โ‰ค15 words)
  • Suggested Action (AddToCalendar, Delete, Unsubscribe, etc.)

One-Click Actionsโ€‹

Category-based quick actions eliminate decision fatigue:

  • FYI/Newsletter/Marketing: Delete button (moves to trash)
  • Need-Action: Dropdown with 4 options (Add to Calendar, Add Task, Mark as Read, Delete)
  • SPAM: Unsubscribe link (auto-extracts unsubscribe email and sends opt-out)

Actions execute instantly without confirmation dialogs. The UI updates inline.

Comprehensive Loggingโ€‹

Full audit trail for debugging and observability:

  • All Gemini AI interactions logged with prompts and responses
  • API calls logged with formatted Python syntax
  • Daily log rotation with search and filtering
  • Statistics dashboard (latency, operation counts)

Technical Architectureโ€‹

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Web Browser โ”‚
โ”‚ (Email Review UI, Logs Dashboard) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ HTTP/JSON
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Flask Web Server โ”‚
โ”‚ Routes: /gemini-review, /gemini-logs, /api/* โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ โ”‚ โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Gemini AI โ”‚ โ”‚ Gmail API โ”‚ โ”‚ Calendar/ โ”‚
โ”‚ Service โ”‚ โ”‚ Service โ”‚ โ”‚ Tasks APIs โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Tech Stackโ€‹

  • Backend: Python 3.14, Flask
  • AI: Google Gemini 2.5 Flash Lite
  • APIs: Gmail API v1, Calendar API v3, Tasks API v1
  • Frontend: Vanilla HTML/CSS/JS with Jinja2 templates
  • Auth: OAuth 2.0 for Google services

Key Design Decisionsโ€‹

1. No Confirmation Dialogsโ€‹

Actions execute immediately. Users processing 50+ emails don't want to click "Are you sure?" 50 times. The trade-off: occasional mistakes are easily undone (emails go to trash, not permanent delete).

2. Server-Side Renderingโ€‹

Chose Flask + Jinja2 over a SPA framework. For a personal productivity tool, simplicity wins. No build step, no framework overhead, instant page loads.

3. Comprehensive Loggingโ€‹

Every Gemini interaction and API call is logged. This was critical for:

  • Debugging categorization issues
  • Understanding AI behavior patterns
  • Building confidence in the system

4. Category-Based UIโ€‹

The action controls change based on email category. Marketing emails get a simple delete button. Need-Action emails get a full dropdown. The UI adapts to the task.

Performanceโ€‹

  • Single email categorization: under 2 seconds (p95)
  • Batch of 30 emails: under 60 seconds (p95)
  • Page load: under 2 seconds
  • Action execution: under 1 second

Rate limiting handles Gemini's 30 requests/minute quota gracefully.

Lessons Learnedโ€‹

  1. AI summaries are surprisingly useful: The one-sentence summary often tells you everything you need without opening the email.

  2. Unsubscribe extraction is tricky: Parsing unsubscribe links from email bodies requires handling many formats.

  3. Logging saves debugging time: When categorization seems wrong, the logs show exactly what the AI saw and why it decided.

  4. Gmail API quotas matter: Batch operations and caching are essential for processing large inboxes.

What's Nextโ€‹

Planned for Phase 2:

  • Smart date/time extraction for calendar events
  • Bulk actions (select multiple emails)
  • Email threading support

Future phases:

  • Natural language queries ("Show bills due this month")
  • Automation rules engine
  • Mobile app