PDF、Word 与幻灯片32k · #9173
gws-gmail-watch
它能做什么
这个命令会监控你的 Gmail 收件箱,有新邮件时就把它以格式化文本(NDJSON)的形式发送给你。
适用场景
- ✓当你希望重要邮件一到达就收到通知时。
- ✓当你要自动化处理依赖新邮件的任务时(比如处理订单)。
- ✓当你想根据标签监控特定邮件时。
技能链接
https://github.com/googleworkspace/cli/blob/main/skills/gws-gmail-watch/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
请用这个技能帮我:https://github.com/googleworkspace/cli/blob/main/skills/gws-gmail-watch/SKILL.md
阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
npx skills add googleworkspace/cli --skill gws-gmail-watch
下载 SKILL.md,放进智能体的技能文件夹。
curl -L https://raw.githubusercontent.com/googleworkspace/cli/main/skills/gws-gmail-watch/SKILL.md -o SKILL.md
可以这样问 AI
“帮我监控收件箱,有新邮件到达时告诉我。”
每周 5 个新技能,1 分钟读完。
工作原理
它借助 Google Cloud 服务获取新 Gmail 邮件的通知,再把这些通知以其他程序容易读取的文本格式发送给你。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
gmail +watch
PREREQUISITE: Read
../gws-shared/SKILL.mdfor auth, global flags, and security rules. If missing, rungws generate-skillsto create it.
Watch for new emails and stream them as NDJSON
Usage
gws gmail +watch
Flags
| Flag | Required | Default | Description |
|---|---|---|---|
--project |
— | — | GCP project ID for Pub/Sub resources |
--subscription |
— | — | Existing Pub/Sub subscription name (skip setup) |
--topic |
— | — | Existing Pub/Sub topic with Gmail push permission already granted |
--label-ids |
— | — | Comma-separated Gmail label IDs to filter (e.g., INBOX,UNREAD) |
--max-messages |
— | 10 | Max messages per pull batch |
--poll-interval |
— | 5 | Seconds between pulls |
--msg-format |
— | full | Gmail message format: full, metadata, minimal, raw |
--once |
— | — | Pull once and exit |
--cleanup |
— | — | Delete created Pub/Sub resources on exit |
--output-dir |
— | — | Write each message to a separate JSON file in this directory |
Examples
gws gmail +watch --project my-gcp-project
gws gmail +watch --project my-project --label-ids INBOX --once
gws gmail +watch --subscription projects/p/subscriptions/my-sub
gws gmail +watch --project my-project --cleanup --output-dir ./emails
Tips
- Gmail watch expires after 7 days — re-run to renew.
- Without --cleanup, Pub/Sub resources persist for reconnection.
- Press Ctrl-C to stop gracefully.
See Also
- gws-shared — Global flags and auth
- gws-gmail — All send, read, and manage email commands
常见问题
怎么停止监控邮件?
按键盘上的 Ctrl+C 就可以停止这个命令。
到达的邮件会怎样?
它们会以格式化文本(NDJSON)的形式发送给你。如果你愿意,也可以设置成把它们保存到文件里。
需要在 Google Cloud 里做什么设置吗?
可能需要。这项服务通常要求你有一个 Google Cloud 项目。这个命令会尝试帮你完成设置,但可能会要求你提供额外的信息。
详情
热度
- GitHub 星标
- 32k
- 排名
- #9173
- 许可证
- Apache-2.0
- 更新时间
- 2026/10/6
评论
- …