Send a Stripe failed payment recovery email automatically
When a Stripe charge fails, send the customer a short, plain-English email that explains what happened, how to fix it, and when Stripe will retry.
Build me an agent workflow that automatically sends a recovery email to any customer whose Stripe invoice payment fails.
Trigger: an incoming webhook from Stripe on the invoice.payment_failed event. The workflow should fire the instant Stripe delivers the event, not on a schedule.
When the webhook fires, the agent should:
1. Call Stripe Retrieve Invoice using the invoice id from the webhook payload. Pull the amount due, currency, attempt_count, next_payment_attempt, the hosted_invoice_url (the one-click link the customer uses to update their card and pay), the customer id, and any subscription context (subscription id, plan or product name if available).
2. Call Stripe Retrieve Customer using that customer id to get the customer's name and email address.
3. Draft a short HTML email body. The tone should sound like billing operations, not marketing. No exclamation points, no growth language, no upsell. Keep it under 150 words. Include:
- A clear one-line subject like "Action needed: your payment to {Company} did not go through".
- A greeting using the customer's first name when available, otherwise their full name.
- A plain sentence stating what failed: the amount (formatted nicely from cents, with currency), the invoice or subscription it was for, and the date the charge was attempted.
- A single, prominent call to action button or link pointing to the hosted_invoice_url so the customer can update their card in one click.
- A sentence telling the customer when Stripe will automatically retry (use next_payment_attempt; format as a human-readable date).
- A short sign-off pointing to a billing contact email for replies (the no-reply sender address cannot receive replies).
4. Adjust tone based on attempt_count. For early attempts (1 or 2), keep the message calm and operational: "this happens, here's the fix, no action needed beyond updating your card." If this is the final retry (Stripe will not attempt again, i.e. next_payment_attempt is null or attempt_count indicates the last try), switch to a more urgent framing: "this was the final retry. If your card is not updated, your subscription or service will be paused on {date}." Make the urgency unmistakable but still professional.
5. Use Send Email to deliver the HTML message to the customer's email address. The subject line, body, and recipient should all be set by the agent based on the retrieved Stripe data.
Guardrails: if the invoice has already been paid by the time the webhook is processed (status is paid), or the customer has no email on file, skip sending and log why. Format all currency amounts using the invoice's currency, never assume USD. Always link the customer to Stripe's hosted_invoice_url, never construct your own payment URL.
Additional information
What does this prompt do?
- Catches every failed invoice payment in Stripe the moment it happens.
- Pulls the customer's name, email, amount due, retry attempt number, and next retry date from Stripe.
- Drafts a short, operational recovery email that tells the customer what failed, what's affected, and how to update their card.
- Escalates to an urgent service-pause warning automatically on the final retry attempt.
What do I need to use this?
- A Stripe account with permission to read invoices and customers.
- A verified billing or operations email address you want the recovery messages to come from in the customer's eyes.
How can I customize it?
- Tweak the tone or wording of the email so it matches your brand voice.
- Adjust the urgency thresholds, like switching to the service-pause message on the third attempt instead of the final one.
- Add internal cc or bcc recipients so your finance or success team gets a copy of every recovery email.
Frequently asked questions
When does this email actually send?
Does the email change based on the retry attempt?
Will this email feel like spam to my customers?
Can I send the recovery email from my own domain?
What if the same customer fails multiple invoices?
Stop losing revenue to failed cards you never followed up on.
Connect Stripe once, and Geni sends a clean recovery email to every customer whose payment fails, the moment it fails.