Email Insights Agent

AI-powered email management system with two modes: batch analysis (categorization, action items, VIP detection) and real-time conversational interface. Text WhatsApp or SMS to manage your inbox via Claude with tool-use reasoning. Features Gmail OAuth with send/reply capabilities, Twilio integration, conversation history, and daily cron daemon.

Tech Stack

PythonClaude APIGmail APIFlaskTwilioRich CLIAPScheduler

About

An intelligent email analysis system leveraging Claude AI to process Gmail inbox data and generate actionable insights. This project demonstrates enterprise-grade integration of multiple APIs (Gmail, Anthropic) with local data persistence and real-time conversational capabilities. The system operates in multiple modes: initial analysis of the last 100 emails to establish a baseline, manual force-run for recent emails, daily automated cron scheduling, and on-demand report retrieval. Users can interact with their inbox via WhatsApp or SMS, receiving insights and managing emails through natural conversation with Claude.

Technical Approach

Built with a CLI interface using Click framework and Python. The architecture follows a modular design with separate components for Gmail OAuth 2.0 authentication, Claude API integration, schedule-based task automation, and JSON-based local storage. Email processing uses a batch strategy (50-email chunks) with Claude's adaptive thinking for complex inference tasks. Key components include: - Gmail OAuth 2.0 with automatic token refresh - Claude API integration with tool-use reasoning - Twilio for WhatsApp/SMS integration - APScheduler for automated cron execution - Rich terminal formatting for data display

Key Achievements

  • Automated inbox analysis with categorization (IMPORTANT, ACTION_REQUIRED, NEWSLETTER, SPAM)
  • VIP sender identification and priority ranking system
  • Inbox health scoring on a 0-10 scale with trend analysis
  • Real-time conversational interface via WhatsApp/SMS
  • Daily automated report generation with configurable scheduling
  • Sentiment analysis and action item extraction from email content

Challenges & Learning

  • Managing Gmail API rate limits through intelligent batching strategies
  • Implementing reliable OAuth 2.0 token refresh without user intervention
  • Structuring Claude prompts to ensure reliable JSON parsing across diverse email formats
  • Maintaining conversation history while optimizing API costs for real-time interactions
  • Balancing automated analysis with user-driven conversational queries