Gmail Lead Desk (gmail-lead-desk) 📧
Gmail Lead Desk — standalone sales and customer-support Gmail workflows via the AISA gateway.
One skill: connect Gmail, run whitelisted tools, triage inbox, draft replies, archive deals — no other skill required.
Quick start
export AISA_API_KEY="your-key" # get at https://aisa.one
Pre-flight checks (do first, stop if fails):
AISA_API_KEY is set — if not, ask the user to set it before any API call.
user_id is known — use the Gmail address the user provides. If not yet known, ask: "What Gmail address should I use as your identity?"
- Gmail is
ACTIVE — run Workflow 0 if connected_account_id is missing or not ACTIVE.
- Base URL:
https://api.aisa.one
- Auth:
Authorization: Bearer $AISA_API_KEY
- Windows: use
curl.exe
OAuth and tools/execute: references/connect_and_execute.md
When to use
- Connect or reconnect Gmail via OAuth
- Scan unread leads needing follow-up
- Summarize inquiry/support threads (CRM format)
- Draft replies from sales templates (default: do not send)
- Archive won deals with labels
- User mentions: unanswered, follow-up, inquiry, quote, draft, archive, lead, connect Gmail
When NOT to use
- Non-Gmail apps (Slack, GitHub, etc.) — out of scope
- Proactive new-mail automation — not MVP; see
references/workflows.md § Future
- Bulk permanent delete, filter creation — disabled unless user explicitly requests
Intent → Workflow Quick Reference
| User intent |
Workflow |
Reference |
| Connect Gmail / OAuth / authorize |
0 Connect Gmail |
references/connect_and_execute.md |
| Unanswered / follow-up / unread |
A Unread lead scan |
references/workflows.md § A |
| Summarize / summary / summarize thread |
B Thread summary |
references/workflows.md § B |
| Reply for me / draft reply / write email |
C Draft (no send) |
references/workflows.md § C |
| Confirm send / send now |
C-send Send after confirm |
references/workflows.md § C-send |
| Archive / deal closed |
D Label and archive |
references/workflows.md § D |
Run Workflow 0 first if Gmail is not connected (ACTIVE connected_account_id).
Workflow 0 — Connect Gmail (summary)
GET /auth_configs?toolkit_slug=gmail → auth_config_id
GET /connected_accounts?toolkit_slugs=gmail&user_ids={user_id} — reuse ACTIVE if present
- Else confirm, then
POST /connected_accounts/link → user opens redirect_url
- Poll every 3–5 s until
status is ACTIVE; save connected_account_id
- Timeout after ~2 min (24 polls): stop polling, tell user "OAuth not completed — please try again or check the browser tab."
DISCONNECTED / REVOKED: re-run from step 3.
Full steps: references/connect_and_execute.md
Core Workflows (summary)
A — Unread lead scan
- Resolve
connected_account_id (Workflow 0).
GMAIL_FETCH_EMAILS with sales default query — see workflows.md.
- Table: Sender | Subject | Days waiting | thread_id | Suggested action.
- Do not send at end of this workflow.
B — Thread summary (CRM-ready)
GMAIL_FETCH_MESSAGE_BY_THREAD_ID; sort by internalDate.
- Fixed sections: customer, need, budget/timeline, next action, attachments (unverified when inferred).
C — Template draft (default: no send)
- Load thread (B); confirm recipient, tone, quote/link.
GMAIL_REPLY_TO_THREAD or GMAIL_CREATE_EMAIL_DRAFT; empty subject when thread_id set.
- Return
draft_id + preview.
C-send — Send only on explicit request
- User says send / confirm send / send now.
- Show full To/Cc/subject/body; confirm; then
GMAIL_SEND_DRAFT or GMAIL_SEND_EMAIL.
D — Archive and label
GMAIL_LIST_LABELS → Label_* IDs only.
GMAIL_CREATE_LABEL if needed (confirm).
- Sample ≤5
messageIds + count → GMAIL_BATCH_MODIFY_MESSAGES.
Never guess tool_slug. Whitelist: references/tool_whitelist.md.
Safety
| Action |
Rule |
| Default after A/B/C |
Draft only — no auto-send |
| OAuth link / create auth config |
Confirm with user |
| Create draft |
Confirm recipient and thread |
| Send |
Explicit user request + show To/Cc |
| Batch label/archive |
≤5 sample IDs + total count |
| Batch delete / filters |
Refuse in MVP unless explicit cleanup request |
| Privacy |
No uploading full mailbox externally; attachments need consent |
| Rate limits |
Concurrency ≤10; backoff on 429 |
Gmail pitfalls: references/gmail_gotchas.md.
Reference routing
| Need |
File |
| API key, OAuth, execute |
references/connect_and_execute.md |
| Sales workflows A–D |
references/workflows.md |
| message_id, labels, drafts |
references/gmail_gotchas.md |
| Allowed tool slugs |
references/tool_whitelist.md |
Lookup order: intent → Workflow 0 if needed → workflows.md → tool_whitelist.md → GET /tools/{tool_slug} → POST /tools/execute/{tool_slug}.
Troubleshooting
| Symptom |
Action |
AISA_API_KEY not set |
Ask user to run export AISA_API_KEY="..." before any API call |
user_id unknown |
Ask "What Gmail address should I use as your identity?" |
| No Gmail connection |
Workflow 0 in connect_and_execute.md |
| OAuth poll timeout (>2 min) |
Tell user to check browser tab; re-run Workflow 0 step 3 |
Invalid id value |
See gmail_gotchas.md |
| Label not applied |
Used display name — GMAIL_LIST_LABELS for id |
| New thread on reply |
Subject set on draft — leave subject empty |
successful: false |
connect_and_execute.md §4 + re-fetch tool schema |
Deprecated GMAIL_LIST_MESSAGES |
Use GMAIL_FETCH_EMAILS |
1---2name: gmail-lead-desk-33description: Gmail Lead Desk — standalone sales/CS Gmail skill via the AISA gateway: OAuth connect, scan unread leads, summarize threads, draft template replies (default draft-only), archive with labels. Keywords: Gmail Lead Desk, Gmail, lead desk, sales, customer support, follow-up, unread, inquiry summary, draft reply, archive, OAuth, AISA, connected account, thread_id. Use when: the user needs this workflow's domain-specific automation or guidance.4license: MIT5---67# Gmail Lead Desk (`gmail-lead-desk`) 📧89**Gmail Lead Desk** — standalone sales and customer-support Gmail workflows via the AISA gateway.1011One skill: connect Gmail, run whitelisted tools, triage inbox, draft replies, archive deals — no other skill required.1213## Quick start1415```bash16export AISA_API_KEY="your-key" # get at https://aisa.one17```1819> **Pre-flight checks (do first, stop if fails):**20> 1. `AISA_API_KEY` is set — if not, ask the user to set it before any API call.21> 2. `user_id` is known — use the Gmail address the user provides. If not yet known, ask: "What Gmail address should I use as your identity?"22> 3. Gmail is `ACTIVE` — run Workflow 0 if `connected_account_id` is missing or not `ACTIVE`.2324- **Base URL:** `https://api.aisa.one`25- **Auth:** `Authorization: Bearer $AISA_API_KEY`26- **Windows:** use `curl.exe`2728OAuth and `tools/execute`: [`references/connect_and_execute.md`](./references/connect_and_execute.md)2930## When to use3132- Connect or reconnect **Gmail** via OAuth33- Scan **unread leads** needing follow-up34- **Summarize** inquiry/support threads (CRM format)35- **Draft** replies from sales templates (default: do not send)36- **Archive** won deals with labels37- User mentions: unanswered, follow-up, inquiry, quote, draft, archive, lead, connect Gmail3839## When NOT to use4041- Non-Gmail apps (Slack, GitHub, etc.) — out of scope42- Proactive new-mail automation — not MVP; see `references/workflows.md` § Future43- Bulk permanent delete, filter creation — disabled unless user explicitly requests4445## Intent → Workflow Quick Reference4647| User intent | Workflow | Reference |48|-------------|----------|-----------|49| Connect Gmail / OAuth / authorize | **0** Connect Gmail | `references/connect_and_execute.md` |50| Unanswered / follow-up / unread | **A** Unread lead scan | `references/workflows.md` § A |51| Summarize / summary / summarize thread | **B** Thread summary | `references/workflows.md` § B |52| Reply for me / draft reply / write email | **C** Draft (no send) | `references/workflows.md` § C |53| Confirm send / send now | **C-send** Send after confirm | `references/workflows.md` § C-send |54| Archive / deal closed | **D** Label and archive | `references/workflows.md` § D |5556> Run **Workflow 0** first if Gmail is not connected (`ACTIVE` `connected_account_id`).5758---5960## Workflow 0 — Connect Gmail (summary)61621. `GET /auth_configs?toolkit_slug=gmail` → `auth_config_id`632. `GET /connected_accounts?toolkit_slugs=gmail&user_ids={user_id}` — reuse `ACTIVE` if present643. Else **confirm**, then `POST /connected_accounts/link` → user opens `redirect_url`654. Poll every 3–5 s until `status` is `ACTIVE`; save `connected_account_id`66 - **Timeout after ~2 min (24 polls):** stop polling, tell user "OAuth not completed — please try again or check the browser tab."67 - `DISCONNECTED` / `REVOKED`: re-run from step 3.6869Full steps: [`references/connect_and_execute.md`](./references/connect_and_execute.md)7071---7273## Core Workflows (summary)7475### A — Unread lead scan76771. Resolve `connected_account_id` (Workflow 0).782. `GMAIL_FETCH_EMAILS` with sales default query — see `workflows.md`.793. Table: **Sender | Subject | Days waiting | thread_id | Suggested action**.804. **Do not send** at end of this workflow.8182### B — Thread summary (CRM-ready)83841. `GMAIL_FETCH_MESSAGE_BY_THREAD_ID`; sort by `internalDate`.852. Fixed sections: customer, need, budget/timeline, next action, attachments (**unverified** when inferred).8687### C — Template draft (default: no send)88891. Load thread (B); confirm recipient, tone, quote/link.902. `GMAIL_REPLY_TO_THREAD` or `GMAIL_CREATE_EMAIL_DRAFT`; **empty subject** when `thread_id` set.913. Return `draft_id` + preview.9293### C-send — Send only on explicit request9495- User says **send / confirm send / send now**.96- Show full To/Cc/subject/body; confirm; then `GMAIL_SEND_DRAFT` or `GMAIL_SEND_EMAIL`.9798### D — Archive and label991001. `GMAIL_LIST_LABELS` → `Label_*` IDs only.1012. `GMAIL_CREATE_LABEL` if needed (confirm).1023. Sample ≤5 `messageIds` + count → `GMAIL_BATCH_MODIFY_MESSAGES`.103104**Never guess `tool_slug`.** Whitelist: [`references/tool_whitelist.md`](./references/tool_whitelist.md).105106---107108## Safety109110| Action | Rule |111|--------|------|112| Default after A/B/C | **Draft only** — no auto-send |113| OAuth link / create auth config | Confirm with user |114| Create draft | Confirm recipient and thread |115| Send | Explicit user request + show To/Cc |116| Batch label/archive | ≤5 sample IDs + total count |117| Batch delete / filters | **Refuse** in MVP unless explicit cleanup request |118| Privacy | No uploading full mailbox externally; attachments need consent |119| Rate limits | Concurrency ≤10; backoff on 429 |120121Gmail pitfalls: [`references/gmail_gotchas.md`](./references/gmail_gotchas.md).122123---124125## Reference routing126127| Need | File |128|------|------|129| API key, OAuth, execute | `references/connect_and_execute.md` |130| Sales workflows A–D | `references/workflows.md` |131| message_id, labels, drafts | `references/gmail_gotchas.md` |132| Allowed tool slugs | `references/tool_whitelist.md` |133134**Lookup order:** intent → Workflow 0 if needed → `workflows.md` → `tool_whitelist.md` → `GET /tools/{tool_slug}` → `POST /tools/execute/{tool_slug}`.135136---137138## Troubleshooting139140| Symptom | Action |141|---------|--------|142| `AISA_API_KEY` not set | Ask user to run `export AISA_API_KEY="..."` before any API call |143| `user_id` unknown | Ask "What Gmail address should I use as your identity?" |144| No Gmail connection | Workflow 0 in `connect_and_execute.md` |145| OAuth poll timeout (>2 min) | Tell user to check browser tab; re-run Workflow 0 step 3 |146| `Invalid id value` | See `gmail_gotchas.md` |147| Label not applied | Used display name — `GMAIL_LIST_LABELS` for `id` |148| New thread on reply | Subject set on draft — leave subject empty |149| `successful: false` | `connect_and_execute.md` §4 + re-fetch tool schema |150| Deprecated `GMAIL_LIST_MESSAGES` | Use `GMAIL_FETCH_EMAILS` |