Recover failed Stripe payments with OpenAI, Gmail, Sheets and Slack

Go to Workflow
0 views
Built by TakatoYamada TakatoYamada
Created on June 03, 2026

Description

Quick Overview
This workflow triggers on failed Stripe invoice payments, uses OpenAI to generate an escalating dunning email, sends it through Gmail, logs the attempt to Google Sheets, and notifies the owner in Slack when the final reminder threshold is reached.

How it works
Triggers when Stripe emits an invoice.payment_failed event.
Extracts and normalizes key invoice fields like customer email/name, amount due, currency, attempt count, and hosted invoice URL.
Uses OpenAI (GPT-4o-mini) to draft a structured dunning email with a subject and body that escalates tone based on the attempt number.
Sends the generated email to the customer via Gmail with the AI-produced subject and message.
Appends the email attempt details to a Google Sheets spreadsheet for tracking.
If the attempt count is 3 or higher, posts an escalation message to a designated Slack channel.

Setup
Connect your Stripe account in the Stripe Trigger node so it can receive invoice.payment_failed events.
Add OpenAI credentials for the GPT-4o-mini chat model used to generate the dunning email content.
Add Gmail credentials and confirm the sending mailbox used by the Gmail node.
Add Google Sheets credentials and replace the placeholder spreadsheet URL/ID, ensuring a sheet named “Dunning” exists.
Add Slack credentials and set the target channel (for example, #billing) for final-attempt escalation messages.

Nodes Used (6)

Basic LLM Chain
@n8n/n8n-nodes-langchain.chainLlm
Gmail
n8n-nodes-base.gmail
Google Sheets
n8n-nodes-base.googleSheets
OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi
Slack
n8n-nodes-base.slack
Structured Output Parser
@n8n/n8n-nodes-langchain.outputParserStructured