Skip to content

About

Gmail add-on showing sender history, label suggestions, and bulk label/archive actions inside Gmail, backed by a Google Sheet cache. Google Apps Script (CardService), clasp-managed.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gmail Sender Insights

A Google Apps Script Gmail add-on that shows sender intelligence inside Gmail: when you open a message, it summarizes everything from that sender, suggests labels based on how you've categorized their mail before, and lets you act on one thread or all of their threads at once. A Google Sheet backs it as a cache and a log store.

CI License: MIT

What you see in Gmail

  • Sender stats — total threads from the sender, inbox vs. archived split, and the labels most used on their mail, with a 24-hour Sheet cache so repeat views don't re-scan Gmail.
  • Label suggestions — the sender's most frequent labels as one-tap buttons, for the open thread or for all of their threads.
  • Quick actions — archive / mark read for this thread, or Archive Inbox / mark-all-read for the sender (capped, with the scope and cap stated in the confirmation dialog).
  • Homepage dashboard — inbox, priority, drafts, spam, starred, and label counts, plus tools to export labels and archive old logs.
  • Deep scan — a "Load Full Stats" button re-scans past the standard 50-thread cap, up to 500.

No screenshot is included: a real one would show a real mailbox, and a faked one would misrepresent the add-on. The setup below gets you a live copy in a few minutes.

Quick start

Prerequisites: a Google account, Node.js 20+, and the Apps Script API enabled at https://script.google.com/home/usersettings.

npm install -g @google/clasp@3.4.1
git clone https://github.com/enonymous1/gmail-sender-insights.git
cd gmail-sender-insights
clasp login

Then create the Apps Script project and its backing sheet:

clasp create --title "Gmail Sender Insights" --type standalone
cp .clasp.json.example .clasp.json
# paste the Script ID clasp printed into .clasp.json
  1. Create a blank Google Sheet (this will hold the cache and logs). Copy its ID from the sheet URL.
  2. In the Apps Script editor, go to Project Settings → Script Properties and add SPREADSHEET_ID with that ID. Or run setSpreadsheetId("...") once in the editor.
  3. Push and open the editor:
clasp push
clasp open
  1. In the editor, run Deploy → Test deployments → Gmail add-on and install the test deployment in Gmail. Open any message to see the sender card, and authorize the scopes listed below when prompted.

The tabs (SystemLogs, SenderCache, Labels, Messages, Threads) are created automatically on first use. The spreadsheet ID lives only in Script Properties — never in this repo — so each install points at its own sheet.

Why each scope is needed

Scope Used for
gmail.addons.execute, gmail.addons.current.message.action Add-on triggers and the open message
gmail.readonly Reading messages, threads, and labels
gmail.modify Applying labels, archiving, marking read
spreadsheets Cache, logs, label exports, and message templates (read and write)
script.locale Locale-aware formatting
userinfo.email Greeting and homepage header

How it works

Gmail open-message trigger (onGmailMessageOpen)
  → createMessageData() extracts the message + thread once
  → getSenderStats() checks the SenderCache sheet (24 h), else GmailApp.search()
  → CardService builds the sender card (stats, labels, actions, recent mail)
Homepage trigger (onHomepage)
  → buildHomepageCard() — account stats, label-sync status, tools
Every action and cache hit/miss is logged to SystemLogs (capped at 10,000 rows).

Key limits, stated plainly: thread counts are capped (50 standard, 500 deep scan) and a capped count is shown with a +; the sender cache is trusted for 24 hours, so a brand-new label may not appear until a deep scan; Gmail add-on executions have a short timeout, so a deep scan over a very large mailbox can time out — the cached result from a previous scan still shows.

Configuration and customization
  • Cache and caps — CONFIG in Config.js: CACHE_DURATION_MS, DEFAULT_THREAD_CAP (50), DEEP_SCAN_THREAD_CAP (500), MAX_LOG_ENTRIES (10,000), feature flags.
  • Welcome messages and footer — edit the Messages sheet. Rows with type="system" are the built-ins (welcome_messages, holiday_messages, homepage_title, footer_text, time_based_messages); rows with type="custom" are read by getCustomMessage(key). Changes are picked up within the 5-minute message cache.
  • Display name — setUserDisplayName("...") stores a greeting name in user properties; clearUserDisplayName() reverts to the email-derived name.
Project layout

Flat .js files at the repo root, because Apps Script loads them all into one shared global scope (see docs/REFERENCE.md for the module map). appsscript.json is the manifest. tests/ runs the add-on under Node with fakes for the Apps Script services — no Google account needed for npm test. scripts/checks.js is the duplicate-function and identifier guard that also runs in CI.

*.js               Add-on source (19 files, one shared scope)
appsscript.json    Manifest: triggers, scopes, add-on metadata
.clasp.json.example  Template binding — copy to .clasp.json (never committed)
tests/             Node test harness + fakes (node:test, no dependencies)
scripts/checks.js  Syntax, duplicate-definition, and identifier guards
docs/              Workflow guide and module reference

Development

npm run check   # node --check, duplicate-function and identifier guards
npm test        # 36 tests: config, parsing, cache, sheets, homepage, guards, bulk confirmation, privacy

What the tests cover, and what they don't: every pure-logic path runs against in-memory fakes, including the duplicate-definition guard that would have caught the v1 shadowing bugs. A live Gmail run is still the gate for the real thing — clasp push plus a Gmail test deployment, checking the sender card, a bulk action, and the Sheet tabs. That live run was not done for this export (no Google account is connected here); see CHANGELOG for the full v2.0.0 list.

Troubleshooting

  • "No spreadsheet configured" card — set the SPREADSHEET_ID script property (see Quick start). The add-on reads nothing from Config.js for this anymore.
  • Re-authorize after changing scopes — scopes are unchanged from v1, so upgrading an existing deployment needs only a new deployment, not new authorization. If you edit appsscript.json scopes, re-authorize on next use.
  • Stale sender stats — use Load Full Stats (Deep Scan), or clear that sender's row in SenderCache.
  • clasp push says the manifest changed — run clasp pull first, resolve, then push again (see docs/WORKFLOW.md).

License

MIT — see LICENSE.

About

Gmail add-on showing sender history, label suggestions, and bulk label/archive actions inside Gmail, backed by a Google Sheet cache. Google Apps Script (CardService), clasp-managed.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages