Score customer accounts on churn risk using product usage, support tickets, and engagement signals, then alert CSMs before renewals slip.
You are a customer success analyst. You watch account health and alert humans before deals churn. WORKFLOW: 1. Call ingest_signals across product usage, support tickets, NPS, and renewal dates. 2. Call score_account to compute a 0-100 health score per account. 3. Call detect_drop to flag week-over-week declines beyond a threshold. 4. Call notify_csm with the account, score, top contributing signals, and a recommended play. RULES: - Health score must combine at least 3 signal types; never score on usage alone. - Always include the top 3 signals contributing to a low score. - Recommended plays must be specific (which feature, which contact) not generic. - Never alert if the account is within 5 days of an already-scheduled QBR.
import { agent, tool } from "@agent-sdk"
import { z } from "zod"
const ingestInput = z.object({
accountIds: z.array(z.string()).min(1).max(500),
})
export default agent({
model: "claude-sonnet-4-6",
permissionMode: "bypassPermissions",
maxTurns: 25,
systemPrompt: `...`, // see System Prompt section above
tools: {
ingest_signals: tool({
description: "Pull usage, tickets, NPS, renewal date per account",
inputSchema: ingestInput,
execute: async ({ accountIds }) => { /* warehouse query */ },
}),
score_account: tool({
description: "Compute composite 0-100 health score",
inputSchema: z.object({ signals: z.any() }),
execute: async ({ signals }) => { /* { score, contributors[] } */ },
}),
detect_drop: tool({
description: "Flag week-over-week declines beyond threshold",
inputSchema: z.object({ accountId: z.string(), threshold: z.number() }),
execute: async ({ accountId, threshold }) => { /* delta */ },
}),
notify_csm: tool({
description: "Send Slack alert with recommended play",
inputSchema: z.object({ text: z.string() }),
execute: async ({ text }) => { /* Slack webhook */ },
}),
},
})WAREHOUSE_URLData warehouse connection stringSLACK_WEBHOOK_URLSlack incoming-webhook for CSM alertsMost CS teams find out about churn the day the customer cancels. This catches it 30 days earlier with the why already attached.