Blog
How to Recover Failed Stripe Payments Automatically (With a Human for the Big Accounts)
Tutorial
ยท
Quick answer: To recover failed Stripe payments automatically, add the BuildShip Stripe Trigger subscribed to invoice.payment_failed, fetch the customer, look the account up in your own database for plan value and owner, then branch. A first failure on a small plan gets a short, friendly update-your-card note written from the facts you pass in. A large account or a repeated failure goes to a person in Slack with context and a draft. The workflow only reads from Stripe. It never changes a subscription, issues a refund or cancels anything.

Cards expire. Banks decline for reasons nobody can explain. And a good customer gets cancelled by accident, which is the worst way to lose one.
Stripeโs own retries and emails help, and you should keep them on. What they canโt do is know who the customer is. A new customer on the smallest plan and a long-time team plan get the same generic message, and the account manager for the second one finds out a month later when the renewal is gone.
So the interesting question isnโt โhow do I email people whose payment failed?โ It is โwho should hear about this, and how?โ That depends on your own data, which is exactly what a workflow with a database lookup can use.
This post builds the routing and the human hand-off. If you want the trigger setup in detail, our earlier guide on triggering an AI agent when a Stripe payment fails walks through the screens.
One failure, two very different customers
Picture two failed invoices on the same morning.
The first is a person on a small monthly plan who signed up three weeks ago. A clear, kind email with a link to update the card is the right response. Nobody needs to be woken up.
The second is a team that has paid every month for two years and has a few hundred seats. An automated template is the wrong response. The account owner should know today, with the history in front of them and a draft ready to edit.
The difference isnโt in Stripeโs event. It is in your own table: plan, monthly value, owner, how long they have been a customer. That is why the second step of the workflow is a database lookup.
What you need
A BuildShip workspace. You can start a 7-day trial (a card is required).
A Stripe account. Build this in Stripe test mode with a test secret key first.
A table of your accounts, for example in Supabase, with email, plan, monthly value, owner and customer-since date.
A Slack channel or user for account owners, and an email node such as Resend or Gmail for the friendly note.
Build it step by step
1. Listen for the failure
Add the Stripe Trigger and subscribe it to invoice.payment_failed. The event list lets you add custom event names, so you can add others later. When you connect, BuildShip creates the webhook in Stripe for you.
2. Get the facts about the customer
Use Get Stripe Event Metadata and Fetch Stripe Customer to pull the name, email and plan details out of the event.
3. Look them up in your own database
Match the customer by email in your accounts table, using Supabase Get Row or the equivalent node for your database. This is where plan value, owner and tenure come from. If you want to keep a copy of Stripe subscriptions in your own tables, this guide shows one way.
4. Pick the route
Add an If/Else on the attempt count and the account value. For example: first failure and monthly value under 200 goes to the friendly note. Anything else goes to a person. The threshold is yours to choose, and it is the most important number in the workflow, so keep it where the team can see and change it.
5. The automatic route: a short, honest note
Ask an AI node to write a note under 90 words that says the payment didnโt go through, how to update the card (a link you keep in an environment variable) and who to reply to. Tell it to use only the facts you pass in and never to invent amounts or dates. Send it with the Send Emails via Resend node or Gmail Send Email.
6. The human route: context and a draft, no email
For large accounts and repeated failures, donโt email the customer. Send a Slack Message to the account owner with the customerโs context and the same draft, so a person can adjust it and send it themselves.
7. Keep a record, and notice the recovery
Save every event with its route in a BuildShip database table. A second workflow with a Stripe Trigger on invoice.paid can post a short โrecoveredโ note to Slack when the money arrives. Because the Stripe trigger supports any event name, that is just another trigger on the same idea.

Above your value threshold, nothing is sent automatically. A person decides.
Prompt to start from in BuildShipโs AI builder
Build a workflow with a Stripe Trigger subscribed to invoice.payment_failed. Get the customer with Fetch Stripe Customer. Look up the customer by email in my Supabase table โaccountsโ (columns: email, plan, monthly_value, owner_slack_id, customer_since). If attempt_count is 1 and monthly_value is under 200, write a short friendly email (under 90 words) telling them the payment did not go through, how to update their card (link from my environment variable BILLING_PORTAL_URL), and who to reply to. Send it with the Resend node. Use only facts from the data, never invent amounts or dates. Otherwise, do not email the customer. Post a Slack Message to the owner with the customerโs context and the same draft, so a person decides. Save every event with its route in a BuildShip database table. This workflow must only read from Stripe and never change a subscription or customer. Use Stripe test mode keys.
Where people stay in charge
The value threshold decides who is in the loop. Above it, nothing is sent automatically. The workflow reads from Stripe and never changes a subscription, refunds anything or cancels anything. It only writes to your own database and sends the messages above. That is a deliberate boundary, and it is worth writing into the prompt, as the example does.
What Iโd test first
Stay in Stripe test mode with a fake customer and a Stripe test card that is set up to fail. Create two test accounts in your table: one small, one large. Trigger a failure for each and confirm the first sends a note youโd be happy to receive and the second goes only to Slack. Open the run log and check what the AI node was given. If it was given facts, the note will use them. If it was given nothing, it will be vague.
One detail to decide early: the link for updating a card. A static billing portal link kept in an environment variable is the simple version. Creating a fresh portal session for each customer is possible too, but that needs an extra API call node.
FAQ
Can BuildShip trigger a workflow when a Stripe payment fails?
Yes. The Stripe Trigger can subscribe to invoice.payment_failed, and the event list lets you add other event names too.
Does this change anything in Stripe?
No. The workflow only reads from Stripe. Any message it sends goes through your email or Slack node.
What about large accounts?
Above the value threshold you choose, or on repeated failures, the workflow sends a draft and context to the account owner in Slack and emails no one.
How do I test it without charging a real card?
Use Stripe test mode, a test secret key and a test card that fails. Nothing real is charged.
How much does it cost to try?
BuildShip plans start with a 7-day trial, and a card is required to start it. See the pricing page for plans and credits.
Start building
The quickest way to learn this is to build it. Start your 7-day trial (a card is required) and start in Stripe test mode. If you liked the idea of putting a person in the loop, see building human-in-the-loop automations with BuildShip. And if you want an assistant that can look up customers on demand, read how to connect Claude or ChatGPT to your database and Stripe with an MCP server.





