https://github.com/olivierloverde/gmail-agent Skip to content Navigation Menu Toggle navigation Sign in * Product + GitHub Copilot Write better code with AI + Security Find and fix vulnerabilities + Actions Automate any workflow + Codespaces Instant dev environments + Issues Plan and track work + Code Review Manage code changes + Discussions Collaborate outside of code + Code Search Find more, search less Explore + All features + Documentation + GitHub Skills + Blog * Solutions By company size + Enterprises + Small and medium teams + Startups By use case + DevSecOps + DevOps + CI/CD + View all use cases By industry + Healthcare + Financial services + Manufacturing + Government + View all industries View all solutions * Resources Topics + AI + DevOps + Security + Software Development + View all Explore + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Enterprise + Enterprise platform AI-powered developer platform Available add-ons + Advanced Security Enterprise-grade security features + GitHub Copilot Enterprise-grade AI features + Premium Support Enterprise-grade 24/7 support * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up Reseting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} olivierloverde / gmail-agent Public * Notifications You must be signed in to change notification settings * Fork 0 * Star 21 AI-based Telegram agent with memory that will help you reach inbox 0 in no time. License MIT license 21 stars 0 forks Branches Tags Activity Star Notifications You must be signed in to change notification settings * Code * Issues 0 * Pull requests 0 * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Projects * Security * Insights olivierloverde/gmail-agent main BranchesTags [ ] Go to file Code Folders and files Name Name Last commit message Last commit date Latest commit History 8 Commits src src .gitignore .gitignore LICENSE LICENSE README.md README.md package.json package.json View all files Repository files navigation * README * MIT license Gmail AI Agent An intelligent email management system that automates email processing using AI. The system analyzes emails, suggests actions, and allows control through Telegram. Demo agent-read-emails-1.mov agent-read-emails-2.mov agent-commands.mp4 Features Top features * AI-Powered Analysis: Uses GPT models to understand email context and intent * Smart Response Generation: Creates contextually appropriate responses * Smart Email Summarization: Generates action-driven email summaries * Bulk Email Management: Groups and handles similar emails efficiently * Vector Similarity: Uses embeddings to find truly similar emails * Telegram Control: Full email management through Telegram interface * Multi-language Support: Handles emails in any language * Smart Threading: Understands email conversation context * Customizable Actions: Archive, respond, or request more information Email Summaries The bot provides comprehensive email summaries to help you stay on top of your inbox: Scheduled Summaries * Morning Overview (9 AM) + Covers emails from 5 PM previous day to 9 AM + Perfect for catching up on overnight communications * Midday Catch-up (2 PM) + Covers emails from 9 AM to 2 PM + Stay updated on morning developments * Evening Wrap-up (7 PM) + Covers emails from 2 PM to 7 PM + Review afternoon communications and plan for tomorrow On-Demand Summary * Quick Summary + Covers the last 3 hours of emails + Useful for immediate status checks Each summary includes: * Brief overview of important communications * Top 5 priority emails ranked by urgency * Key insights and action items Summaries automatically exclude: * Automated notifications/alerts * Newsletters/marketing emails * System-generated messages * Calendar invites/updates * Subscription confirmations * Receipts/invoices * Social media notifications * Promotional offers Commands * /summary: Request an email summary + Choose from morning, midday, evening, or quick summary types + Each type covers a specific time range + Summaries are focused on actionable items only * /help: Display available commands and information Prerequisites * Node.js v16+ * Gmail Account with API access * Telegram Bot Token * OpenAI API Key Quick Start 1. Clone and install: git clone https://github.com/olivierloverde/gmail-agent.git cd gmail-agent npm install 2. Run the automated setup wizard: npm start The setup wizard will: * Guide you through API setup process * Help create necessary credentials * Configure environment variables * Set up Gmail authentication * Configure Telegram bot * Test all connections Detailed Setup Guide Automated Setup Wizard On first run, the application will launch an interactive setup wizard that will: 1. Check for missing configurations 2. Guide you through obtaining necessary API keys 3. Help you set up: + Gmail API credentials + Telegram bot token + OpenAI API key 4. Create and configure the .env file automatically 5. Validate all credentials 6. Initialize required directories and files The wizard will provide step-by-step instructions for: Gmail API Setup 1. Go to Google Cloud Console 2. Create new project or select existing 3. Enable Gmail API 4. Create OAuth 2.0 credentials 5. Download credentials file Telegram Bot Setup 1. Message @BotFather 2. Create new bot 3. Get bot token 4. Get user ID from @userinfobot OpenAI API Setup 1. Visit OpenAI Platform 2. Create API key The wizard will automatically save all configurations to the .env file. Usage Guide Overview 1. Start a chat with your Telegram bot 2. Use the /help command to see available options 3. Use the /summary command to request an email summary + Select the desired time range based on your needs + Morning: overnight emails since 5 PM yesterday + Midday: morning emails since 9 AM + Evening: afternoon emails since 2 PM + Quick: last 3 hours of emails 4. Interact with the bot to manage your emails efficiently The bot will automatically process incoming emails and send you notifications for important messages. You can then choose to respond, archive, or take other actions directly through the Telegram interface. Telegram Commands * 1 - Confirm suggested action * 2 - Reject suggestion * 3 - Edit response/Force reply * 4 - Force archive (for RESPOND actions) Email Processing The system will: 1. Fetch unread emails 2. Analyze content using AI 3. Send Telegram notification 4. Wait for your action 5. Execute chosen action Bulk Operations When archiving, the system: 1. Checks for similar emails 2. Shows bulk archive options 3. Allows individual selection Configuration [?][?] After initial setup, you can manually adjust settings in .env: GMAIL_CREDENTIALS=./credentials.json TELEGRAM_BOT_TOKEN=your_bot_token TELEGRAM_USER_ID=your_user_id OPENAI_API_KEY=your_openai_key Advanced Settings Adjust in src/services/emailService.js: this.similarityThreshold = 0.85; // Similarity detection threshold maxResults: 500, // Number of emails per batch Troubleshooting Authentication Issues If authentication fails: rm token.json npm start The setup wizard will automatically run if configuration is missing. Rate Limits If hitting API limits: 1. Increase delays between requests 2. Reduce batch sizes 3. Adjust similarity thresholds Message Format Errors If Telegram messages fail: 1. Check special characters 2. Verify markdown syntax 3. Reduce message length Support and Contribution * Report issues on GitHub * Submit pull requests License MIT License - See LICENSE file Security Notes * Credentials are automatically secured * Environment variables are properly handled * API keys are stored safely * Access is limited to authorized user About AI-based Telegram agent with memory that will help you reach inbox 0 in no time. Resources Readme License MIT license Activity Stars 21 stars Watchers 1 watching Forks 0 forks Report repository Releases No releases published Packages 0 No packages published Languages * JavaScript 100.0% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.