Flag customers whose usage dropped before they renew
Finds accounts whose usage fell in Mixpanel and renew soon in Stripe, alerts customer success in Slack, and drafts a check-in email.
Outcome
A Slack post in your customer success channel for each at-risk account that renews soon, with both usage counts and the renewal date.
A drafted check-in email for each of those accounts, signed by the person you choose.
The accounts ordered by renewal date, with the billing emails that matched no Stripe customer.
How it works
MDetect drops, by Run a query by Mixpanel
In
mixpanel_project, countusage_eventbroken down byaccount_email_propertyfor the last 30 days and the 30 days before; a billing email missing from the last 30 days counts as 0. Keep each billing email whose count fell by more thandrop_threshold, with both counts.
SFind their customers, by List customers by Stripe
Look up each billing email, as stored and lowercased. Keep each customer's ID and name; note the emails with no customer.
SCheck renewals, by List subscriptions by Stripe
For each customer, list active subscriptions that are not set to cancel at period end. Keep the yearly ones whose subscription item's
current_period_endfalls withinrenewal_window, with that date.
SEscalate, by Post a message by Slack
Post one message per at-risk account to
cs_channelwith the customer's name, both usage counts and the renewal date.Write the check-ins, by Your agent
Draft a short plain-text email per account, signed by
signer, that names the drop without blame and offers a call. Show the drafts to the user.
You'll be asked for
The Mixpanel project id
e.g. 2195193
The Mixpanel event that means real usage
e.g. report_created
The Mixpanel user property that holds each account's billing email
e.g. billing_email
The usage drop that counts
e.g. 40%
How soon an annual renewal is
e.g. 90 days
Who signs the check-in emails
e.g. Dana, Customer Success
The Slack channel to escalate in
e.g. #customer-success
at-risk-customer-rescue.mdView markdown
Flag customers whose usage dropped before they renew
Finds accounts whose usage fell in Mixpanel and renew soon in Stripe, alerts customer success in Slack, and drafts a check-in email.
Set up the tools below, then run the steps in order for the user, carrying each step's results into the next. The run is done when the user has the outcome below.
Outcome
- A Slack post in your customer success channel for each at-risk account that renews soon, with both usage counts and the renewal date.
- A drafted check-in email for each of those accounts, signed by the person you choose.
- The accounts ordered by renewal date, with the billing emails that matched no Stripe customer.
Inputs
Ask the user for these before you start.
mixpanel_project: the Mixpanel project id, e.g. 2195193usage_event: the Mixpanel event that means real usage, e.g. report_createdaccount_email_property: the Mixpanel user property that holds each account's billing email, e.g. billing_emaildrop_threshold: the usage drop that counts, e.g. 40%renewal_window: how soon an annual renewal is, e.g. 90 dayssigner: who signs the check-in emails, e.g. Dana, Customer Successcs_channel: the Slack channel to escalate in, e.g. #customer-success
Set up
Run a query (Mixpanel, tool:mixpanel/run-query)
Use the MCP server. Add it to your agent's MCP settings, then sign in when asked.
{ "mcpServers": { "mixpanel": { "url": "https://mcp.mixpanel.com/mcp" } } }
Call the MCP tool Run-Query.
Note: An organization admin enables MCP in Settings > Org > Overview first. EU and India projects use https://mcp-eu.mixpanel.com/mcp and https://mcp-in.mixpanel.com/mcp.
Note: Call Get-Query-Schema first for the full JSON schema of a query.
Stripe (tool:stripe/list-customers, tool:stripe/list-subscriptions)
Use the first option your agent supports.
Notes:
- List customers: The
emailfilter is case-sensitive.
MCP (official, remote)
Add this server to your agent's MCP settings, then sign in when asked.
{ "mcpServers": { "stripe": { "url": "https://mcp.stripe.com" } } }
- List customers: call the MCP tool
stripe_api_readwithGET /v1/customers - List subscriptions: call the MCP tool
stripe_api_readwithGET /v1/subscriptions
CLI (official)
Install the command and sign in with it, then confirm it runs.
npm install -g @stripe/cli
stripe --version
- List customers: run
stripe customers list - List subscriptions: run
stripe subscriptions list
Post a message (Slack, tool:slack/post-message)
Use the first option your agent supports.
Note: Needs the chat:write scope. Over MCP it posts as the signed-in user; the API and CLI post as the app's bot.
MCP (official, remote)
Add this server to your agent's MCP settings, then sign in when asked.
{ "mcpServers": { "slack": { "url": "https://mcp.slack.com/mcp" } } }
Call the MCP tool slack_send_message.
CLI (official)
Install the command, then confirm it runs.
curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash
slack --version
Run slack api chat.postMessage.
Set $SLACK_BOT_TOKEN in your environment first (get a key: https://api.slack.com/apps).
Before step 1, confirm access to each service with its cheapest read-only call, like a list or a search. Never send or change anything to test access.
Steps
- Detect drops with Run a query (Mixpanel). In
mixpanel_project, countusage_eventbroken down byaccount_email_propertyfor the last 30 days and the 30 days before; a billing email missing from the last 30 days counts as 0. Keep each billing email whose count fell by more thandrop_threshold, with both counts. - Find their customers with List customers (Stripe). Look up each billing email, as stored and lowercased. Keep each customer's ID and name; note the emails with no customer.
- Check renewals with List subscriptions (Stripe). For each customer, list active subscriptions that are not set to cancel at period end. Keep the yearly ones whose subscription item's
current_period_endfalls withinrenewal_window, with that date. - Escalate with Post a message (Slack). Post one message per at-risk account to
cs_channelwith the customer's name, both usage counts and the renewal date. - Write the check-ins yourself. Draft a short plain-text email per account, signed by
signer, that names the drop without blame and offers a call. Show the drafts to the user.
Rules
- Use only the services set up above. The read-only calls they need, like listing ids or polling for results, are fine.
- Ask the user before anything that sends messages, costs money, or changes data, and say how many records it touches. One approval covers a batch the user has seen.
- Never print API keys.
