Loading...
Loading...
Identify inactive/at-risk customers via CRM filters and create follow-up tasks at scale. Builds on `bulk-operations`; defers activity-creation specifics to `sales-execution`.
npx skill4agent add hubspot/agent-cli-skills customer-retention| File | When to use |
|---|---|
| Filter cookbook of churn signals — |
bulk-operations/SKILL.mdsales-execution/SKILL.mdhubspot properties get --type contacts notes_last_contacted... hs_last_sales_activity_date... --type subscriptions hs_subscription_statussubscriptionssubscriptions-readCUTOFF=$(date -v-60d +%Y-%m-%d 2>/dev/null || date -d '60 days ago' +%Y-%m-%d)
# No outreach in 60d (calls/notes/meetings update notes_last_contacted)
hubspot objects search --type contacts \
--filter "lifecyclestage=customer AND notes_last_contacted<$CUTOFF" \
--properties email,firstname,notes_last_contacted,hubspot_owner_id
# No sales activity in 60d (broader — also catches emails/tasks)
hubspot objects search --type contacts \
--filter "lifecyclestage=customer AND hs_last_sales_activity_date<$CUTOFF" \
--properties email,firstname,hs_last_sales_activity_date
# Never contacted
hubspot objects search --type contacts \
--filter "lifecyclestage=customer AND !notes_last_contacted" \
--properties email,firstnameresources/customer-health-signals.mdbulk-operationssubscriptionshubspot objects typeshs_subscription_statushubspot properties get --type subscriptions hs_subscription_status # lists allowed values
# Past-due — revenue at immediate risk (substitute your verified value)
hubspot objects search --type subscriptions \
--filter "hs_subscription_status=past_due" \
--properties hs_recurring_billing_total,hs_subscription_status
# Map an at-risk subscription to its contact for outreach
hubspot associations list --from subscriptions:<sub_id> --to contacts --format jsonlsales-executiontask_id=$(hubspot objects create --type tasks \
--property hs_task_subject="Q1 retention check-in" \
--property hs_task_priority=HIGH --property hs_task_status=NOT_STARTED \
--property hs_task_type=CALL --property hs_timestamp=$(date +%s)000 \
--format json | jq -r '.id')
hubspot associations create --from tasks:$task_id --to contacts:<contact_id>jqobjects create--dry-runbulk-operationsDUE_MS=$(( ($(date +%s) + 2*86400) * 1000 )) # due in 2 days
# 1. Capture the cohort (same file feeds both create + associate)
hubspot objects search --type contacts \
--filter "lifecyclestage=customer AND notes_last_contacted<$CUTOFF" \
--properties firstname > /tmp/inactive.jsonl
# 2. Build task payloads — one per contact
jq -c --arg due "$DUE_MS" '{
contact_id: .id,
properties: {
hs_task_subject: ("Re-engage: " + (.properties.firstname // "customer")),
hs_task_priority: "HIGH", hs_task_status: "NOT_STARTED",
hs_task_type: "CALL", hs_timestamp: $due
}
}' /tmp/inactive.jsonl > /tmp/task_payloads.jsonl
# 3. Dry-run, then create (drop contact_id before piping)
jq -c '{properties}' /tmp/task_payloads.jsonl | hubspot objects create --type tasks --dry-run | head
jq -c '{properties}' /tmp/task_payloads.jsonl | hubspot objects create --type tasks > /tmp/created.jsonl
# 4. Associate each new task to its contact (paste preserves order)
paste <(jq -r '.id' /tmp/created.jsonl) <(jq -r '.contact_id' /tmp/task_payloads.jsonl) \
| while read task_id contact_id; do
hubspot associations create --from tasks:$task_id --to contacts:$contact_id
donexargs -I{}objects createbulk-operationspastehubspot associations create