{"product_id":"stripe-failed-invoice-recovery-in-n8n-claude-dunning-gmail-alerts","title":"Stripe Failed Invoice Recovery in n8n: Claude Dunning + Gmail Alerts","description":"\u003ch3\u003eRecover failed Stripe payments automatically—while keeping customers informed\u003c\/h3\u003e\n\u003cp\u003eThis n8n workflow listens for \u003cstrong\u003eStripe invoice.payment_failed\u003c\/strong\u003e events, uses \u003cstrong\u003eClaude (Anthropic)\u003c\/strong\u003e to generate stage-appropriate recovery emails, sends them to customers via \u003cstrong\u003eGmail\u003c\/strong\u003e (including the hosted Stripe invoice link), and notifies you internally when the failure reaches the \u003cstrong\u003efinal retry attempt\u003c\/strong\u003e.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eTriggers on failed payments:\u003c\/strong\u003e Starts when Stripe sends an \u003ccode\u003einvoice.payment_failed\u003c\/code\u003e event for a failed invoice payment attempt.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eExtracts invoice details:\u003c\/strong\u003e Pulls attempt count, amount\/currency, next retry date, hosted invoice URL, and customer contact info.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eDetermines the dunning stage:\u003c\/strong\u003e Classifies the attempt as first, repeat, or final to adjust email “angle” and urgency.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eGenerates recovery email content with Claude:\u003c\/strong\u003e Calls the \u003cstrong\u003eAnthropic Messages API\u003c\/strong\u003e to draft a short subject and body using the real invoice amount and retry date.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eEnsures a valid final message:\u003c\/strong\u003e Parses Claude output and appends the \u003cstrong\u003eStripe hosted invoice payment link\u003c\/strong\u003e plus support contact details; if AI output is missing\/invalid, it uses a fallback template.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eSends via Gmail:\u003c\/strong\u003e Emails the customer with the recovery message.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eAlerts on final attempt:\u003c\/strong\u003e If this is the final retry attempt, sends a separate \u003cstrong\u003einternal Gmail alert\u003c\/strong\u003e to the workflow owner.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eSaaS operators who want automated \u003cstrong\u003eStripe dunning\u003c\/strong\u003e that escalates tone from gentle reminders to final notices.\u003c\/li\u003e\n  \u003cli\u003eAutomation engineers deploying reliable \u003cstrong\u003epayment recovery\u003c\/strong\u003e with AI-assisted email drafting.\u003c\/li\u003e\n  \u003cli\u003eTeams that need internal visibility when a payment fails even after the last retry.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eStripe integration:\u003c\/strong\u003e Stripe Trigger configured for \u003ccode\u003einvoice.payment_failed\u003c\/code\u003e (via Stripe webhook).\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eAI generation:\u003c\/strong\u003e \u003cstrong\u003eClaude (Anthropic) Messages API\u003c\/strong\u003e using environment variable \u003ccode\u003eANTHROPIC_API_KEY\u003c\/code\u003e.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eEmail delivery + alerts:\u003c\/strong\u003e Gmail node for both customer emails and internal Gmail alerts.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eLogic \u0026amp; flow control:\u003c\/strong\u003e \u003ccode\u003eif\u003c\/code\u003e, \u003ccode\u003eset\u003c\/code\u003e, \u003ccode\u003ecode\u003c\/code\u003e, \u003ccode\u003eswitch\u003c\/code\u003e, and sticky note annotations.\u003c\/li\u003e\n\u003c\/ul\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":45758758518963,"sku":"N8N-17775","price":56.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/Jll0QhPtTSkujhciOaPqw_ekTXYLWT.png?v=1785834803","url":"https:\/\/buyflowscripts.com\/products\/stripe-failed-invoice-recovery-in-n8n-claude-dunning-gmail-alerts","provider":"N8N Commerce","version":"1.0","type":"link"}