MorningMail AI is a production-ready daily email parser that checks your Gmail every morning, applies AI (Gemini or OpenAI) to identify only the emails that actually matter, summarizes them, and delivers a formatted digest straight to your WhatsApp.
It includes a premium, glassmorphic dark-mode web dashboard to monitor your incoming feeds, toggle AI classifications, trigger manual digest runs, check scheduler cron times, and train the AI over time based on feedback.
- Gmail API OAuth 2.0: Reads messages securely using modern token flows (token auto-refreshes in the background).
- AI Classification Layer: Filters out newsletters, promotions, LinkedIn notifications, and spam. Supports Gemini (default) or OpenAI.
- WhatsApp Cloud API: Integrates with the official Meta WhatsApp Graph API to deliver daily digests.
- WhatsApp & Gmail Simulators: Run the app completely offline without configuring Google Cloud or Meta developer accounts for easy local testing.
- Feedback & Rule Customization: The AI automatically learns from your inputs (thumbs up/down, muting) to dynamically modify classification rules.
- Weather Integrations: Appends daily weather forecasts to the morning digest.
- Background Scheduler: Dynamic cron executions using APScheduler that updates in real-time when the timezone or run time changes.
morningmail-ai/
│
├── app/
│ ├── api/
│ │ ├── auth.py # Gmail OAuth flow endpoints
│ │ ├── emails.py # Log logs list and user feedback loops
│ │ ├── preferences.py # Scheduling configuration, rules and mutes
│ │ └── digests.py # History logs, manual trigger and simulator API
│ │
│ ├── database/
│ │ ├── connection.py # Database engines and context sessions
│ │ └── repository.py # Database CRUD helper queries
│ │
│ ├── models/
│ │ └── db_models.py # SQLAlchemy User, Email, History, and Cache schemas
│ │
│ ├── schemas/
│ │ └── api_schemas.py # Pydantic request/response data models
│ │
│ ├── services/
│ │ ├── ai_service.py # AI provider bindings and heuristic simulators
│ │ ├── gmail_service.py # Gmail API client and inbox simulators
│ │ ├── wa_service.py # Meta WhatsApp API client and file logs simulator
│ │ ├── weather_service.py # wttr.in or OpenWeatherMap provider
│ │ └── digest_orchestrator.py # Core workflow coordinator
│ │
│ ├── prompts/
│ │ └── templates.py # System instructions and classification formats
│ │
│ ├── scheduler/
│ │ └── scheduler.py # APScheduler setup and cron triggers
│ │
│ ├── utils/
│ │ ├── config.py # Pydantic settings loading .env parameters
│ │ └── logger.py # Rotating log files configuration
│ │
│ ├── main.py # Application entrypoint and static file mount
│ │
│ └── static/ # Web Dashboard SPA front-end (HTML / CSS / JS)
│
├── tests/
│ └── test_morningmail.py # pytest test suites
│
├── .env.example # Environment template
├── Dockerfile # Production build recipe
├── docker-compose.yml # Docker deployment composer
└── requirements.txt # Package requirements list
- Python: Ensure Python 3.9+ is installed.
- Virtual Environment: Initialize a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txtCopy the template .env.example file to .env:
cp .env.example .envFill out the keys as desired. By default, if you leave GMAIL_CLIENT_ID and GEMINI_API_KEY/OPENAI_API_KEY blank, the app will run in Simulator Mode using pre-configured heuristic classifications and mock inbox emails, so you can explore the dashboard features immediately!
- Go to the Google Cloud Console.
- Create a new project.
- Enable the Gmail API under APIs & Services.
- Set up the OAuth Consent Screen (Choose External, add test users, set scopes to include
.../auth/gmail.readonly). - Under Credentials, create OAuth 2.0 Client IDs (Application type: Web Application).
- Set the Authorized redirect URIs to
http://localhost:8000/api/auth/gmail/callback(or your production domain). - Copy your Client ID and Client Secret into your
.envfile underGMAIL_CLIENT_IDandGMAIL_CLIENT_SECRET.
- Go to the Meta for Developers Portal.
- Create an App (Type: Business).
- Add the WhatsApp product.
- Copy the Temporary Access Token (or configure a Permanent token) and the Phone Number ID under WhatsApp Getting Started.
- In your
.env, setWHATSAPP_PROVIDER=cloudand paste yourWHATSAPP_TOKEN,WHATSAPP_PHONE_NUMBER_ID, andWHATSAPP_RECIPIENT_NUMBER(your personal phone number including country code). - Important Note: To send free-text messages to your personal phone number, you must send a text message from your phone to the developer phone number first to open the 24-hour customer service session window!
Start the local server using Uvicorn:
uvicorn app.main:app --reloadOpen http://localhost:8000 in your browser.
- Simulator Check: Click Trigger Daily Digest Now on the right side. The app will fetch 10 mock emails, filter out newsletters/promotional material, categorize important items, compile the digest, and print it to the console. The simulated text will display in the WhatsApp mobile mockup screen instantly!
- Link Gmail: Click Link Gmail to perform Google OAuth. Once approved, the dashboard badge changes to "Connected". Manual triggers and daily crons will sync your actual inbox!
- Mute/Thumbs Up & Down: Click the thumbs-up/down icons on email logs to alter the priorities. Check the Override Rules tab to inspect the generated filters!
Run unit tests via pytest:
pytestThe application is Docker-ready.
Build and run using docker-compose:
docker-compose up --build -dThe database will be persisted under the docker volume sqlite_data so that your OAuth tokens, preference rules, and email history logs are saved securely across container instances!