https://github.com/iloveitaly/gmail-digest
A tool to generate a daily digest of your Gmail inbox. Helpful if you have agents working on your behalf.
https://github.com/iloveitaly/gmail-digest
ai digest email gmail gmail-api llm
Last synced: 10 months ago
JSON representation
A tool to generate a daily digest of your Gmail inbox. Helpful if you have agents working on your behalf.
- Host: GitHub
- URL: https://github.com/iloveitaly/gmail-digest
- Owner: iloveitaly
- License: mit
- Created: 2024-07-25T12:27:19.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-02T13:01:12.000Z (12 months ago)
- Last Synced: 2025-04-14T12:58:18.538Z (10 months ago)
- Topics: ai, digest, email, gmail, gmail-api, llm
- Language: Python
- Homepage: https://github.com/iloveitaly/gmail-digest
- Size: 295 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Gmail Digest
If you have an assistant (real or AI) working in your inbox, it's helpful to know what they are doing. This tool generates a summary of the emails sent from your inbox each day.
Alternatively, this could be used to monitor a support inbox, sales inbox, etc and understand what is happening across that inbox.
## Installation
```shell
pip install -U gmail-digest
```
## Usage
```shell
Usage: gmail-digest [OPTIONS]
Options:
--dry-run Run script without creating sending
--help Show this message and exit.
```
### Docker
Check out the [docker-compose.yml file](./docker-compose.yml) for an example of how to run this tool in a docker container.
```
ghcr.io/iloveitaly/gmail-digest
```
### Extra filter
You can customize the gmail query used to collect emails to summarize:
```shell
GMAIL_FILTER_SUFFIX='-to:personal@gmail.com -to:readwise.io -to:todoist.com'
```
## Development
Test the tool by running it locally and increasing `DIGEST_DAYS`.
Need to debug OpenAI/prompt issues? [Enable debug logging.](https://stackoverflow.com/questions/76256249/logging-in-the-open-ai-python-library/78214464#78214464)
## Setup
You need to create a "OAuth 2.0 Client IDs" which has to be done with a Google Workspace (gsuite). This will not work on a personal gmail account (unless you create a app on a workspace and add your personal account as a test account).
### Generating a Gmail API Token
1. Navigate to the Google Cloud Console. https://console.developers.google.com/
2. Create a new project or select an existing one.
3. Go to "APIs & Services" -> "Library" and enable the Gmail API.
4. Navigate to "APIs & Services" -> "Credentials".
5. Click "Create Credentials" -> "OAuth client ID".
6. Select "Desktop app" as the application type, then click "Create".
7. Download the JSON file, rename it to `credentials.json`, and place it in the root of this project.
8. Run the script and oauth into your account
If you want to edit scopes on an existing application, you can:
1. OAuth Consent Screen
2. Edit
3. Continue to step 2
4. Add or remove scopes
5. Add scopes and save
#### Credential Scopes Needed
Two main scopes are required for this:
* `https://www.googleapis.com/auth/gmail.compose`
* `https://www.googleapis.com/auth/gmail.readonly`
Some other scopes I'd add so you can reuse the credentials in other projects, [like gmailctl](https://github.com/mbrt/gmailctl) or calendar scripts:
* `https://www.googleapis.com/auth/calendar.readonly`
* `https://www.googleapis.com/auth/calendar.event`
* `https://www.googleapis.com/auth/gmail.labels`
* `https://www.googleapis.com/auth/gmail.settings.basic`