GClaw: Gmail 收件箱智能分类 - Openclaw 技能库

作者:互联网

2026-04-18

AI教程

什么是 GClaw?

GClaw 提供了一个强大的框架,将 Gmail 智能引入 Openclaw 生态系统。它旨在读取、解析和分类电子邮件数据,从而在拥挤的收件箱中提取重要信息。通过专注于效率,GClaw 允许开发者构建通过结构化、特定于机器人的上下文与邮件历史记录和收件进行交互的代理。

此技能对于需要处理海量邮件的 Openclaw 技能开发者尤为重要。它利用启发式分类器将邮件归为 15 个不同的类别(如金融、旅行、工作),确保 AI 代理仅将 LLM 令牌用于摘要或叙述生成等高价值任务,而非基础排序。

下载入口:https://github.com/openclaw/skills/tree/main/skills/yhyatt/gclaw

安装与下载

1. ClawHub CLI

从源直接安装技能的最快方式。

npx clawhub@latest install gclaw

2. 手动安装

将技能文件夹复制到以下位置之一

全局模式 ~/.openclaw/skills/ 工作区 /skills/

优先级:工作区 > 本地 > 内置

3. 提示词安装

将此提示词复制到 OpenClaw 即可自动安装。

请帮我使用 Clawhub 安装 gclaw。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。

GClaw 应用场景

  • 创建自动化的每日摘要,综合简报和工作更新。
  • 构建专门的旅游机器人,监控 booking.com 或航空公司等特定发件人。
  • 开发财务追踪代理,隔离收据和发票通知。
  • 过滤高流量收件箱,为 AI 编码代理提取需要操作的项目。
  • 驱动多代理工作流,让不同的机器人可以隔离查看同一个 Gmail 帐户。
GClaw 工作原理
  1. BotContext 定义代理的具体范围,包括允许的 Gmail 标签和发件人过滤器。
  2. EmailFetcher 利用 gog CLI 安全地检索邮件,同时应用去重逻辑以避免重复处理。
  3. EmailParser 提取元数据,清理邮件正文,并识别转发内容以进行更干净的数据摄取。
  4. EmailClassifier 应用启发式引擎,在不产生 LLM 成本的情况下将邮件分配到 15 个预定义类别之一。
  5. EmailStore 将处理后的数据持久化到特定于机器人的 JSONL 文件中,使结构化数据可供下游 Openclaw 技能使用。

GClaw 配置指南

要将 GClaw 集成到您的 Openclaw 技能环境中,请确保已安装并验证 gog 技能。设置环境变量并安装包:

export GCLAW_GMAIL_ACCOUNT="your@gmail.com"
export GOG_KEYRING_PASSWORD="your-keyring-password"

pip install -e .

您可以通过运行包含的测试套件来验证设置:

pip install pytest
pytest tests/

GClaw 数据架构与分类体系

GClaw 保持清晰的数据分类,以确保跨不同 Openclaw 技能的兼容性。数据组织如下:

组件 功能
BotContext 管理每个机器人的标签隔离和结果限制
EmailClassifier 将数据标记为简报、金融、旅游、工作等
EmailStore 以 JSONL 格式保存去重记录
Metadata 包括发件人详情、清理后的正文文本和转发检测

所有数据均以机器人隔离的方式存储,允许多个代理查询同一账户而不会发生数据泄露或干扰。

name: gclaw
description: Gmail inbox intelligence for OpenClaw. Reads, classifies, and digests your Gmail so the important stuff surfaces without the noise. Use when fetching new emails, running an inbox digest, classifying messages into categories (newsletter, finance, travel, work, action-required, etc.), or building downstream bots that consume email data. Provides BotContext (per-bot label isolation), EmailFetcher, EmailParser, EmailClassifier (15 categories), and EmailStore (deduplicated JSONL).
metadata:
  openclaw:
    requires:
      bins: [gog]
    env:
      - GCLAW_GMAIL_ACCOUNT
      - GOG_KEYRING_PASSWORD

GClaw — Gmail Intelligence for OpenClaw

GClaw — Gmail inbox intelligence

Reads, classifies, and digests your Gmail so the important stuff surfaces without the noise.

Zero LLM tokens for classification — heuristic classifier covers 15 categories. LLM only fires when you need a summary or digest narrative.

Setup

# Requires the gog skill (Google OAuth CLI)
export GCLAW_GMAIL_ACCOUNT="your@gmail.com"
export GOG_KEYRING_PASSWORD="your-keyring-password"

pip install -e .

Quick Usage

from kaimail.bot_context import BotContext
from kaimail.fetcher import EmailFetcher
from kaimail.classifier import EmailClassifier
from kaimail.store import EmailStore

# Each bot declares its own label scope
ctx = BotContext(
    bot_id="digest",
    allowed_labels=["INBOX", "CATEGORY_UPDATES"],
    max_results=50
)

fetcher = EmailFetcher(context=ctx)
emails = fetcher.fetch_new()  # deduped — never processes the same email twice

classifier = EmailClassifier()
store = EmailStore(bot_id="digest")

for email in emails:
    email.category = classifier.classify(email)
    store.save(email)
    print(f"[{email.category}] {email.subject}")

Classification Categories (15)

newsletter · finance · travel · work · action_required · social · shopping · security · calendar · health · legal · ads · receipt · personal · other

All heuristic — no LLM cost.

Architecture

Gmail (via gog CLI)
    └─? EmailFetcher      — fetch, cache, deduplicate
        └─? EmailParser   — extract sender, clean body, detect forwards
            └─? EmailClassifier  — 15-category heuristic classification
                └─? EmailStore  — JSONL persistence (per bot_id)

BotContext — Per-Bot Isolation

Multiple bots can share one Gmail account without interfering:

# Digest bot — only newsletters + inbox
digest_ctx = BotContext(bot_id="digest", allowed_labels=["Thoughts", "INBOX"])

# Travel bot — only travel senders
travel_ctx = BotContext(
    bot_id="travel",
    allowed_labels=["Travel"],
    allowed_senders=["booking.com", "airbnb.com", "kayak.com"]
)

Running Tests

pip install pytest
pytest tests/

Requirements

  • Python 3.10+
  • gog skill installed and authenticated
  • GOG_KEYRING_PASSWORD env var set

License

MIT

相关推荐