Managing a large volume of emails in Gmail can quickly become overwhelming. Promotional messages, notifications, offers, spam, and invoices all mix together, making it difficult to respond efficiently. Manually sorting and labeling emails is tedious, error-prone, and time-consuming. Many users underutilize Gmail’s powerful labeling system simply due to the lack of an effective, intelligent tool for automatic email categorization based on actual content.
🚀 Application
Gmail Assistant is a Python-based tool designed to solve this problem. It automatically analyzes your recent (or selected) Gmail messages and assigns appropriate labels from a pre-defined category set. The tool leverages:
- 🤖 Perplexity API (AI) for deep content analysis and category assignment
- 📬 Gmail API for fetching emails, applying labels, and dynamically creating new labels in your Gmail account if needed
⭐ Key Features
- Automatic email classification into predefined categories (e.g., Invoice, Spam, Offers)
- Interactive mode allowing you to confirm or correct AI suggestions, storing feedback for future improvement
- Automatic mode for fast batch processing without manual intervention
- Built-in statistics with bar charts showing category distributions during each session
- Feedback loop system enabling the assistant to learn from user corrections (excellent portfolio showcase)
- Clean, modular design facilitating future extensions and integration with other services
⚙️ Setup Instructions
-
Google Cloud Console Setup:
- Create a project in Google Cloud Console.
- Enable the Gmail API.
- Create OAuth 2.0 credentials for a Desktop Application.
- Download the
credentials.jsonfile and place it in the project root directory.
-
Perplexity API Key:
- Obtain your Perplexity API key from your Perplexity Pro account.
- Store the key securely by creating a
.envfile or export it as an environment variable:PERPLEXITY_API_KEY=your_api_key_here
-
Install dependencies:
pip install -r requirements.txt
- Run the assistant:
- You will be prompted to select Automatic or Interactive mode.
- Authentication with Gmail will happen on the first run via OAuth browser window.
- View statistics:
After processing emails, run:
python plot_statistics.py
This displays a bar chart of how many emails were assigned to each category during the session.
🎯 Usage Modes
- ⚙️ Automatic mode: The assistant tags emails without asking for user input — fast and hands-off.
- 🖱️ Interactive mode: After AI suggests a label, you can approve or change it, enabling a feedback loop to improve labeling accuracy over time.
🧩 Final Effects
I encourage you to discover more about my assistant by reading other sections or even running it by yourself! Instructon is also given above.
🔐 Security & Good Practices
- Your
credentials.json, OAuthtoken.json,feedback.csv, and.envfiles must never be publicly shared or pushed to GitHub. - Use
.gitignoreto exclude these files from your repository. - Store all secrets securely and consider using environment variables for API keys.
- This approach keeps your account safe and your project professional.
📞 Contact & Contributions
For questions, improvements, or collaboration, feel free to open an issue or pull request on GitHub, or reach out via email.
Thank you for exploring Gmail Assistant — efficient, intelligent, and ready to help you tame your inbox! ✉️✨
