Using GPT4 to extract interesting links from my daily newsletters
Why? I spend too much time opening and checking through all my newsletters subscriptions, would rather have all interesting links in one page.
Inspired by isafulf/inbox_cleaner
- Python 3.10 or higher
- Gmail account
- Google Cloud account with Gmail API enabled
- OpenAI API key
-
Clone repo:
git clone https://github.com/benthecoder/gmail_llm.git cd gmail_llm
-
Install packages:
pip install -r requirements.txt
-
Set up Google API credentials:
- create a new OAuth 2.0 Client ID (instructions)
- Download JSON file and rename it to
credentials.json
. - Put
credentials.json
in thegmail_llm
directory.
-
Set OpenAI API key:
- Get an OpenAI API key here
- Rename
.env.local
to.env
and set your key
OPENAI_API_KEY=<YOUR_API_KEY>
Run the script:
python main.py
see an example in summary folder
- improve prompt to extract as many links as possible and have better categorization
- Experiment with different forms of output, maybe article form? Have it copy someone's writing style, publish it to substack, could be a newsletter automation with AI thing
- Check if text extracted from emails can be cleaned up, any redundant info fed into prompt?
- Run this on cloud/local and dump results in DB so I can read into my blog or in notion
- Docs for listing emails users.messages.list
- Docs for querying Searching for Messages
- Counting tokens with tiktoken