m26-resend-email
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseM26 Resend email automation
M26 Resend 邮件自动化
Assume the upstream layout exists (or will be materialized). All procedures below use into , a venv, and unless the user is in a full monorepo from the repository root, where is also valid.
scripts/emails/cdscripts/emailspython <script>.pypython -m scripts.emails.<name>假设上游目录结构中的 已存在(或即将生成)。以下所有操作都需要先 进入 目录,使用 venv 虚拟环境,并运行 命令,除非你处于代码仓库根目录的完整 monorepo 环境中,这种情况下也可以使用 命令。
scripts/emails/cdscripts/emailspython <script>.pypython -m scripts.emails.<name>First: materialize scripts/emails
scripts/emails第一步:生成 scripts/emails
目录
scripts/emailsIf the folder is missing, obtain a sparse checkout of only that path (not the whole monorepo working tree). Full step-by-step commands, Windows junctions, and Linux symlinks live in in the upstream repo.
scripts/emails/MINIMAL_CLONE.mdMinimum idea:
- Clone with , then
--filter=blob:none --sparseandgit sparse-checkout init --no-cone.git sparse-checkout set --no-cone '/scripts/emails/' - , create
cd scripts/emails,.venv, copypip install -r requirements.txtfrom.env(or from another machine — see below)..env.example - Updates: from the sparse clone root.
git pull
New machine / copied workspace: Copy and every file paths inside it (service account JSON, Gmail OAuth client JSON, , etc.), then edit paths so they match the new filesystem. Copying alone often breaks because paths still point at the old PC. Agents should ask for missing keys or files before sending. Full checklist: .
.envgmail_token.json.envreferences/required-credentials.mdDo not run from the monorepo root (path through ). Either and run , or from full repo use .
python scripts/emails/foo.pyscripts/emails/cd scripts/emailspython foo.pypython -m scripts.emails.fooSecrets stay in or the environment — never commit API keys, webhook secrets, or Gmail token files.
.env如果该文件夹不存在,请仅对该路径执行稀疏检出(sparse checkout)(不需要检出整个monorepo工作树)。完整的分步命令、Windows junction配置以及Linux符号链接说明都在上游仓库的 文件中。
scripts/emails/MINIMAL_CLONE.md基础操作思路:
- 使用 参数克隆仓库,然后执行
--filter=blob:none --sparse和git sparse-checkout init --no-cone命令。git sparse-checkout set --no-cone '/scripts/emails/' - ,创建
cd scripts/emails虚拟环境,执行.venv,从pip install -r requirements.txt复制生成.env.example文件(也可以从其他机器复制,见下文说明)。.env - 更新操作:在稀疏克隆的根目录执行 。
git pull
新机器/复制的工作空间: 复制 文件以及文件中引用的所有路径对应的文件(服务账号JSON、Gmail OAuth客户端JSON、等),然后编辑路径使其匹配新的文件系统。仅复制文件通常会导致报错,因为路径仍然指向旧设备的地址。Agent在发送邮件前应该询问缺失的密钥或文件。完整检查清单见 。
.envgmail_token.json.envreferences/required-credentials.md请不要在monorepo根目录运行 命令(直接通过路径调用)。要么 后运行 ,要么在完整仓库环境下使用 命令。
python scripts/emails/foo.pyscripts/emails/cd scripts/emailspython foo.pypython -m scripts.emails.foo密钥存储在 文件或环境变量中——永远不要提交API密钥、webhook密钥或Gmail token文件到代码仓库。
.envCore scripts (from scripts/emails
)
scripts/emails核心脚本(在scripts/emails
目录下)
scripts/emails| Script | Role |
|---|---|
| Batch sends via Resend + Google Sheet rows |
| Pull inbox replies (Resend webhooks do not replace this) |
| Receives Resend events → Sheet columns ( |
| Threaded Gmail/Resend replies |
| Build tracked links with consistent UTM params |
Details, flags, and examples: . Operational guardrails: .
scripts/emails/README.mdscripts/emails/AGENTS.md| 脚本 | 作用 |
|---|---|
| 基于Resend + Google Sheet行数据批量发送邮件 |
| 拉取收件箱回复(Resend webhooks无法替代该功能) |
| 接收Resend事件 → 写入Sheet列( |
| 线程化Gmail/Resend回复 |
| 生成带统一UTM参数的跟踪链接 |
详细说明、参数标识和示例见 。操作规范见 。
scripts/emails/README.mdscripts/emails/AGENTS.mdResend behavior (short)
Resend行为说明(简版)
- Opens/clicks: Emitted when domain-level open/click tracking is enabled in Resend; webhooks can fire / click events. Open rates are imperfect (clients blocking images, etc.).
email.opened - Inbox replies: Not a substitute for before follow-up sends.
sync_replies_gmail.py
- 打开/点击统计: 当你在Resend中开启了域名级别的打开/点击跟踪时会生成对应数据;webhooks会触发 / 点击事件。打开率统计存在误差(客户端拦截图片等原因)。
email.opened - 收件箱回复: 发送跟进邮件前,不能用Resend的回复统计替代 的同步结果。
sync_replies_gmail.py
UTM and readable links
UTM和可读链接
Put long query strings in the HTML (or Markdown ). Visible copy stays short; parameters stay on the URL. Parameter pattern and generators: see .
href[visible text](url)references/utm-and-links.md把长查询字符串放在 HTML 属性中(或者Markdown的 格式中)。可见文案保持简洁,参数放在URL上。参数规范和生成器见 。
href[可见文本](url)references/utm-and-links.mdIdempotency and safety
幂等性和安全说明
- : idempotency keys tie to campaign + chunk; reuse within 24h with a different body → 409. Use a test campaign id or
send_campaignfor experiments.--idempotency-suffix - Before production sends: ,
--dry-run, validate templates.--show-selected
- : 幂等性密钥与营销活动+分块绑定;24小时内使用相同密钥发送不同内容的邮件会返回 409 错误。进行测试时请使用测试营销活动ID或者添加
send_campaign参数。--idempotency-suffix - 正式发送前:使用 、
--dry-run参数验证模板。--show-selected
When to load bundled references
何时需要查阅附带的参考文档
- Clone/symlink mechanics, sparse-checkout pitfalls →
references/clone-and-layout.md - , paths, copied key files, webhook vs send-only, PostHog →
.envreferences/required-credentials.md - UTM + link presentation →
references/utm-and-links.md - Checklists (reply sync timing, batch columns, GIF env vars) →
references/operational-rules.md
Upstream canonical copies evolve in and ; refresh this skill when those change materially.
scripts/emails/MINIMAL_CLONE.mdscripts/emails/AGENTS.md- 克隆/符号链接机制、稀疏检出常见问题 →
references/clone-and-layout.md - 、路径、复制的密钥文件、webhook和仅发送模式、PostHog →
.envreferences/required-credentials.md - UTM + 链接展示规范 →
references/utm-and-links.md - 检查清单(回复同步时间、批量列、GIF环境变量) →
references/operational-rules.md
上游的标准版本会在 和 中更新;当这些文件发生重大变更时需要更新本技能。
scripts/emails/MINIMAL_CLONE.mdscripts/emails/AGENTS.md