Gmail Auto Draft
Use this skill to build or run a review-safe Gmail reply workflow: read new emails, generate AI reply text, and save drafts instead of sending directly.
Quick workflow
- 1. Prepare Google OAuth credentials.
- Use local GMN endpoint (
openclaw:main) or set external OpenAI key. - Run one-shot mode to validate draft creation.
- Tune query and prompt style.
- Switch to polling mode for continuous monitoring.
Run commands
Install dependencies:
CODEBLOCK0
Default backend (local GMN via OpenClaw gateway):
CODEBLOCK1
Or use OpenAI directly:
CODEBLOCK2
One-shot test:
CODEBLOCK3
Continuous monitor:
CODEBLOCK4
Upwork demo profile (lead-focused query + fixed agency tone):
CODEBLOCK5
Common options
- -
--query: Gmail search filter for target emails. - INLINECODE2 : max messages per cycle.
- INLINECODE3 : seconds between cycles (
0 means run once). - INLINECODE5 : model name (default
openclaw:main). - INLINECODE7 : OpenAI-compatible base URL (default
http://127.0.0.1:18789/v1). - INLINECODE9 : business context for OpenAI prompt.
- INLINECODE10 : load agency context from a text file.
- INLINECODE11 : response style constraints.
- INLINECODE12 : load style rules from a text file.
- INLINECODE13 : load Gmail query from a text file.
- INLINECODE14 : mark processed messages as read.
- INLINECODE15 : label for already drafted emails (default
openclaw_auto_drafted).
Output behavior
The script prints JSON for each cycle:
- -
processed: number of drafted replies - INLINECODE18 : draft metadata
- INLINECODE19 : skipped message reasons
- INLINECODE20 : per-message errors
Resources
- - Script: INLINECODE21
- Runner: INLINECODE22
- Demo runner: INLINECODE23
- Dependencies: INLINECODE24
- Setup guide: INLINECODE25
- Prompt/query tuning: INLINECODE26
- Demo config: INLINECODE27
- Demo config: INLINECODE28
- Demo config: INLINECODE29
Gmail 自动草稿
使用此技能构建或运行安全审查的 Gmail 回复工作流:读取新邮件,生成 AI 回复文本,并保存草稿而非直接发送。
快速工作流
- 1. 准备 Google OAuth 凭据。
- 使用本地 GMN 端点(openclaw:main)或设置外部 OpenAI 密钥。
- 运行一次性模式以验证草稿创建。
- 调整查询和提示风格。
- 切换到轮询模式进行持续监控。
运行命令
安装依赖:
bash
cd skills/gmail-auto-draft/scripts
python3 -m pip install -r requirements.txt
默认后端(通过 OpenClaw 网关的本地 GMN):
bash
export OPENAIBASEURL=http://127.0.0.1:18789/v1
export OPENAI_MODEL=openclaw:main
或直接使用 OpenAI:
bash
export OPENAIAPIKEY=youropenaikey
export OPENAI_MODEL=gpt-4o-mini
一次性测试:
bash
./run_once.sh --auth-mode local --max-emails 3
持续监控:
bash
./run_once.sh --poll-interval 60 --max-emails 5 --mark-read
Upwork 演示配置(以潜在客户为导向的查询 + 固定机构语气):
bash
./runupworkdemo.sh --auth-mode local --max-emails 5
常用选项
- - --query:目标邮件的 Gmail 搜索过滤器。
- --max-emails:每周期最大邮件数。
- --poll-interval:周期之间的秒数(0 表示运行一次)。
- --openai-model:模型名称(默认为 openclaw:main)。
- --openai-base-url:兼容 OpenAI 的基础 URL(默认为 http://127.0.0.1:18789/v1)。
- --agency-profile:OpenAI 提示的业务上下文。
- --agency-profile-file:从文本文件加载机构上下文。
- --style-rules:回复风格约束。
- --style-rules-file:从文本文件加载风格规则。
- --query-file:从文本文件加载 Gmail 查询。
- --mark-read:将已处理邮件标记为已读。
- --processed-label:已创建草稿邮件的标签(默认为 openclawautodrafted)。
输出行为
脚本为每个周期打印 JSON:
- - processed:已创建草稿的回复数量
- created_drafts:草稿元数据
- skipped:跳过的邮件原因
- errors:每封邮件的错误信息
资源
- - 脚本:scripts/gmailautodraft.py
- 运行器:scripts/runonce.sh
- 演示运行器:scripts/runupworkdemo.sh
- 依赖:scripts/requirements.txt
- 设置指南:references/setup.md
- 提示/查询调整:references/prompt-tuning.md
- 演示配置:references/upwork-demo/agencyprofile.txt
- 演示配置:references/upwork-demo/stylerules.txt
- 演示配置:references/upwork-demo/gmailquery.txt