Step 1 — Pull usage from Postgres (read-only)

Query per-account activity trend over a rolling window (active seats, key-feature events, login frequency over the last 30 days vs. the prior 30). Classify:
Usage signalCriteria
Stable/growingFlat or increasing vs. prior window
Declining≥20% drop in core activity vs. prior window
DormantNear-zero activity for 14+ days on a previously active account

Step 2 — Pull support friction from Plain (read-only)

Pull thread volume and tone per account over the same window.
Support signalCriteria
NormalThread volume in line with the account's history
Rising frictionThread count up materially vs. baseline, or repeated unresolved threads
EscalatedAn open thread flagged urgent/escalated, or explicit cancellation language

Step 3 — Pull billing state from Stripe (read-only)

Pull payment status and renewal date per account.
Billing signalCriteria
HealthyPayments current, renewal more than 45 days out
At riskOne missed or failed payment in the last billing cycle
Renewal-imminentRenewal within 30 days

Step 4 — Combine into one score per account

No single signal alone is high risk. Weigh combinations:
CombinationRisk
Declining/dormant usage aloneLow–medium — watch
Declining usage + rising/escalated supportMedium–high
Any usage signal + a failed paymentHigh
Declining/dormant usage + renewal-imminentHigh
Rising/escalated support + renewal-imminentHigh
Declining usage + rising support + (renewal-imminent or failed payment)Highest — surface first
Stable usage, normal support, healthy billingNot at risk — omit from the list

Step 5 — Write the reason and the next step

For every account that clears the "watch" bar, write:
  • Reason — the specific signals that fired, e.g. "usage down 34% in 30d, 2 escalated threads, renewal in 12 days."
  • Next step — one concrete, human-actionable suggestion tied to the dominant signal:
    • Usage decline → a check-in call or re-onboarding nudge.
    • Support friction → proactive outreach from the account's CSM.
    • Payment risk → a billing follow-up (the agent does not send this itself).
    • Renewal-imminent combined with any other signal → prioritize a renewal conversation now, not at the renewal date.

Step 6 — Rank and post

Sort highest risk first. Post one message to {{alert_channel}}: for each account, its rank, risk level, the reason, and the next step. Post exactly once per run — this is a fresh session, so there is no prior list to update or diff against; the whole list is recomputed and reposted every day.
Churn signals — Kortix Marketplace | Kortix