AI-powered newsletter summarizer that reads your newsletters and sends concise summaries.
- Python 3.8+
- Gmail account
- OpenAI account or HuggingFace account
- Google Cloud account
The HuggingFace Serverless Inference API has a free tier, but the OpenAI API does not.
git clone https://github.com/sb529/NewsletterGPT.git
cd NewsletterGPT
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
-
Go to Google Cloud Console
-
Create new project
- Click top bar dropdown → "New Project"
- Name: "Newsletter Summarizer"
- Click "Create"
-
Enable Gmail API
- Search "Gmail API" in top search bar
- Click "Enable API"
-
Create OAuth Credentials
- Go to "APIs & Services" → "Credentials"
- Click "Create Credentials" → "OAuth client ID"
- Configure consent screen:
- User Type: External
- App name: "Newsletter Summarizer"
- User support email: Your email
- Developer contact: Your email
- Add test users:
- Your Gmail address
- Create OAuth Client ID:
- Application type: Desktop app
- Name: "Newsletter Client"
- Download JSON
- Rename to
credentials.json
- Move to project folder
- Visit OpenAI Platform
- Create account/login
- Click "API Keys" → "Create new secret key"
- Copy key
- Visit HuggingFace
- Create account/login
- Go to Access Tokens
- Click "Create new token"
- In User Permissions, select Inference->"Make calls to the serverless inference API"
- Click "Create"
- Copy key
Create .env
file:
TYPE=OPENAI or HUGGINGFACE
OPENAI_API_KEY=your-openai-key
INFERENCE_API_KEY=your-huggingface-key
SUMMARY_EMAIL=your-email@example.com
Update NEWSLETTER_SENDERS
in newsletter_processor.py:
NEWSLETTER_SENDERS = [
'newsletter1@example.com',
'newsletter2@example.com'
]
python newsletter_processor.py
First run opens browser for Gmail authorization.
-
"Access Blocked" error
- Check OAuth consent screen setup
- Verify you're logged into correct Google account
-
"API Key Invalid" error
- Check OPENAI_API_KEY in .env
- Verify key on OpenAI platform
-
No emails processed
- Verify newsletter sender addresses
- Check for unread emails