Text customers when Stripe payments fail and alert your billing team

When a Stripe payment fails, text the customer a tap-to-pay link and post a structured alert in your billing Slack channel so nothing slips.

Deterministic Code
StripeTwilioSlack BotFinanceOperationsNotifications & Alerts

Build me a deterministic code workflow that runs SMS dunning on Stripe failed payments and alerts our billing team in Slack. No reasoning needed — every step is fixed.

Trigger: a Stripe webhook for invoice.payment_failed (and optionally charge.failed as well). The workflow should fire once per webhook event.

Step 1 — Look up the customer. Take the customer ID from the webhook payload and call Stripe's Retrieve Customer to fetch their name, email, and stored phone number. From the same webhook payload, capture the failed amount, the invoice number, the hosted invoice URL, and the current attempt count.

Step 2 — Send the customer an SMS via Twilio (only if a phone number is present on the customer). Use Twilio's Send a Message operation to send a friendly text that includes the customer's first name, the failed amount formatted as currency, the invoice number, and the hosted invoice URL so they can update their card in one tap. Example tone: "Hi {first_name}, your payment of {amount} for invoice {number} didn't go through. Update your card here: {hosted_invoice_url}." If the customer has no phone number on file, skip the SMS step silently and continue.

Step 3 — Always post a structured alert to our billing Slack channel using Slack Bot's Send a Message. The message should include the customer name, the failed amount, the attempt count, whether the SMS went out or was skipped, and a clickable link to the Stripe invoice so finance can follow up if the SMS retry doesn't work.

Configuration the user should be able to set up front: the Slack channel ID, the Twilio sending phone number, and which Stripe events to subscribe to (invoice.payment_failed only, charge.failed only, or both). Keep the flow deterministic — no LLM calls, no judgement, just fetch and notify.

Additional information

What does this prompt do?
  • Listens for failed Stripe charges and invoice payments the moment they happen.
  • Texts the customer a friendly SMS with their first name, the failed amount, the invoice number, and a one-tap link to update their card.
  • Posts a structured alert to your billing Slack channel with the customer, amount, attempt count, and a direct link to the Stripe invoice.
  • Runs the same way every time, so a failed payment never sits unnoticed in your dashboard.
What do I need to use this?
  • A Stripe account where you can see and manage customers and invoices.
  • A Twilio account with an SMS-capable phone number to send the texts from.
  • A Slack workspace and a channel where your billing or finance team watches alerts.
How can I customize it?
  • Rewrite the SMS copy to match your brand voice, or switch the channel mix to SMS only, Slack only, or both.
  • Point the alert at a different Slack channel, or route high-value customers to a separate channel.
  • Choose which failures trigger the workflow: failed invoice payments, failed one-off charges, or both.

Frequently asked questions

What happens if Stripe doesn't have the customer's phone number?
The SMS step is skipped automatically and the Slack alert still goes out, so your team always sees the failure and can follow up another way.
Will it fire on every retry attempt or only the first one?
Every retry attempt. The Slack alert includes the attempt count, so finance can decide whether to wait for Stripe to retry or step in.
Does this replace Stripe's built-in dunning emails?
No, it runs alongside them. Stripe still sends its retry emails. This adds a faster SMS nudge to the customer and an internal alert for your team.
Can I send WhatsApp instead of SMS?
Yes. Twilio supports WhatsApp, so you can swap the channel without rebuilding the workflow.
Where do customer replies to the text go?
Replies land in your Twilio inbox. If you want a teammate or an AI to read them, you can add a follow-up workflow that listens for incoming messages.

Stop chasing failed payments by hand.

Connect Stripe, Twilio, and Slack once, and every failed payment triggers a friendly text to the customer and a clean alert for your billing team.