Text dunning iMessages from Sendblue when Stripe charges fail

By General Input

When a Stripe charge fails, send a friendly, AI-drafted iMessage with a retry link from Sendblue and log the attempt on the matching HubSpot contact.

Integrations

  • Stripe
  • Sendblue
  • HubSpot

Type

Agentic Task

Categories

  • Finance
  • Customer Support

Build an agent workflow that recovers failed Stripe payments by texting the customer an iMessage from Sendblue and logging the attempt in HubSpot.

Trigger: a Stripe webhook on the charge.failed event. The webhook payload is the failed charge, including the customer id, amount, currency, and failure reason.

When the trigger fires, the agent should:

1. Call Stripe Retrieve Customer with the customer id from the webhook to get the customer's email and name.

2. Call HubSpot Search Contacts on that email to find the matching contact. Pull back the phone number, lifecycle stage, and any properties that indicate past dunning history (for example, the number of recent failed payment notes on the contact). If no contact is found, stop and do nothing.

3. Decide whether to send. Skip sending if the contact has no phone number, or if the failed amount is below a configurable threshold (default: $10 USD equivalent). When you skip, still record a HubSpot note explaining why no message was sent.

4. Compose the message. Draft a short, friendly iMessage that opens with the customer's first name, explains that the card on file just declined on a charge of [amount] for [product or invoice description if available], gives the human-readable failure reason in plain language (for example, "your bank declined the card" instead of generic_decline), and includes a retry payment link. Choose tone based on past dunning attempts: first failure stays casual and apologetic, repeat failures (two or three) get more direct, and after four or more failures keep the tone calm but explicit that the account is at risk.

5. Send the message via Sendblue Send Message to the customer's phone number from your configured Sendblue line. Use E.164 format for the number.

6. Call HubSpot Create Note on the matched contact recording: the failure reason from Stripe, the charge amount and currency, a link to the charge in Stripe, the exact iMessage that was sent, and the Sendblue message id for traceability.

Make the threshold amount and the retry link template configurable inputs so I can tune them without editing the workflow. Where the customer is not in HubSpot, the workflow should exit cleanly and not error.

Related prompts

Explore more prompts
Let support send one-off Loops emails without an engineerTurn Mailjet email clicks into ranked HubSpot follow-upsCustomer lifecycle inspector for Loops, Stripe and PostHogiMessage campaign console with pre-flight checks and delivery boardA searchable RFP answer library your bid team drafts fromSee which target accounts just started advertising on LinkedInAccount health board that puts product usage next to your CRMLook up a customer's full chat history mid conversationLusha prospecting workbench with credit-safe revealsWhich companies your LinkedIn ads reach, matched to your CRM