Skip to main content

Recover failed Stripe payments with AI emails (by FlyCode)

Workflow preview

Workflow preview
100%
Recover failed Stripe payments with AI emails (by FlyCode) preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

️ Automated Stripe Failed Payment Recovery (with Postmark + AI Email Generator) Recover failed Stripe subscription payments with AI personalized emails sent via Postmark. Template Description R...

Best for

  • Lead Nurturing automation workflows
  • AI Chatbot automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.webhook, n8n-nodes-base.code, n8n-nodes-base.if, @n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.lmchatopenai, n8n-nodes-base.httprequest, n8n-nodes-base.stickynote, n8n-nodes-base.filter

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by FlyCode.

Original n8n.io source

1.1 Workflow description

Title
Recover failed Stripe payments with AI emails (by FlyCode)
Workflow name
Recover failed Stripe payments with AI emails (by FlyCode)

⚙️ Automated Stripe Failed Payment Recovery (with Postmark + AI Email Generator)

Recover failed Stripe subscription payments with AI-personalized emails sent via Postmark.

📝 Template Description

Recover failed subscription payments automatically with Stripe, Postmark, and AI.

This workflow listens for Stripe invoice.payment_failed webhooks, checks that the event is related to an auto-charged subscription, and then automatically sends a personalized email (generated with AI) to the customer. The email is polite, branded, but also urgent — encouraging the customer to pay quickly and avoid service cancellation.


🛠️ How it works

  1. 📣 Webhook
    Listens for Stripe webhook events. Make sure to connect it in your Stripe dashboard (see setup below).

  2. 🧹 Filter (Guard)
    Ensures the event is indeed an invoice event and filters out unrelated webhooks.

  3. 💡 Code Node
    Extracts useful fields (firstName, lastName, customer email, amount, currency, invoice number, hosted invoice URL, subscription description, account name).

  4. ✅ If Node
    Verifies that:

    • Event type = invoice.payment_failed
    • Billing reason = subscription_cycle
    • Collection method = charge_automatically

    👉 This ensures only recurring subscription invoices with auto-payment are processed.

  5. 🤖 AI Agent + OpenAI
    Generates a ready-to-send email JSON (to, subject, HTML body) using the extracted Stripe data.
    ✍️ You can customize the prompt here to match your brand’s tone of voice and style.

  6. 🧩 Code Parser
    Parses the AI model’s JSON output into fields (to_email, email_subject, email_body).

  7. 📧 HTTP Request (Postmark)
    Sends the email using Postmark’s API.
    You’ll need your own Postmark Server Token, From address, and Message Stream.


🚀 Setup Instructions

1. Stripe Webhook

👉 Example docs: Stripe: Listen to events with webhooks.

2. Disable Stripe’s Default Failed Payment Emails

  • In Stripe, go to Billing → Settings → Customer emails → Manage failed payments.
  • Turn off “Failed payment” emails under the Revenue Recovery section.
  • This prevents customers from receiving duplicate or conflicting emails.

3. Postmark Setup

  • Create a Postmark account.
  • Add a Server and copy the Server API Token.
  • In n8n, add Postmark credentials with this token.
  • Configure:
    • From = your verified sending email (must be verified in Postmark).
    • MessageStream = typically "outbound" (or any custom stream you set up).

Docs: Postmark API overview.

4. OpenAI Setup

  • Add your OpenAI credentials in n8n.
  • Attach them to the OpenAI Chat Model node.
  • You can modify the prompt in the AI Agent node to fit your company’s style.

✨ Customization Tips

  • Update the AI prompt with your brand’s tone of voice (friendly, formal, playful, etc.).
  • Adjust the HTML email design inside the prompt (button colors, footer, etc.).
  • Add extra guard conditions (e.g., only trigger if invoice_amount > 0).
  • Change the sending service: replace Postmark with Gmail, SMTP, or another provider.
  • 💬 Or talk to our Billing Recovery Experts at flycode.com for hands-on help.

✅ Outcome

Whenever a customer’s subscription payment fails, this workflow:

  • Detects it instantly via Stripe
  • Generates a polite but urgent recovery email
  • Sends it automatically via Postmark

Result: Fewer cancellations, higher recovered revenue, and a smoother customer experience. 💸💌

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Webhook

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2.1

Block 2 - Code in JavaScript

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 3 - If

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 4 - AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 2.2

Block 5 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 6 - HTTP Request1

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 7 - Code in JavaScript1

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 8 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 9 - Filter

Type / Role
n8n-nodes-base.filter - filter
Config choices
Version 2.2

Block 10 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 11 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 12 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Sticky Note6

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - Sticky Note7

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Recover failed Stripe payments with AI emails (by FlyCode)
Complexity advanced
Nodes 15
Categories Lead Nurturing, AI Chatbot
Author FlyCode
Published 21 Sept 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/8794/8794.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Recover failed Stripe payments with AI emails (by FlyCode) do?

️ Automated Stripe Failed Payment Recovery (with Postmark + AI Email Generator) Recover failed Stripe subscription payments with AI personalized emails sent via Postmark. Template Description R...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Lead Nurturing, AI Chatbot use case.