An intelligent email management system that automates email processing using AI. The system analyzes emails, suggests actions, and allows control through Telegram.
agent-read-emails-1.mov
agent-read-emails-2.mov
agent-commands.mp4
- 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
- Task Management: Automatically extracts and manages tasks from emails
- Persistent Storage: SQLite database for reliable task and email tracking
The bot provides comprehensive email summaries to help you stay on top of your inbox:
- π
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
- π 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
- Extracted tasks and their status
The system automatically:
- Extracts tasks from incoming emails
- Groups similar tasks to avoid duplication
- Assigns priorities (HIGH/MEDIUM/LOW) based on context
- Creates parent tasks for related items
- Tracks task status and progress
- Provides task summaries via Telegram
- Sends completion notifications to original email threads
- Maintains task dependencies and relationships
- Stores task history and updates in SQLite database
Task Features:
- Automatic priority assignment based on urgency and context
- Smart task grouping using AI similarity detection
- Parent-child task relationships for complex items
- Task completion notifications sent to original senders
- Task status tracking (PENDING/COMPLETED)
- Task context preservation with email thread information
/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
/tasks
: View and manage tasks- List all tasks
- Filter by status/priority
- Update task status
- View task details
- Mark tasks as complete with
/task_done <task_id>
/help
: Display available commands and information/start_processing
: Begin email processing/stop_processing
: Stop email processing/processing_status
: Check current processing status
The bot provides interactive buttons for task management:
- π Refresh List - Update task list
- β° Due Tasks - View upcoming deadlines
- π΄ High Priority - Filter high priority tasks
- π‘ Medium Priority - Filter medium priority tasks
βοΈ Back to Menu - Return to main menu
- Node.js v16+
- Gmail Account with API access
- Telegram Bot Token
- OpenAI API Key
- SQLite3
- Clone and install:
git clone https://github.com/olivierloverde/gmail-agent.git
cd gmail-agent
npm install
- 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
On first run, the application will launch an interactive setup wizard that will:
- Check for missing configurations
- Guide you through obtaining necessary API keys
- Help you set up:
- Gmail API credentials
- Telegram bot token
- OpenAI API key
- Create and configure the
.env
file automatically - Validate all credentials
- Initialize required directories and files
The wizard will provide step-by-step instructions for:
- Go to Google Cloud Console
- Create new project or select existing
- Enable Gmail API
- Create OAuth 2.0 credentials
- Download credentials file
- Message @BotFather
- Create new bot
- Get bot token
- Get user ID from @userinfobot
- Visit OpenAI Platform
- Create API key
The wizard will automatically save all configurations to the .env
file.
- Start a chat with your Telegram bot
- Use the
/help
command to see available options - 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
- 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.
1
- Confirm suggested action2
- Reject suggestion3
- Edit response/Force reply4
- Force archive (for RESPOND actions)
The system will:
- Fetch unread emails
- Analyze content using AI
- Send Telegram notification
- Wait for your action
- Execute chosen action
When archiving, the system:
- Checks for similar emails
- Shows bulk archive options
- Allows individual selection
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
Adjust in src/services/emailService.js
:
this.similarityThreshold = 0.85; // Similarity detection threshold
maxResults: 500, // Number of emails per batch
If authentication fails:
rm token.json
npm start
The setup wizard will automatically run if configuration is missing.
If hitting API limits:
- Increase delays between requests
- Reduce batch sizes
- Adjust similarity thresholds
If Telegram messages fail:
- Check special characters
- Verify markdown syntax
- Reduce message length
- Report issues on GitHub
- Submit pull requests
MIT License - See LICENSE file
- Credentials are automatically secured
- Environment variables are properly handled
- API keys are stored safely
- Access is limited to authorized user