Send a Stripe failed payment recovery email automatically

By General Input

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.

Integrations

  • Stripe
  • Send Email

Type

Agentic Task

Categories

  • Finance
  • Customer Support

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.

Related prompts

Explore more prompts
Let support send one-off Loops emails without an engineerCustomer lifecycle inspector for Loops, Stripe and PostHogMonth-end Stripe finance pack, stored and shared in SlackRank your Intercom queue by what each customer pays youCatch the trials quietly dying before the card gets chargedWork every open Stripe dispute from one chargeback war roomLook up any customer's support, billing and CRM in one pageInvestor update studio that builds your board deck monthlySell and invoice Ghost newsletter sponsor slots in one boardSupport console that pairs Gladly chats with orders and refunds