See llms.txt for all machine-readable content.

Back to Templates

Run Stripe dunning and revoke access with Gmail, Telegram and Sheets

Quick overview

This workflow receives Stripe billing webhooks, verifies the Stripe signature, and then either revokes access for refunds/disputes or runs a multi-step dunning sequence for failed invoice payments, sending Gmail emails, alerting via Telegram, and logging the event to Google Sheets.

How it works

  1. Receives a POST webhook from Stripe and reconstructs the signed payload to validate the Stripe webhook signature with an HMAC check.
  2. Rejects requests with an invalid signature by returning a 401 response.
  3. Parses the Stripe event into a simplified billing record and routes execution based on the event type (charge.refunded, charge.dispute.created, or invoice.payment_failed).
  4. For refunds and disputes, calls your app API to look up the customer and revoke access, then cancels the related Stripe subscription.
  5. Emails the customer via Gmail about the closure and sends a Telegram alert to finance, then appends the event details to a Google Sheets “Billing Events” tab.
  6. For failed payments, sends an initial dunning email via Gmail, waits two days, checks Stripe for an open invoice, and sends a second notice if still unpaid.
  7. Waits four more days, sends a final notice, pauses the Stripe subscription, and sends a Telegram notification that dunning has finished.

Setup

  1. Create a Stripe webhook endpoint subscribed to charge.refunded, charge.dispute.created, and invoice.payment_failed, then set the webhook URL to this workflow and paste the signing secret into the HMAC secret field.
  2. Configure an HTTP Header Auth credential for Stripe API requests (Bearer secret key) and replace YOUR_APP_DOMAIN plus the /api/customers/{id} and /api/customers/{id}/revoke endpoints to match your application.
  3. Add a Gmail credential for sending customer emails and replace YOUR_BILLING_PORTAL_URL in all dunning email bodies.
  4. Add a Telegram credential, set YOUR_TELEGRAM_CHAT_ID for finance/owner notifications, and ensure your Google Sheets credential and spreadsheet ID contain a “Billing Events” sheet tab.