Iyeoluwa Akinrinola 70b2bcc89d Fix Zoho connection issues and add local testing capabilities
- Fixed 'days_back' parameter error in zoho_client.py
- Added robust settings validation in app.py to prevent int() errors
- Created LOCAL_TESTING.md with comprehensive testing guide
- Added run_local.sh for easy local server setup
- Added deploy_updates.sh for deployment instructions
- Added test_local_connection.py for automated testing
- Updated config.json with proper structure
- All fixes tested and working locally
2025-07-25 12:40:10 +01:00

Email Alerts System

A smart email monitoring system that automatically detects actionable emails and sends WhatsApp alerts with AI-powered analysis.

🚀 Features

  • Real-time Email Monitoring: Connects to Zoho Mail API to fetch emails
  • AI-Powered Analysis: Uses Groq LLM for intelligent email analysis
  • Smart Triage: Identifies actionable vs non-actionable emails
  • WhatsApp Alerts: Sends real-time alerts to your phone
  • Thread Tracking: Monitors conversation states and timing
  • Intelligent Timing: Level 1 (1-24 hours), Level 2 (24-48 hours), Level 3 (48+ hours)
  • 7-Day Email Filtering: Only processes emails from the last 7 days

📁 Core System Files

email_alerts/
├── main.py                 # Main entry point
├── zoho_client.py          # Zoho Mail API integration
├── email_triage.py         # Email filtering & classification
├── thread_tracker.py       # Thread state management
├── ai_analyzer.py          # AI analysis & alert generation
├── whatsapp_sender.py      # WhatsApp alert sending
├── email_processor.py      # Main orchestration
├── requirements.txt        # Python dependencies
├── .env                    # Environment variables
├── email_threads.db       # SQLite database
├── README.md              # This file
└── TWILIO_SETUP.md       # WhatsApp setup guide

🛠️ Setup

  1. Install Dependencies:

    pip install -r requirements.txt
    
  2. Configure Environment:

    cp env.example .env
    # Edit .env with your API keys
    
  3. Set up Zoho Mail:

  4. Set up Twilio WhatsApp:

    • Follow TWILIO_SETUP.md
    • Configure WhatsApp Business API

🚀 Usage

Run the system:

python main.py

Alert Timing

  • Level 1: 1-24 hours - Initial alert
  • Level 2: 24-48 hours - Urgent alert
  • Level 3: 48+ hours - Critical alert

📧 Email Filtering

The system now only processes emails from the last 7 days to ensure relevance and performance.

🤖 AI Analysis

The system uses Groq LLM for intelligent email analysis:

  • Real AI analysis - No mock mode, only real Groq LLM
  • Smart filtering - Only alerts for emails that actually need responses
  • Urgency detection - LOW/MEDIUM/HIGH/CRITICAL based on content
  • Intelligent summaries - Context-aware email analysis
  • Action recommendations - Specific guidance on what to do

📱 WhatsApp Alerts

Alerts include:

  • Real email details (sender, subject, body)
  • AI-generated summary
  • Urgency level
  • Required action
  • Thread ID for reference

🔧 Configuration

Key environment variables:

  • ZOHO_EMAIL: Zoho email address
  • ZOHO_PASSWORD: Zoho email password
  • GROQ_API_KEY: Groq LLM API key
  • TWILIO_ACCOUNT_SID: Twilio account SID
  • TWILIO_AUTH_TOKEN: Twilio auth token
  • TWILIO_WHATSAPP_NUMBER: Twilio WhatsApp number
  • WHATSAPP_TO_NUMBER: Your phone number

📊 System Architecture

Zoho Mail API → Email Triage → AI Analysis → Thread Tracking → WhatsApp Alerts

Status

  • Real Zoho Mail integration
  • Real AI analysis (Groq LLM)
  • Real WhatsApp alerts (Twilio)
  • Intelligent timing system
  • 7-day email filtering
  • No hardcoded data
  • Production ready

🔄 Migration from Gmail

The system has been successfully migrated from Gmail API to Zoho Mail API:

  • Replaced gmail_client.py with zoho_client.py
  • Updated authentication to use Zoho credentials
  • Maintained all existing functionality
  • Added 7-day email filtering for better performance
S
Description
No description provided
Readme 33 MiB
Languages
Python 63.5%
HTML 31%
Shell 5.5%