Transform your chaotic Gmail inbox into an organized, actionable workspaceβwithout giving third parties access to your emails.
5,000+ unread emails. Sound familiar?
While achieving Inbox Zero is the dream, spending hours manually sorting emails isn't realistic. Third-party automation tools exist, but they require granting external services full access to your Gmail accountβincluding the ability to read and send emails on your behalf.
A privacy-first Gmail personal assistant that runs entirely within Google's ecosystem using Apps Script and Gemini AI. Your emails never leave Google's servers, and only you maintain access.
Automatically categorizes emails into actionable categories:
Action Categories:
- π¨ Urgent - Requires immediate attention
- π To Do - Needs response/action soon
- β³ Waiting - Awaiting response from others
- π Security Alert - Account security notifications
Reference Categories:
- π° Financials - Bills, statements, financial updates
- π° Creator Newsletters - Content creator updates with summaries
- π₯ Social & Community - Social platform notifications, community updates
- ποΈ Purchases - Order confirmations, shipping updates
- π·οΈ Promotions - Marketing emails, sales, offers
- π Misc - Everything else
Receive twice-daily email summaries that:
- Aggregate similar emails intelligently (e.g., all social notifications in one section)
- Summarize newsletter content individually with key insights
- Highlight urgent items requiring immediate attention
- Include direct links to original emails for quick access (only works on Desktop)
Category-specific archiving rules:
Action Categories (Never auto-archive):
- Urgent: Stay in inbox
- To Do: Stay in inbox
- Waiting: Stay in inbox
- Security Alert: Stay in inbox
Reference Categories:
- Financials: Archive after 7 days (with 5-day notice)
- Creator Newsletters: Auto-archive immediately (after summary generation)
- Social & Community: Auto-archive immediately
- Purchases: Archive after 7 days (with 2-day notice)
- Promotions: Auto-archive immediately
- Misc: Keep in inbox
Very affordable! Based on Gemini 2.0 Flash-Lite API pricing (2025):
- Input tokens: ~1,500 tokens per email Γ 50 emails = 75,000 tokens
- Output tokens: ~200 tokens per email Γ 50 emails = 10,000 tokens
- Daily cost: (75,000 Γ $0.10/1M) + (10,000 Γ $0.40/1M) = ~$0.012 per day
- Monthly: ~$0.36
- Annual: ~$4.40 (less than a coffee!)
Note: Actual costs may vary based on email length and complexity. The free tier includes generous quotas that may cover light usage entirely.
β
100% Google Ecosystem - Uses only Apps Script and Gemini AI
β
No Third-Party Access - Your emails never leave Google's servers
β
You Stay In Control - Full access control remains with you
β
No External APIs - Everything runs within your Google account
- Gmail account
- Google Apps Script access
- Gemini API access (free tier available)
You can find a video instruction here: https://youtu.be/MDlQQy4D60c
-
Copy the code
- Copy the entire contents of
code.gsfrom this repository
- Copy the entire contents of
-
Open Google Apps Script
- Go to script.google.com
- Create a new project
- Paste it into your Apps Script editor
- Save the project
-
Get Gemini API key
- Go to Google AI Studio
- Get your Gemini API key (free tier available)
- Add the API key to your Apps Script project
-
Set up triggers
- In Apps Script, go to "Triggers" (clock icon)
- Add new trigger for
processEmailsDailyfunction - Set to run "Time-driven" β "Day timer" β "6:00 to 7:00 AM"
-
Pre-setup recommendation (Optional but Recommended)
- Archive emails older than 1 week to reduce processing load
- This prevents the AI from categorizing thousands of old emails
- Focus the system on recent, actionable content
-
Test the setup
- Run the
processEmailsDailyfunction manually first - Check your Gmail for the summary email
- Verify emails are being categorized with labels
- Run the
-
Configure label colors (after running LIMITED or FULL mode)
- Go to Gmail β Settings β Labels in the left sidebar
- Manually assign colors to the created labels for better visual organization
- Suggested colors:
- Urgent: Red
- Security Alert: Red
- To Do: Yellow
- Waiting: Blue
- Social & Community: Light Blue
- Purchases: Light Orange
- Promotions: Light Pink
- Financial: Light Green
- Misc: Light Gray
The script includes three safety modes for different use cases:
- Safe testing mode - makes no changes to your mailbox
- Perfect for testing the AI classification without any risk
- Shows what would happen without actually doing it
- Set
MODE: 'PREVIEW'in the configuration
- Controlled testing - processes only the first 20 emails
- Applies actual changes but limits the scope
- Great for verifying everything works before full deployment
- Set
MODE: 'LIMITED'in the configuration
- Full automation - processes all emails in your inbox
- Use only after testing with PREVIEW and LIMITED modes
- Recommended for daily automated runs
- Set
MODE: 'FULL'in the configuration
- Open your
code.gsfile in Apps Script - Find the
CONFIGsection at the top - Add your Gemini API key to
GEMINI_API_KEY - Start with
MODE: 'PREVIEW'for safe testing - Gradually move to
LIMITEDthenFULLas you gain confidence
- Scheduled Execution: Apps Script triggers run automatically twice daily
- Email Retrieval: Fetches unread emails from your inbox
- AI Classification: Gemini analyzes each email's content and context
- Category Assignment: Emails are tagged with appropriate categories
- Summary Generation: Creates intelligent summaries grouped by category
- Archive Processing: Applies category-specific archiving rules
- Report Delivery: Sends summary email with actionable insights
- Complex interdependencies: Adding a category requires updating:
- The AI classification prompt
- Label creation logic
- Archiving rules
- Summary generation templates
- Consistency: AI ensures all related code sections stay synchronized
- Error prevention: Reduces risk of breaking the script with incomplete changes
Tell your AI assistant what you want to change:
Adding Categories: "Add a 'Travel' category for flight confirmations and hotel bookings"
Modifying Archiving: "Archive financial emails after 30 days instead of keeping them"
Summary Changes: "Make newsletter summaries shorter, only 1-2 sentences"
Label Adjustments: "Change label colors - make Urgent red and To Do orange"
If you prefer manual editing, key sections to modify:
- Classification prompt (around line 200+)
- Label definitions and colors
- Archiving logic in
processEmailsDaily() - HTML templates in summary generation
Contributions welcome! Please read our contributing guidelines and submit pull requests for any improvements.
MIT License - see LICENSE file for details.
- Google Apps Script team for the robust automation platform
- Gemini AI for intelligent email classification
- Claude Code for development assistance and code optimization
Ready to reclaim your inbox? β Star this repo if it helped organize your email chaos!
