Skip to main content
ClaudeWave
Skill313 estrellas del repoactualizado 2d ago

customer-email-assist

Customer Email Assist optimizes Gmail support ticket handling by using Codex Gmail connectors to fetch emails, clean and queue them in SQLite, and apply deterministic processing for classification before reserving model calls only for JSON-based message understanding and draft field generation. Use this when implementing connector-first support workflows that minimize token consumption through separation of deterministic operations (parsing, cleaning, matching) from language model operations.

Instalar en Claude Code
Copiar
git clone --depth 1 https://github.com/Prompthon-IO/agent-systems-handbook /tmp/customer-email-assist && cp -r /tmp/customer-email-assist/zh-Hans/case-studies/examples/customer-email-assist-starter/skill ~/.claude/skills/customer-email-assist
Después abre una sesión nueva de Claude Code; el skill carga automáticamente.

SKILL.md

# Customer Email Assist

使用这个技能来操作 `customer-email-assist-starter` 示例,并尽量减少
模型 token 消耗。

## 必需的运行时输入

- `CUSTOMER_EMAIL_ASSIST_POLICY_PATH`
- 可选 `CUSTOMER_EMAIL_ASSIST_DB_PATH`

正常工作流中的 Gmail 认证应通过 Codex Gmail connector 完成。不要要求用户
为了常规使用配置本地 Google OAuth 环境变量。

## 硬性规则

只在以下两种场景使用模型 token:

1. 理解清洗后的客户邮件内容
2. 生成回复模板字段 JSON

不要把模型调用用于 Gmail 抓取、HTML 清理、引用历史移除、签名裁剪、
客户匹配、SQLite 写入、分析统计、过滤、分页或发送队列执行。

## 确定性命令

相对于该入门项目目录解析路径。

```bash
npm run setup-local
tsx scripts/customer-email-assist.ts import-prepared-batch --input /tmp/prepared-inbound.json
tsx scripts/customer-email-assist.ts persist-understanding --input /tmp/understanding.json
tsx scripts/customer-email-assist.ts prepare-draft-batch --policy "$CUSTOMER_EMAIL_ASSIST_POLICY_PATH" --out /tmp/draft-batch.json
tsx scripts/customer-email-assist.ts render-save-drafts --input /tmp/draft-fields.json
```

## 工作流

1. 使用 Codex Gmail connector 搜索邮箱。
   - 优先使用窄查询,例如 `newer_than:1d -in:spam -in:trash -category:promotions`。
   - 只读取入选的客户来信内容。
   - 每个批次最多保留四条清洗后的来信。
2. 构建 `/tmp/prepared-inbound.json`,格式为 `PreparedInboundItem[]`。
   - 只包含 `gmailThreadId`、`gmailLastInboundMessageId`、`subject`、
     `cleanBody`、`receivedAt` 和 customer 字段。
   - 如果本地数据库已知道某个客户是 ignored,则跳过。
3. 运行 `import-prepared-batch --input <file>`。
   - 这会写入 SQLite issue,并用确定性兜底模板生成草稿,不需要本地 Gmail OAuth。
4. 只有当硬逻辑不够时,才使用模型执行 `understand`。
   - 只读取 JSON 批次输出。
   - 只返回 JSON。
   - 每条记录字段:
     - `gmailThreadId`
     - `gmailLastInboundMessageId`
     - `customerEmail`
     - `customerName`
     - `subject`
     - `receivedAt`
     - `originalMessageText`
     - `classification`
     - `summary`
     - `urgency`
     - `actionSuggestion`
5. 如果使用了模型输出,保存该 JSON,并运行 `persist-understanding --input <file>`。
6. 运行 `prepare-draft-batch --policy <file>`。
   - 这一步每个 issue 只提取少量政策证据行。
7. 只有当兜底模板不够时,才使用模型执行 `draft-fields`。
   - 只读取草稿批次 JSON。
   - 只返回 JSON。
   - 每条记录字段:
     - `issueId`
     - `classification`
     - `draftFields.customerName`
     - `draftFields.acknowledgement`
     - `draftFields.nextStep`
     - `draftFields.policyEvidence`
     - `draftFields.signoff`
8. 保存该 JSON,并运行 `render-save-drafts --input <file>`。
9. 在 dashboard 中让用户编辑已渲染的草稿、通过带 undo 倒计时的方式批准
   发送、对仍在排队的回复取消批准、标记完成、批准待审核客户、忽略客户,
   或更新客户描述。
10. 对于 connector 模式下仍处于 `approved_to_send` 的 issue,使用 Codex
    Gmail connector 创建或发送回复,然后把 issue 标记为 resolved。

## 高级本地 OAuth Adapter

仓库仍保留直接 Gmail API adapter,供明确需要 standalone local integration
的团队使用。它属于高级路径,不应作为默认设置展示。

高级变量:
- `CUSTOMER_EMAIL_ASSIST_GMAIL_LABEL`
- `GOOGLE_CLIENT_ID`
- `GOOGLE_CLIENT_SECRET`
- `CUSTOMER_EMAIL_ASSIST_OPERATOR_EMAIL`
- `GOOGLE_REDIRECT_URI`

dashboard 的 `Connect Gmail` 按钮会在 Google consent callback 之后把
refresh token 写入本地状态。`GOOGLE_REFRESH_TOKEN` 仍可作为手动兜底变量,
但不是 web-app 流程必需项。

高级命令:

```bash
npm run sync:oauth
tsx scripts/customer-email-assist.ts prepare-inbound-batch --out /tmp/prepared-inbound.json
tsx scripts/customer-email-assist.ts apply-send-queue
```

当这个高级本地 OAuth 路径已连接时,dashboard 的 `Approve & Send` 动作会在
undo 倒计时结束后立即执行确定性的发送路径。没有 OAuth 连接时,dashboard
会把 issue 保持在 `approved_to_send`,而不是尝试未认证的发送。

## 保护措施

- 保持模型输入短小。不要发送完整线程历史。
- 不要把原始政策文档发送给模型;只发送 `prepare-draft-batch` 选出的
  政策证据行。
- 除非用户明确编辑并批准最终回复,否则不要把 `handoff_required`
  案例放进自动发送路径。
- 对被 ignored 的客户,后续同步运行中应视为不可操作。
local-customer-email-replySkill

审阅客户来信,以本地政策或 FAQ 文档为依据起草安全的投诉和咨询回复。

agent-runtime-cache-benchmarkSkill

Compare two structured agent-run artifacts to estimate cache efficiency, explain likely cache breaks, and produce a local benchmark report. Use when a user wants to understand whether a prompt layout, tool manifest, or history shape is helping or hurting prompt-cache reuse.

daily-news-watcherSkill

Persistent daily news monitoring backed by local SQLite and Markdown reports. Use when a user asks Codex to track named publications, fetch the last N hours of news, summarize recent articles by topic, deduplicate articles across runs, or maintain a personal newsroom that survives across sessions.

garbage-collectorSkill

Scan local cleanup targets, apply readable cleanup rules, produce a preview report, and execute approved cleanup actions with logs. Use when a user asks Codex to clean up their computer, empty old Trash items, find duplicated Downloads files, review local storage clutter, or propose safe file cleanup actions before making changes.

local-document-organizerSkill

Preview-first local file organizer. Scan a user-named folder, classify files into category subfolders using readable rules, write a preview Markdown report and JSON plan, execute confirmed moves with persistent SQLite state, and reverse moves with undo. Use when a user asks Codex to organize Downloads, sort a messy folder into Invoices/Receipts/School/Images/Software/PDFs subfolders, propose a folder structure before moving anything, or undo a previous organization run.

personal-knowledge-captureSkill

Capture local or explicitly provided web knowledge sources into cited Markdown notes. Use when a user asks Codex to watch a research folder, register local folders for later scans, summarize new or modified local Markdown/TXT/PDF/DOCX files, capture a provided URL, maintain SQLite state for personal knowledge capture, or generate searchable source-grounded daily notes.

price-watcherSkill

Persistent product price tracking for natural-language product requests. Use when a user asks to watch, track, monitor, compare, or report prices for a product, especially with a target price or threshold such as "Watch MacBook Pro M3 14-inch and tell me if it drops below $1200." Supports source discovery, Playwright/browser product checks, SQLite history, threshold comparison, and Markdown price reports.

prompt-cache-agent-harnessSkill

Plan and inspect prompt-cache behavior for long-running Claude agent loops. Use when a user wants to split stable tool, system, and history context into cacheable layers, compare captured cache metadata, estimate cost impact from supplied pricing inputs, or keep durable memory outside the cached prefix.