Text customers via ClickSend when Stripe payments fail

By General Input

When a Stripe invoice payment fails, send the customer a polite ClickSend text with a link to update their card, and log the attempt in HubSpot.

Integrations

  • ClickSend
  • Stripe
  • HubSpot

Type

Deterministic Code

Categories

  • Finance
  • Operations

Build a deterministic, node-by-node code workflow that recovers failed Stripe subscription payments by texting the customer via ClickSend and logging the attempt in HubSpot. No reasoning or LLM steps are required, this is straight glue.

Trigger: a Stripe webhook on the invoice.payment_failed event. The webhook payload gives us the invoice id, the customer id, and the current attempt count.

Step 1. Call Stripe Retrieve Invoice with the invoice id from the webhook. Pull out amount_due, currency, hosted_invoice_url, attempt_count, and customer_email.

Step 2. Guard clause on attempt_count. Only continue past this step when attempt_count is 1 or 3. For any other attempt (2, 4, 5, etc.), short-circuit the workflow so we never spam the customer on every Stripe retry. This anti-spam gate is the whole point of the workflow.

Step 3. Call Stripe Retrieve Customer with the customer id. Pull out name, email, and phone. If phone is missing or empty, skip the ClickSend step entirely but still continue to the HubSpot logging steps so we have an audit record of a failed payment we could not text about.

Step 4. Call ClickSend Send SMS with a single message to the customer's phone number. Use a templated body like: "Hi {name}, we could not process your {amount} {currency} payment for {business_name}. You can update your card here: {hosted_invoice_url}". Format amount as a human-readable currency string (divide by 100 for USD-style zero-decimal handling, respect Stripe's smallest-currency-unit rule). The business_name should be a configurable constant on the workflow, not derived from Stripe. Phone must be in E.164 with a leading plus.

Step 5. Call HubSpot Get Contact by the customer's email using idProperty=email. If no contact is found (404), record that in the run log and skip step 6 but do not fail the workflow.

Step 6. Call HubSpot Create Note associated to that contact. The note body should record the failed amount, the attempt number, whether an SMS was dispatched (and to what number, masked), and the hosted invoice URL. Use the contact association type appropriate for the notes-to-contact link in HubSpot v3.

Configuration inputs to expose on the workflow: business_name (string, shown in the SMS body), attempt_numbers_to_notify (default [1, 3]), and a masked-phone toggle for the note body.

Idempotency: the Stripe webhook can redeliver, so key the run by (invoice_id, attempt_count). If we have already run this pair, no-op.

Integrations: Stripe (Retrieve Invoice, Retrieve Customer), ClickSend (Send SMS), HubSpot (Get Contact, Create Note). All operations are verified against the platform catalog.

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