mcpField
S
sales-execution

sales-execution

github.com/hubspot营销与增长281.7k 次安装今天更新
代码仓库

关于 sales-execution

sales-execution 是通过 HubSpot CLI 创建和管理销售活动与任务的技能,强调将活动关联到 CRM 记录,并提供任务搜索和批量创建跟进任务的模式。

主要功能

  1. 01创建销售活动并关联记录
  2. 02读取与联系人关联的任务
  3. 03按状态和负责人搜索任务
  4. 04批量为指定阶段的交易创建跟进任务
  5. 05查阅活动属性和枚举参考

适用场景

  1. 01将通话记录关联到联系人和交易
  2. 02查找联系人的未完成任务
  3. 03为某阶段的交易批量创建跟进任务

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/hubspot/agent-cli-skills --skill sales-execution

安装后在 Claude Code 中输入/sales-execution确认已加载。

附带文件resources/activity-properties-reference.md

详细介绍

资源

文件适用场景
resources/activity-properties-reference.md通话/备注/会议/任务的属性名称和枚举值。创建 objects create 时请保持打开状态——要查看实时枚举值,运行 hubspot properties options-list --type calls <property>;要查看通话结果,运行 hubspot activities calls dispositions list;这份参考文档可让你快速查阅。

先阅读 bulk-operations/SKILL.md——本技能假设你了解其中的批处理、管道和试运行模式。

两条容易忽略的规则

1. 活动在关联之前不可见。 单独运行 hubspot objects create --type calls ... 只会创建一条记录,在 CRM 界面中无人可见。停止之前,务必接着运行 hubspot associations create --from calls:<id> --to contacts:<id>(如果相关,也要关联商机)。

2. 写入和读取时的时间戳格式不同。

路径字段格式
objects create --property hs_timestamp=...hs_timestampUnix 毫秒(13 位)
objects get --type calls <id> 返回properties.hs_timestampUnix 毫秒(字符串)
activities list --contact <id> 返回timestamp(扁平顶层字段)ISO 8601(例如 2024-01-15T10:00:00Z)

当前 Unix 毫秒时间戳:$(date +%s)000(macOS)或 $(date +%s%3N)(Linux)。activities list 的行格式为 {"id","type","timestamp","lastModified","title","body","status","owner_id"}——这是跨类型时间线读取格式,不包含原始属性名称。

按类型创建并关联

# CALL
call_id=$(hubspot objects create --type calls \
  --property hs_call_title="Discovery call" \
  --property hs_call_body="Confirmed $50K budget, Q2 timeline." \
  --property hs_call_direction=OUTBOUND \
  --property hs_call_status=COMPLETED \
  --property hs_call_duration=1800000 \
  --property hs_timestamp=$(date +%s)000 \
  --format json | jq -r '.id')
hubspot associations create --from calls:$call_id --to contacts:149
hubspot associations create --from calls:$call_id --to deals:456

# NOTE
note_id=$(hubspot objects create --type notes \
  --property hs_note_body="Sent proposal. Follow-up Friday." \
  --property hs_timestamp=$(date +%s)000 \
  --format json | jq -r '.id')
hubspot associations create --from notes:$note_id --to deals:456

# MEETING — start/end in Unix ms; reuse start as hs_timestamp
start=$(date +%s)000; end=$(( ${start%000} + 3600 ))000
meeting_id=$(hubspot objects create --type meetings \
  --property hs_meeting_title="Demo — Acme" --property hs_meeting_outcome=COMPLETED \
  --property hs_meeting_start_time=$start --property hs_meeting_end_time=$end \
  --property hs_timestamp=$start --format json | jq -r '.id')
hubspot associations create --from meetings:$meeting_id --to contacts:149

# TASK — hs_timestamp is the DUE DATE, not creation time
due=$(( $(date -v+7d +%s) * 1000 ))   # macOS; Linux: date -d '7 days' +%s
task_id=$(hubspot objects create --type tasks \
  --property hs_task_subject="Confirm proposal received" \
  --property hs_task_priority=HIGH \
  --property hs_task_status=NOT_STARTED \
  --property hs_task_type=CALL \
  --property hs_timestamp=$due \
  --format json | jq -r '.id')
hubspot associations create --from tasks:$task_id --to deals:456

查询联系人的未完成任务——调用两次 CLI,不使用 xargs

associations list 每行输出 {"id": …}(以及 label/associationType 字段);objects get 可在一次批量调用中从标准输入读取数据(参见 bulk-operations/SKILL.md 中的“Read in batch”)。

hubspot associations list --from contacts:149 --to tasks \
| hubspot objects get --type tasks \
    --properties hs_task_subject,hs_task_status,hs_task_priority,hs_timestamp \
| jq -c 'select(.properties.hs_task_status != "COMPLETED")'

查询整个门户中的未完成任务——在服务端通过 @!= 排除状态

@!= 表示 NOT_IN:整个排除列表只需一个条件。不要为每个要排除的状态单独使用一个 --filter 标志——搜索 API 对每个请求的限制为 5 个筛选组、每组 6 个条件,且总计 18 个条件。

@!= 只会匹配具有该属性的记录,因此,要复现 HubSpot 任务视图中“状态不属于以下任何值或为空”的筛选,需要两个组(以 OR 连接),并在每组中重复共享条件:

hubspot objects search --type tasks \
  --filter "hubspot_owner_id=123 AND hs_task_status@!=COMPLETED,DEFERRED" \
  --filter "hubspot_owner_id=123 AND !hs_task_status" \
  --properties hs_task_subject,hs_task_status,hs_task_priority,hs_timestamp

反向筛选(仅包含这些状态)使用 @=(IN):--filter "hs_task_status@=NOT_STARTED,IN_PROGRESS,WAITING"。

批量操作:为某个阶段中的每笔商机创建后续任务

商机 ID 和任务 ID 必须保持对应。将商机负载保存到文件中,创建任务(输出顺序与输入顺序一致——参见 bulk-operations),然后逐行配对两个 ID 列表,并在一次调用中流式传入关联对。

due=$(( $(date -v+7d +%s) * 1000 ))

# 1. Per-deal payload, deal_id retained alongside the create payload.
hubspot objects search --type deals --filter "dealstage=appointmentscheduled" \
  --properties dealname \
| jq -c --argjson due "$due" '{deal_id: .id, payload: {properties: {
    hs_task_subject: ("Follow up: " + .properties.dealname),
    hs_task_priority: "HIGH", hs_task_status: "NOT_STARTED", hs_task_type: "CALL",
    hs_timestamp: ($due|tostring)
  }}}' > /tmp/deal_tasks.jsonl

# 2. Create tasks; one CLI call for the whole batch.
jq -c '.payload' /tmp/deal_tasks.jsonl \
| hubspot objects create --type tasks > /tmp/created_tasks.jsonl

# 3. Zip and stream association pairs through stdin.
paste \
  <(jq -r '.deal_id' /tmp/deal_tasks.jsonl) \
  <(jq -r '.id'      /tmp/created_tasks.jsonl) \
| jq -Rc 'split("\t") | {from:("tasks:"+.[1]), to:("deals:"+.[0])}' \
| hubspot associations create

这些是 objects create 调用(Additive)——创建操作永远不会受摘要门控,因此 --dry-run 只是普通预览;执行时移除该标志即可(无需摘要/确认)。摘要流程仅适用于 bulk-operations/SKILL.md 中的不可逆写入操作(update/upsert/delete/merge)。

已知限制

活动必须立即关联,否则在 CRM 界面中不可见。要查看活动属性的枚举选项值,运行 hubspot properties options-list --type calls <property>(要查看通话结果,则运行 hubspot activities calls dispositions list);这份参考文档可让你快速查阅。Sales Hub 序列在 CLI 中为只读(hubspot sequences list/get/enrollments,需要 automation.sequences.read 权限范围)——CLI 无法将联系人加入序列,因此请通过上述任务/活动来推进外联。此功能范围会不断扩展;在认定 API 不存在之前,请重新检查 hubspot --help/CHANGELOG.md。

评论

支持 Markdown