Gmail Labeler
A production-oriented Gmail labeling workflow built around:
- -
gog for Gmail access - a local overlay for private rules/accounts/routes
- a hybrid review flow: heuristics first, lightweight LLM review for ambiguity-band messages
- a 15-minute cron-friendly runner
What it does
- - Classifies inbox items into non-actionable vs actionable buckets
- Applies Gmail labels and archives non-actionable mail
- Keeps replies, opportunities, urgent billing items, and other actionable mail in Inbox
- Supports English, Portuguese, and Spanish keyword coverage out of the box
- Logs every decision to JSONL for auditability and tuning
- Purges logs older than 30 days
- Supports a daily self-improvement review loop based on prior decisions and user corrections
Default categories
Non-actionable
- - Newsletters
- Promotions
- Notifications
- Ordinary receipts
Actionable
- - Billing issues
- Replies
- Opportunities
- Action Required
What stays local/private
Keep user-specific editorial, business, or inbox-policy rules in the local overlay, not in the shared skill defaults.
Examples of local-only rules:
- - PR / press release handling
- press trip or media invitation routing
- VIP sender policies
- business-specific labels
- custom notification routes
Operating model
1. Sender-type-first routing
Classify sender as:
- - INLINECODE1
- INLINECODE2
- INLINECODE3
This keeps bulk automated mail cheap to classify and reserves deeper review for ambiguous or human-origin messages.
2. Inbox-by-exception policy
Treat Inbox as an
action queue, not a reading queue.
Recommended default:
- - processed mail always gets INLINECODE4
- mail stays in Inbox only when it is clearly actionable / important
- everything else should leave Inbox, even when the category is still somewhat generic
Practical effect:
- - important/actionable mail → keep in Inbox and add category labels when possible
- non-important mail → remove
INBOX, keep Auto/Triaged, then add a best-fit category label (Notification, Newsletter, Receipt, Press Releases, etc.)
3. Confidence-band review
Use heuristics first.
Then send only ambiguity-band messages to a lightweight LLM review.
Recommended pattern:
- - high confidence → trust heuristics
- medium confidence → LLM review
- low confidence → conservative fallback
4. Conservative-but-useful fallback
If a message is clearly automated/company-origin but no specific filter matches, prefer a generic non-actionable classification (for example
Notification) over leaving it untouched in Inbox.
5. Label normalization
Use a small canonical label set and avoid near-duplicates caused by translation, singular/plural, or typos.
Example normalization targets:
- -
Press Release → INLINECODE13 - finance label variants → one canonical finance label
- keep
Auto/Triaged as the universal processed marker
Gmail-native labels to prefer
Use Gmail system labels when possible:
- - INLINECODE15
- INLINECODE16
- INLINECODE17
- INLINECODE18
- INLINECODE19
Create custom labels only when needed, for example:
- - INLINECODE20
- INLINECODE21
- INLINECODE22
- INLINECODE23
- INLINECODE24
- INLINECODE25
Local overlay design
Keep the skill publishable by storing private configuration outside the skill directory.
Recommended local overlay path:
CODEBLOCK0
Store private values only in the local overlay:
- - email accounts
- VIP senders/domains
- notification targets
- business-specific opportunity rules
- personal/custom labels
Logging and review
Decision logs should live outside the skill source tree, for example:
CODEBLOCK1
Recommended format:
- - one JSONL file per day
- one row per decision
- separate error rows
Suggested daily review inputs:
- - yesterday's decision log
- false positives / false negatives
- over-aggressive archiving
- missed billing urgency
- missed opportunities
- user-requested corrections
Files to read
- - INLINECODE26
- INLINECODE27
- INLINECODE28
- INLINECODE29
- INLINECODE30
- INLINECODE31
- INLINECODE32
- INLINECODE33
Runners
- - Main runner: INLINECODE34
- Launcher example: INLINECODE35
Publishing guidance
Before publishing:
- - keep only generic defaults in the skill
- remove personal accounts, chat ids, private domains, and custom user rules
- keep examples generic
- document clearly that private configuration belongs in the local overlay
- keep PR / press-release handling user-specific when it reflects private editorial policy; do not publish those local heuristics by default
- validate cron/non-interactive execution via the launcher, not only via direct Python invocation
Gmail 标签器
一个面向生产的 Gmail 标签工作流程,围绕以下组件构建:
- - 使用 gog 进行 Gmail 访问
- 本地覆盖层用于私有规则/账户/路由
- 混合审核流程:先使用启发式规则,对模糊消息进行轻量级 LLM 审核
- 15 分钟周期的 cron 友好运行器
功能说明
- - 将收件箱邮件分类为非 actionable 和 actionable 两类
- 应用 Gmail 标签并将非 actionable 邮件归档
- 将回复、商机、紧急账单项目及其他 actionable 邮件保留在收件箱中
- 开箱即支持英语、葡萄牙语和西班牙语关键词覆盖
- 将每条决策记录为 JSONL 格式,便于审计和调优
- 清除超过 30 天的日志
- 支持基于先前决策和用户更正的每日自我改进审核循环
默认分类
非 actionable
Actionable
本地/私有内容
将用户特定的编辑、业务或收件箱策略规则保存在本地覆盖层中,而非共享技能默认配置中。
本地规则示例:
- - 公关/新闻稿处理
- 媒体考察或媒体邀请路由
- VIP 发件人策略
- 业务特定标签
- 自定义通知路由
运行模式
1. 发件人类型优先路由
将发件人分类为:
这样可以低成本地对批量自动邮件进行分类,并将深入审核保留给模糊或人工来源的消息。
2. 收件箱例外策略
将收件箱视为
操作队列,而非阅读队列。
推荐默认设置:
- - 已处理的邮件始终获得 Auto/Triaged 标签
- 仅当邮件明显 actionable/重要时才保留在收件箱中
- 其他所有邮件应移出收件箱,即使分类仍较为宽泛
实际效果:
- - 重要/actionable 邮件 → 保留在收件箱中,并尽可能添加分类标签
- 非重要 邮件 → 移除 INBOX 标签,保留 Auto/Triaged 标签,然后添加最合适的分类标签(Notification、Newsletter、Receipt、Press Releases 等)
3. 置信度区间审核
先使用启发式规则。
然后仅将模糊消息发送给轻量级 LLM 审核。
推荐模式:
- - 高置信度 → 信任启发式规则
- 中等置信度 → LLM 审核
- 低置信度 → 保守回退
4. 保守但有用的回退
如果消息明显是自动/公司来源,但没有特定过滤器匹配,则优先选择通用的非 actionable 分类(例如 Notification),而非将其原封不动留在收件箱中。
5. 标签规范化
使用小型规范标签集,避免因翻译、单复数或拼写错误导致的近似重复标签。
规范化目标示例:
- - Press Release → Press Releases
- 财务标签变体 → 一个规范财务标签
- 保留 Auto/Triaged 作为通用已处理标记
优先使用的 Gmail 原生标签
尽可能使用 Gmail 系统标签:
- - CATEGORYPROMOTIONS
- CATEGORYUPDATES
- IMPORTANT
- STARRED
- INBOX
仅在需要时创建自定义标签,例如:
- - Newsletter
- Notification
- Receipt
- Opportunity
- Action Required
- Auto/Triaged
本地覆盖层设计
通过将私有配置存储在技能目录之外,保持技能的可发布性。
推荐的本地覆盖层路径:
text
~/.openclaw/local/gmail-labeler.config.json
仅在本地覆盖层中存储私有值:
- - 电子邮件账户
- VIP 发件人/域名
- 通知目标
- 业务特定的商机规则
- 个人/自定义标签
日志记录与审核
决策日志应存储在技能源代码树之外,例如:
text
/home/ubuntu/.openclaw/gmail-labeler-logs/
推荐格式:
- - 每天一个 JSONL 文件
- 每条决策一行
- 错误行单独记录
建议的每日审核输入:
- - 昨天的决策日志
- 误报/漏报
- 过度归档
- 遗漏的账单紧急情况
- 遗漏的商机
- 用户请求的更正
需读取的文件
- - references/default-config.json
- references/config-guide.md
- references/filter-catalog.md
- references/implementation-notes.md
- references/logging-and-review.md
- references/llm-review.md
- references/cron-example.md
- references/ain-email-review.schema.json
运行器
- - 主运行器:scripts/gmaillabelerrunner.py
- 启动器示例:scripts/gmaillabelerrun.sh
发布指南
发布前:
- - 仅在技能中保留通用默认配置
- 移除个人账户、聊天 ID、私有域名和自定义用户规则
- 保持示例的通用性
- 明确说明私有配置应放在本地覆盖层中
- 当 PR/新闻稿处理反映私有编辑策略时,保持用户特定性;默认不发布这些本地启发式规则
- 通过启动器验证 cron/非交互式执行,而非仅通过直接 Python 调用