** LLM-Powered Gmail Inbox ** Automation Agent
An intelligent, automated email triage system that uses the Gmail API and Llama 3.3 70B (via Groq) to ruthlessly organize your inbox. It acts as an elite executive assistant, reading unread emails, scoring their importance, and automatically trashing junk while keeping high-priority communications.
- LLM-Powered Judgment: Uses Llama 3.3 70B to evaluate email context, sender, and body snippets to rank emails on a priority scale of 1 to 10.
- Smart Context Engine: Pre-filters senders and subjects to provide the AI with hints (e.g., flagging OTPs, interview requests, or standard marketing junk).
- Automated Inbox Management: Automatically moves low-value emails (Rank 1-2) to the Trash and marks high-value emails as Read.
- Pagination Handling: Safely processes unread emails in batches of 20 to respect API rate limits.
- Dry-Run Safety Mode: Includes a built-in safety toggle to test the AI's judgment without actually modifying or deleting your emails.
- Language: Python
- APIs: Gmail API (OAuth 2.0), Groq API
- Libraries:
google-api-python-client,google-auth-oauthlib,groq,python-dotenv
- Python 3.8+
- A Groq API Key
- A Google Cloud Project with the Gmail API enabled.
Create a free account at the Groq Console and generate an API key.
Go to the Google Cloud Console, enable the Gmail API, and download your credentials.json.
Rename .env.example to .env and paste your Groq API key inside.
Place your credentials.json in the root folder of the project.
git clone [https://github.com/YOUR_USERNAME/YOUR_REPO_NAME.git](https://github.com/YOUR_USERNAME/YOUR_REPO_NAME.git)
cd YOUR_REPO_NAME
pip install -r requirements.txt
**Example output from the AI Inbox Agent:**
```text
SENDER: Pinterest <recommendations@discover.pinterest.com>
SUB: Aasthaasharma, so iconic...
RANK: 1/10 | Automated marketing email with no personalized content
[DRY RUN] Would have Trashed.
SENDER: TCS Careers <Careers@tcs.com>
SUB: Incomplete profiles will not be able to participate...
RANK: 5/10 | Coding competition invite
[DRY RUN] Would have Kept.
Once your environment variables and credentials are set up, you can run the agent:
```bash
python main.py