AI-personalized SMS recovery for failed Stripe payments
When a Stripe payment fails, an agent writes a friendly, customer-specific text with a one-tap link to update the card, then logs the recovery in your billing Slack channel.
Build me an agent workflow that recovers failed Stripe payments with a personalized SMS instead of a generic dunning email, and keeps our billing team in the loop in Slack.
Trigger: a Stripe webhook on the invoice.payment_failed event. The workflow should fire once per webhook delivery.
Step 1 — Gather context. From the webhook payload, take the invoice ID and the customer ID. Use Stripe's Retrieve Invoice operation to pull the amount due, the invoice number, the hosted invoice URL, the next payment attempt date, the current attempt count, and the line items (so we know which product or subscription this is for). Use Stripe's Retrieve Customer operation to pull the customer's name, email, and stored phone number.
Step 2 — Decide what to do. If the customer has no phone number on file, skip the SMS step entirely and go straight to logging in Slack. Otherwise, continue.
Step 3 — Draft the SMS. Write a short, friendly text in the customer's voice, under 320 characters total. It must include the customer's first name, the exact product or subscription name from the invoice line items, the amount due formatted as currency, and the hosted invoice URL so they can update their card in one tap. Shift the tone based on the attempt count: warm and apologetic on attempt one, a little more direct on attempt two, and matter-of-fact on attempt three or later. Do not invent details that are not in the Stripe data.
Step 4 — Send the SMS. Use Twilio's Send a Message operation. The To number is the phone on the Stripe customer record (already in E.164 format if it was collected through Stripe Checkout). The From number is the user's configured Twilio sending number. The body is the SMS the agent drafted.
Step 5 — Post a paper trail. Use Slack Bot's Send a Message operation to post a one-line summary in the configured billing channel (#billing by default). The Slack message should include the customer name, the amount, which attempt this is, whether the SMS went out or was skipped because there was no phone number, and the full SMS body so finance can see exactly what the customer received. Include the hosted invoice URL as a clickable link.
Things the user should be able to configure up front: the Slack channel ID for billing alerts, the Twilio sending phone number, and an optional opt-out line to append to every SMS (for example "Reply STOP to opt out").
Additional information
What does this prompt do?
- Catches every failed Stripe invoice payment the moment it happens.
- Drafts a short, friendly SMS that uses the customer's name, mentions the exact product or subscription, states the amount, and adapts the tone to how many times the card has been retried.
- Texts the customer through Twilio with a one-tap link to update their card on the hosted invoice.
- Posts a one-line summary in your billing Slack channel with the customer, amount, attempt number, and the text that went out, so finance has a clean paper trail.
- If there is no phone number on file, the agent skips the text and still logs the failure in Slack so nothing slips.
What do I need to use this?
- A Stripe account where you can see customers, subscriptions, and invoices.
- A Twilio account with an SMS-capable phone number to send the recovery texts from.
- A Slack workspace and a billing or finance channel where the alerts should land.
How can I customize it?
- Tune the SMS voice and length to match your brand, or add an opt-out line if your customers expect one.
- Decide how the tone should shift across retry attempts, for example friendlier on attempt one and more direct on attempt three.
- Point the Slack summary at a different channel, or send high-value accounts to a dedicated channel for a CSM to call instead.
Frequently asked questions
How is this different from Stripe's built-in dunning emails?
What happens if the customer has no phone number in Stripe?
Will it text the customer on every retry attempt?
Can the agent reference the specific plan or product?
Where do replies to the text go?
Recover more failed payments without writing a single template.
Connect Stripe, Twilio, and Slack once, and every failed invoice triggers a friendly, personalized text and a clean log for your billing team.