An intelligent system that converts school emails into Google Calendar events using Claude AI, with multi-calendar support for different classes.
This repository contains no sensitive credentials. All API keys and personal information are stored securely via Google Sheets integration. See SETUP_GUIDE.md
for configuration instructions.
# Install dependencies
pip install -r requirements.txt
# Follow setup guide for complete configuration
# See SETUP_GUIDE.md for detailed instructions
# Run the application
python run_mail2cal.py
Mail2Cal/
├── 📄 Core Application
│ ├── run_mail2cal.py # Main entry point (START HERE)
│ ├── mail2cal.py # Core Mail2Cal class
│ ├── ai_parser.py # Claude AI integration
│ ├── event_tracker.py # Event tracking system
│ ├── pdf_attachment_processor.py # PDF processing
│ └── secure_credentials.py # Secure credential management
│
├── 🛠️ utils/ # Utility Scripts
│ ├── preview_emails.py # Preview emails (no AI tokens)
│ ├── cleanup_duplicates.py # Remove duplicate events
│ └── check_calendar.py # View calendar events
│
├── 🔧 troubleshooting/ # Troubleshooting & Testing
│ ├── test_setup.py # Validate installation
│ ├── test_gmail_auth.py # Test Gmail authentication
│ └── test_limited.py # Test with limited emails
│
├── 📚 docs/ # Documentation
│ └── CLAUDE.md # Complete documentation
│
└── 📋 Essential Files
├── README.md # Project overview
├── SETUP_GUIDE.md # Setup instructions
├── requirements.txt # Python dependencies
├── secure_credentials_config.py # Google Apps Script URL
├── credentials.json # OAuth credentials (user-provided)
├── token.pickle # Saved authentication tokens
└── event_mappings.json # Email-to-event tracking database
# Interactive mode (recommended for beginners)
python run_mail2cal.py
# Direct commands
python run_mail2cal.py --preview # Preview emails (no AI tokens)
python run_mail2cal.py --test # Test with 3 emails
python run_mail2cal.py --full # Process all emails with AI
# Calendar management
python utils/check_both_calendars.py
python utils/migrate_calendar_events.py
python utils/analyze_email_routing.py
# System maintenance
python utils/cleanup_duplicates.py
python utils/preview_emails.py
# System validation
python troubleshooting/test_setup.py
python troubleshooting/test_gmail_auth.py
# Testing & debugging
python troubleshooting/test_multi_calendar.py
python troubleshooting/test_limited.py
The system automatically routes emails to appropriate calendars:
- Teacher 1 emails → Calendar 1 only (8:00 AM default timing)
- Teacher 2 emails → Calendar 2 only (8:00 AM default timing)
- Teacher 3 & 4 emails (Afterschool) → Both calendars (1:00 PM default timing)
- Other school emails → Both calendars (all-day events)
The system now automatically processes PDF attachments containing important school information:
- Holiday calendars and exceptional days off
- Special activity schedules
- School event programs
- Class timetable changes
- Administrative announcements
- Auto-Detection: Automatically finds PDF attachments in emails
- Text Extraction: Extracts text from PDFs using advanced libraries
- AI Integration: Includes PDF content in Claude analysis
- Event Creation: Generates calendar events from PDF information
pip install pdfplumber PyMuPDF
- Setup:
SETUP_GUIDE.md
- Quick setup instructions - Complete Documentation:
docs/CLAUDE.md
- Full system documentation
- Installation issues: Run
python troubleshooting/test_setup.py
- Authentication problems: Run
python troubleshooting/test_gmail_auth.py
- Limited testing: Run
python troubleshooting/test_limited.py
- General questions: Check
docs/CLAUDE.md
- Calendar 1: Teacher 1 events + afterschool events (Teachers 3&4) + other school senders
- Calendar 2: Teacher 2 events + afterschool events (Teachers 3&4) + other school senders
- System: Fully operational with correct multi-calendar routing
- Migration: All events properly distributed (July 2025)