Team Ownership

hubspot/agent-cli-skills/team-ownership

作者 hubspota8eea0880838無授權條款27 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫7 天前更新

Assign and reassign CRM record ownership, audit who-owns-what across object types, and handle rep transitions. Built on `bulk-operations`.

僅含說明Business & Finance
AI 產生的概覽

使用 hubspot CLI 指派、重新指派與稽核聯絡人、公司、交易和工單的 CRM 記錄歸屬。

功能
此技能提供操作說明,用於指派與重新指派 CRM 記錄的歸屬、稽核各物件類型中誰擁有哪些記錄,以及處理業務人員交接。內容涵蓋將負責人電子郵件解析為入口網站專屬 ID、依負責人或未指派狀態搜尋記錄,以及透過 dry-run、digest 和 confirm 保護機制執行批次或單筆記錄的重新指派。它也說明如何依負責人 ID 將記錄分組並串接負責人清單,產生用戶端層級的團隊檢視。
適用情境
當記錄需要更換負責人、業務人員離職需要轉移其記錄,或需要稽核聯絡人、公司、交易和工單的歸屬時使用。它也適合重新分配客戶或查找某位負責人名下的記錄。
執行需求
需要 hubspot CLI 的 objects、owners 和 history 指令,以及用於 JSON 重塑的 jq 和用於管線的 shell 環境。它依賴 bulk-operations 技能提供 JSONL 管線、分頁、dry-run/digest/confirm 和歷史還原。此技能不附帶指令碼,僅為說明文件。

Prereq: read bulk-operations/SKILL.md first. JSONL piping, pagination, dry-run/digest/confirm, and hubspot history recovery live there. Reshape patterns live in bulk-operations/resources/json-patterns.md.

hubspot_owner_id is a string field on contacts, companies, deals, and tickets. Owners are CRM users — hubspot owners list returns them; there is no teams object, so team-level views are client-side groupings by hubspot_owner_id.

1. Resolve email → owner ID

Never hardcode IDs — they are portal-specific. Resolve, then cache:

bash
FROM_ID=$(hubspot owners list | jq -r 'select(.email=="[email protected]") | .id')TO_ID=$(hubspot owners list | jq -r 'select(.email=="[email protected]")  | .id')

2. Find records for an owner

Same filter across all four object types. Add object-specific --properties for context. Unowned records use the !property form.

bash
hubspot objects search --type contacts  --filter "hubspot_owner_id=$FROM_ID" --properties email,firstname,lifecyclestagehubspot objects search --type companies --filter "hubspot_owner_id=$FROM_ID" --properties name,domainhubspot objects search --type deals     --filter "hubspot_owner_id=$FROM_ID" --properties dealname,dealstage,amounthubspot objects search --type tickets   --filter "hubspot_owner_id=$FROM_ID" --properties subject,hs_pipeline_stage
# Records with no owner at allhubspot objects search --type deals --filter "!hubspot_owner_id" --properties dealname,amount

100 hits — page with the --after loop from bulk-operations. Counting only: pipe to wc -l.

3. Bulk reassign — search → update

Reshape each search row into {id, properties:{hubspot_owner_id}} and pipe to objects update. objects update is irreversible, so dry-run first: the dry-run emits a digest + apply_command_hint at every size (confirm = the record ID for one record, the row count for a batch). Then re-run with --digest/--confirm (see bulk-operations/SKILL.md § "Safe destructive workflow").

bash
# Dry-runhubspot objects search --type contacts --filter "hubspot_owner_id=$FROM_ID" \| jq -c --arg to "$TO_ID" '{id, properties:{hubspot_owner_id:$to}}' \| hubspot objects update --type contacts --dry-run \| tee /tmp/reassign.preview.jsonl
# Execute — lift the digest + confirm from the preview line (required at every size)digest=$(jq -r 'select(.digest != null) | .digest' /tmp/reassign.preview.jsonl)confirm=$(jq -r 'select(.digest != null) | .target.id' /tmp/reassign.preview.jsonl)   # single: record ID; batch: row count
hubspot objects search --type contacts --filter "hubspot_owner_id=$FROM_ID" \| jq -c --arg to "$TO_ID" '{id, properties:{hubspot_owner_id:$to}}' \| hubspot objects update --type contacts --digest "$digest" --confirm "$confirm"

Single-record assignment — no stdin, no jq. Still irreversible, so dry-run first (confirm = the record ID):

bash
hubspot objects update --type contacts 12345 --property hubspot_owner_id=$TO_ID --dry-runhubspot objects update --type contacts 12345 --property hubspot_owner_id=$TO_ID --digest <hash> --confirm 12345

4. Rep-leaves workflow

Loop over the four object types the rep touches:

bash
FROM_ID=$(hubspot owners list | jq -r 'select(.email=="[email protected]")    | .id')TO_ID=$(hubspot  owners list | jq -r 'select(.email=="[email protected]") | .id')
for type in contacts companies deals tickets; do  echo "── $type ──"  hubspot objects search --type "$type" --filter "hubspot_owner_id=$FROM_ID" \  | jq -c --arg to "$TO_ID" '{id, properties:{hubspot_owner_id:$to}}' \  | hubspot objects update --type "$type" --dry-rundone

Review each digest line, then re-run per type with the --digest/--confirm lifted from that type's preview line (required at every size; confirm = the row count for a batch, the record ID for a single). Mis-reassigned? hubspot history --since 1h lists the affected IDs.

5. Team-level views (client-side grouping)

Group records by hubspot_owner_id, join to owners list for human-readable emails:

bash
hubspot objects search --type deals --filter "dealstage!=closedwon AND dealstage!=closedlost" \  --properties hubspot_owner_id --format json \| jq '.data | group_by(.properties.hubspot_owner_id)       | map({owner_id: .[0].properties.hubspot_owner_id, count: length})' \> /tmp/by-owner.json
hubspot owners list \| jq --slurpfile by /tmp/by-owner.json -r \     '. as $o | $by[0][] | select(.owner_id==$o.id) | "\($o.email)\t\(.count)"'

來源與署名

來源:hubspot/agent-cli-skills位於team-ownership提交a8eea08

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架