An AI-powered agent that monitors your Gmail for newsletters, extracts key insights using Google Gemini, and compiles them into a Notion database and Daily Summary page.
NOTE: This agent was built via AI. Design brainstorm and PRD via Claude Sonnet. Code, testing, and utilities via Gemini/Antigravity.
- Automated Search: Scans Gmail for newsletters based on your filters.
- AI Extraction: Uses Gemini Flash to extract summaries, key takeaways, and categories from emails.
- Notion Integration: Creates individual article pages and a consolidated "Daily Summary" in Notion.
- Chunking Support: Handles large summaries by splitting content into Notion-compatible blocks.
- Deduplication: Tags emails as processed to prevent duplicate entries.
- Agent Icon: assets/Newsletter_agent.jpg can be used when creating Notion API Connection (and will be used as the author avatar in Notion). The image was generated by Antigravity/Nano Bananna.
-
Prerequisites:
- Python 3.10+
- Google Cloud Project (Gmail API enabled)
- Google Gemini API Key
- Notion Integration Token
-
Environment Variables: Create a
.envfile:GEMINI_API_KEY=your_key_here NOTION_API_KEY=your_key_here NOTION_ARTICLES_DB_ID=your_db_id NOTION_SUMMARY_DB_ID=your_db_id
-
Authentication:
- Place
credentials.json(Gmail OAuth) in the root. - Run
python gmail_auth.pyto generatetoken.json.
- Place
-
Install Dependencies:
pip install -r requirements.txt
Run the agent manually:
python main.pyUses launchd on macOS for daily execution at 8:00 AM.
- Generate the configuration file from the template:
sed "s|{{PROJECT_DIR}}|$PWD|g" com.ben.newsletter_agent.plist.template > com.ben.newsletter_agent.plist
- Install the agent:
cp com.ben.newsletter_agent.plist ~/Library/LaunchAgents/ launchctl load ~/Library/LaunchAgents/com.ben.newsletter_agent.plist
main.py: Entry point and orchestration.gmail_client.py: Handles Gmail API searching and label management.llm_processor.py: Interacts with Gemini API for content extraction.notion_agent.py: Manages Notion pages and databases.