📬 AI-Powered Email & Focus for Chrome
Inboxes are overloaded. Promotions and newsletters compete with what actually matters. At the same time, staying focused is harder than ever—tabs, notifications, and context-switching fragment attention.
Traditional approaches fall short because:
- Manual filters and labels don’t scale
- Unsubscribing is tedious and scattered across senders
- Focus tools are either too rigid or easy to ignore
Decluttr is a Chrome extension that combines an AI-powered email assistant with focus mode. It connects to Gmail, uses AI for summaries and categorization, helps you manage promotions and unsubscribe in one place, and adds face-based focus tracking so you stay on task.
Think of it as “Inbox + Focus in one place”:
- Gmail integration with OAuth 2.0
- AI-powered summaries, category suggestions (Primary / Promotions), and unsubscribe detection
- Manage Promotions: pick senders, then Open in Gmail (use Gmail’s Unsubscribe) or Unsubscribe & optionally trash
- Primary vs Promotions tabs; load more, process with AI, view details
- Process individual emails for summary, category, and unsubscribe detection
- Optional auto-categorize on load
- Backend uses OpenAI for analysis
- Visualize email flow and pipeline (e.g. Primary vs Promotions) with D3.js Sankey diagrams
- Face detection and focus tracking (MediaPipe / TensorFlow, face landmarker, WASM)
- Distraction overlay and focus sessions to keep you on task
- Placeholder for future LinkedIn-related features
- Extension: You use Email Assistant or Focus from the extension popup/pages.
- Backend: Email and AI requests go to the Node/Express server (OpenAI, SerpAPI for LinkedIn, etc.).
- Gmail: OAuth and Gmail API fetch mail; AI summarizes and classifies; you manage promotions and unsubscribe.
- Focus: Face detection runs in the extension; focus overlay and logic run when Focus mode is on.
| Layer | Technology |
|---|---|
| Extension | Chrome Manifest V3, vanilla JavaScript, HTML, CSS |
| Backend | Node.js, Express.js, OpenAI API, SerpAPI |
| Gmail API, OAuth 2.0, D3.js (Sankey diagram) | |
| Focus | MediaPipe / TensorFlow (face landmarker, WASM) |
- Node.js 18+
- Chrome browser
- OpenAI API key (for AI summaries)
- SerpAPI key (optional; for LinkedIn automatic search summaries)
- Google Cloud project with Gmail API and OAuth 2.0 client (for Gmail)
cd Chrome_Extension/backend
npm install
cp .env.example .envSet in .env:
OPENAI_API_KEY— required for AI summariesSERPAPI_KEY— required for LinkedIn search summaries (if used)
Start the server:
npm startDefault: http://localhost:3000. See Chrome_Extension/backend/README.md for API details.
-
Google Cloud: Gmail API and OAuth
- In Google Cloud Console: create or select a project.
- Enable Gmail API (APIs & Services → Library → search “Gmail API” → Enable).
- Create OAuth 2.0 Client ID: APIs & Services → Credentials → Create Credentials → OAuth client ID.
- Application type: Chrome app (or Web application). For Chrome app, use your extension ID (see step 2).
- Authorized redirect URIs: Load the extension once, then open it → Settings → Developer options → copy the Redirect URI. Add that exact URI to your OAuth client’s “Authorized redirect URIs”. Add the same URI to each client if you use multiple (e.g. for testers).
- Copy the Client ID into
Chrome_Extension/manifest.jsonunderoauth2.client_id.
-
Load the extension
- Chrome →
chrome://extensions/→ turn on Developer mode → Load unpacked → select theChrome_Extensionfolder. - The manifest uses a fixed
keyso the extension ID (and redirect URI) stay the same across reloads. Use the redirect URI from Settings → Developer options when configuring OAuth.
- Chrome →
-
Optional: Backend URL
- Extension → Settings (gear) → Developer options → set Backend URL if the backend is not at
http://localhost:3000→ Save.
- Extension → Settings (gear) → Developer options → set Backend URL if the backend is not at
-
Connect Gmail
- Open the extension → Email Assistant → Connect Gmail → sign in and allow access. Only the OAuth client owner needs to add the redirect URI; testers can connect once it’s set.
- Open the Decluttr icon → Email Assistant.
- Use Primary and Promotions tabs to filter by Gmail category.
- Load More fetches the next page of emails (batch size is configurable).
- Process with AI on an email: summary, category, and unsubscribe detection.
- View Details opens the full email and AI analysis.
- Manage Promotions (when on Promotions): select senders, then Open in Gmail (Gmail’s Unsubscribe) and/or Unsubscribe & optionally trash (extension attempt + optional move to trash).
- Refresh reloads the inbox.
- Account: Log out from Gmail.
- Appearance: Theme (Light / Dark / System).
- Behavior: Auto-categorize emails on load (toggle).
- Developer options (collapsed): Backend URL, Redirect URI (for OAuth). Copy the Redirect URI and add it to your OAuth client(s) in Google Cloud Console so Connect Gmail works.
- Backend: Ensure the backend is running and the Backend URL in Settings → Developer options is correct. CORS must allow the extension origin.
- Gmail / OAuth: For “redirect_uri_mismatch” or “Access blocked: This app’s request is invalid”, add the exact Redirect URI from Settings → Developer options to your OAuth client’s Authorized redirect URIs in Google Cloud Console. If you use multiple OAuth clients, add the same URI to each.
- AI errors: Check
OPENAI_API_KEYin backend.envand backend logs for details.
Chrome_Extension/
├── backend/
│ ├── routes/ # email, linkedin API routes
│ ├── features/linkedin/ # LinkedIn AI service
│ ├── utils/ # openai etc.
│ └── server.js
├── features/
│ ├── email/ # Email Assistant (Gmail, AI, Sankey, Unsubscribe)
│ │ ├── controllers/
│ │ ├── services/
│ │ ├── repositories/
│ │ └── lib/ # d3, sankey
│ ├── focus/ # Focus mode (face detection, overlay)
│ │ └── lib/ # MediaPipe / TensorFlow WASM
│ └── linkedin/ # LinkedIn UI & theme
├── popup/ # Extension popup (App.js, App.html, App.css)
├── utils/ # theme, shared utilities
└── manifest.json
MIT License — see LICENSE for details.