Smartlead — CLI Usage Guide
Smartlead is the email outreach platform used by this workspace. Use smartlead CLI commands
to manage campaigns, leads, webhooks, and message history.
Configuration
Credentials are resolved in order: ~/.config/smartlead-cli/config.toml → env vars → CLI flags.
Required:
- -
SMARTLEAD_API_KEY — Smartlead API key
Optional:
- -
SMARTLEAD_BASE_URL — base URL (default https://server.smartlead.ai/api/v1) - INLINECODE5 — set to
1 for rich table output
All commands output JSON by default. Add --pretty for human-readable tables (avoid in scripts).
Command Discovery (Use This Instead of Memorizing Commands)
Do not guess command names or options. Use --help and follow the CLI surface:
CODEBLOCK0
Prefer curated commands (campaigns, leads, webhooks) over raw. Use raw only when the
CLI does not expose the endpoint you need yet.
For openclaw-smartlead plugin setup, keep plugin config minimal unless there is a clear reason not to:
- - usually set only
webhookSecret (plugin ingress auth) - plugin forwards normalized Smartlead payloads to OpenClaw
/hooks/smartlead by default - prompt text / delivery channel / branching logic should live in OpenClaw
hooks.mappings (or a hook transform), not plugin config - INLINECODE18 /
openclawHookToken are typically auto-derived from OpenClaw hooks config
Common Workflows
Find campaign IDs
CODEBLOCK1
Get full email thread for a lead (most important for reply alerts)
CODEBLOCK2
Inspect / patch a lead safely (preferred over full update)
INLINECODE20 is a full update endpoint and Smartlead requires email in the
body. For partial edits, prefer patch because it auto-fetches the current lead, merges your
changes, and sends a valid full payload.
CODEBLOCK3
Reply Alert Workflow (EMAIL_REPLY webhook event)
When an EMAIL_REPLY webhook fires through openclaw-smartlead, your OpenClaw hook mapping/transform
should construct the prompt. The forwarded payload includes flat fields like campaign_id,
lead_id, lead_email, reply_category, preview_text, message_id, sequence_number,
plus payload (sanitized raw Smartlead payload).
When responding to the hook prompt, always follow this sequence:
- 1. Extract
campaign_id and lead_id from the prompt context.
-
lead_id comes from
sl_email_lead_id (not
sl_email_lead_map_id).
- 2. If
lead_id is present: INLINECODE38 - If
lead_id is missing but lead_email is present:
smartlead leads get-by-email --email <lead_email> → then message-history.
- 4. Summarize the conversation (bullets or short paragraph).
- Send a channel message starting with exactly "New lead answer", including:
- Lead email, campaign ID
- One-line reply preview (from
preview_text)
- The conversation summary
Set up a campaign webhook pointing at openclaw
CODEBLOCK4
Example webhook.json:
CODEBLOCK5
Use smartlead webhooks upsert --help for the current allowed event_types.
categories are Smartlead workspace lead-category labels (for example Interested), not webhook event types.
For OpenClaw side setup, prefer:
- - plugin route
/smartlead/webhook for Smartlead ingress/auth/dedupe - OpenClaw
hooks.mappings on /hooks/smartlead for prompt templates and branching - optional hook transform for deterministic routing like positive/negative/OOO handling
Webhook Payload Fields (EMAIL_REPLY)
Key fields available when an EMAIL_REPLY event arrives:
| Field | Description |
|---|
| INLINECODE51 | Smartlead campaign ID |
| INLINECODE52 |
Lead ID (use this for message-history) |
|
sl_email_lead_map_id | Lead-map ID (different from lead_id — do not confuse) |
|
sl_lead_email | Original target lead email |
|
leadCorrespondence.targetLeadEmail | More reliable target email field |
|
leadCorrespondence.replyReceivedFrom | Actual email that replied (may differ from target) |
|
subject | Email subject |
|
preview_text | Reply preview snippet |
|
event_timestamp | ISO timestamp of the reply |
|
secret_key | Webhook validation secret (set in Smartlead) |
Important Edge Cases / Pitfalls
| Mistake | Fix |
|---|
| Guessing CLI options | Use smartlead ... --help for the exact command shape |
| Using INLINECODE62 |
/campaigns does not support
limit; use
--offset,
--client-id,
--include-tags |
| Using
sl_email_lead_map_id as
lead_id | Use
sl_email_lead_id for
message-history |
| Treating
replyReceivedFrom as the target |
targetLeadEmail is who was originally emailed |
| Using
campaigns leads update without
email | Smartlead rejects it; prefer
campaigns leads patch, or include
email in the full update body |
| Email lookups failing due to case mismatch | Normalize emails to lowercase before
get-by-email / updates |
| Sending webhook
categories: [] |
categories must be a non-empty list of Smartlead lead category labels |
| Assuming webhook
categories is a global enum | Categories are workspace-specific labels (e.g.
Interested); inspect Smartlead UI / Test Webhook |
| Running
--pretty in automated scripts | Drop
--pretty, parse JSON output |
| Starting alert without "New lead answer" | First line must be exactly
New lead answer |
| Forgetting auth | Ensure
SMARTLEAD_API_KEY is set in env or config |
Deletion Behavior
Delete commands prompt for confirmation in interactive shells. In scripts/automation, pass --yes
to skip prompts.
Examples:
CODEBLOCK6
Smartlead — CLI 使用指南
Smartlead 是此工作区使用的邮件推广平台。使用 smartlead CLI 命令管理推广活动、潜在客户、Webhook 和消息历史记录。
配置
凭据按以下顺序解析:~/.config/smartlead-cli/config.toml → 环境变量 → CLI 标志。
必需:
- - SMARTLEADAPIKEY — Smartlead API 密钥
可选:
- - SMARTLEADBASEURL — 基础 URL(默认 https://server.smartlead.ai/api/v1)
- SMARTLEAD_PRETTY — 设置为 1 以启用富表格输出
所有命令默认输出 JSON。添加 --pretty 可输出人类可读的表格(避免在脚本中使用)。
命令发现(使用此方法而非记忆命令)
不要猜测命令名称或选项。使用 --help 并遵循 CLI 界面:
bash
smartlead --help
smartlead campaigns --help
smartlead campaigns leads --help
smartlead webhooks --help
smartlead --help
优先使用精选命令(campaigns、leads、webhooks)而非 raw。仅在 CLI 尚未公开所需端点时使用 raw。
对于 openclaw-smartlead 插件设置,除非有明确理由,否则保持插件配置最小化:
- - 通常仅设置 webhookSecret(插件入口认证)
- 插件默认将标准化后的 Smartlead 负载转发到 OpenClaw /hooks/smartlead
- 提示文本/投递渠道/分支逻辑应位于 OpenClaw hooks.mappings(或 hook 转换)中,而非插件配置
- openclawHookUrl / openclawHookToken 通常从 OpenClaw hooks 配置自动派生
常见工作流
查找推广活动 ID
bash
smartlead campaigns list
获取潜在客户的完整邮件线程(对回复提醒最重要)
bash
当直接拥有 campaignid 和 leadid 时:
smartlead campaigns leads message-history
id> id>
当只有电子邮件地址时:
smartlead leads get-by-email --email person@example.com # → 获取 id 字段
smartlead campaigns leads message-history id> lead_id>
安全地检查/修补潜在客户(优先于完整更新)
smartlead campaigns leads update 是一个完整更新端点,Smartlead 要求在请求体中包含 email。对于部分编辑,优先使用 patch,因为它会自动获取当前潜在客户,合并您的更改,并发送有效的完整负载。
bash
smartlead campaigns leads get id> id>
smartlead campaigns leads patch id> id> --first-name Updated
回复提醒工作流(EMAIL_REPLY webhook 事件)
当通过 openclaw-smartlead 触发 EMAILREPLY webhook 时,您的 OpenClaw hook 映射/转换应构建提示。转发的负载包含扁平字段,如 campaignid、leadid、leademail、replycategory、previewtext、messageid、sequencenumber,以及 payload(经过清理的原始 Smartlead 负载)。
在响应 hook 提示时,始终遵循以下顺序:
- 1. 从提示上下文中提取 campaignid 和 leadid。
- leadid 来自 slemailleadid(而非 slemailleadmapid)。
- 2. 如果存在 leadid:smartlead campaigns leads message-history id> id>
- 如果缺少 leadid 但存在 lead_email:
smartlead leads get-by-email --email → 然后获取消息历史。
- 4. 总结对话(要点或短段落)。
- 发送以 New lead answer 开头的频道消息,包括:
- 潜在客户电子邮件、推广活动 ID
- 一行回复预览(来自 preview_text)
- 对话摘要
设置指向 openclaw 的推广活动 webhook
bash
首先列出当前 webhook
smartlead webhooks list
创建/更新(id: null = 创建新的)
smartlead webhooks upsert --body-file webhook.json
示例 webhook.json:
json
{
id: null,
name: OpenClaw Reply Alerts,
webhook_url: https:///smartlead/webhook,
eventtypes: [EMAILREPLY],
categories: [Interested]
}
使用 smartlead webhooks upsert --help 查看当前允许的 event_types。
categories 是 Smartlead 工作区潜在客户类别标签(例如 Interested),而非 webhook 事件类型。
对于 OpenClaw 端设置,优先选择:
- - 插件路由 /smartlead/webhook 用于 Smartlead 入口/认证/去重
- OpenClaw hooks.mappings 在 /hooks/smartlead 上用于提示模板和分支
- 可选的 hook 转换,用于确定性路由,如正面/负面/OOO 处理
Webhook 负载字段(EMAIL_REPLY)
EMAIL_REPLY 事件到达时可用的关键字段:
| 字段 | 描述 |
|---|
| campaignid | Smartlead 推广活动 ID |
| slemailleadid |
潜在客户 ID(用于消息历史) |
| slemailleadmapid | 潜在客户映射 ID(与 lead_id 不同 — 不要混淆) |
| slleademail | 原始目标潜在客户电子邮件 |
| leadCorrespondence.targetLeadEmail | 更可靠的目标电子邮件字段 |
| leadCorrespondence.replyReceivedFrom | 实际回复的电子邮件(可能与目标不同) |
| subject | 电子邮件主题 |
| preview_text | 回复预览片段 |
| event_timestamp | 回复的 ISO 时间戳 |
| secret_key | Webhook 验证密钥(在 Smartlead 中设置) |
重要边界情况/陷阱
| 错误 | 修复 |
|---|
| 猜测 CLI 选项 | 使用 smartlead ... --help 查看确切的命令格式 |
| 使用 smartlead campaigns list --limit ... |
/campaigns 不支持 limit;使用 --offset、--client-id、--include-tags |
| 使用 slemailleadmapid 作为 leadid | 使用 slemailleadid 获取 message-history |
| 将 replyReceivedFrom 视为目标 | targetLeadEmail 是原始收件人 |
| 使用 campaigns leads update 而不包含 email | Smartlead 会拒绝;优先使用 campaigns leads patch,或在完整更新体中包含 email |
| 由于大小写不匹配导致电子邮件查找失败 | 在 get-by-email / 更新之前将电子邮件统一转换为小写 |
| 发送 webhook categories: [] | categories 必须是非空的 Smartlead 潜在客户类别标签列表 |
| 假设 webhook categories 是全局枚举 | 类别是工作区特定的标签(例如 Interested);检查 Smartlead UI / 测试 Webhook |
| 在自动化脚本中运行 --pretty | 去掉 --pretty,解析 JSON 输出 |
| 启动提醒时不包含 New lead answer | 第一行必须精确为 New lead answer |
| 忘记认证 | 确保在环境变量或配置中设置了 SMARTLEADAPIKEY |
删除行为
删除命令在交互式 shell 中会提示确认。在脚本/自动化中,传递 --yes 跳过提示。
示例:
bash
smartlead campaigns delete
smartlead campaigns leads delete id> id>
smartlead webhooks delete --webhook-id