Blog · · 5 min read

How to remind customers when a recurring card payment fails with n8n and AI

Step-by-step guide to having n8n check your failed charges in Google Sheets every morning, spot declined recurring cards and use AI to draft a polite retry reminder in Gmail.

In a gym, academy, small SaaS or any business with recurring dues the card charge fails… and nobody notices in time. The customer thinks they are still paying, you lose the fee and, by the time you catch it, weeks have gone by.

In this guide you'll build an n8n workflow that checks a charge log in Google Sheets every morning (a Stripe or Lemon Squeezy export pasted in, or your own payment log), spots recent declines and uses AI to draft a polite retry reminder in Gmail. You review the draft and send it.

This is not the same as an unpaid invoice reminder: there the invoice is already issued and unpaid; here the automatic card charge failed (insufficient funds, expired card, bank block) and you want to recover the payment without sounding like a debt collector.

What you're going to build

A five-step workflow that runs on its own every day:

  1. Daily trigger: a Schedule Trigger node runs at 09:20.
  2. Read failed charges: a Google Sheets node reads your "Failed charges" sheet.
  3. Status filter: a Code node keeps only recent declines that have not yet hit the reminder cap.
  4. AI reminder: a Basic LLM Chain writes a warm email that explains the failure, asks to update the card and how to retry.
  5. Draft and log: Gmail creates the draft and Google Sheets records the stage in reminder_sent.

What you need

  • An n8n instance (cloud or installed free on your computer).
  • Google Sheets and Gmail connected in n8n.
  • An OpenAI or other AI API key, with a monthly spend limit set in the provider's dashboard.
  • A "Failed charges" sheet with columns: customer, email, plan, amount, failed_on (YYYY-MM-DD), reason (optional: funds, expired, declined), payment_link (optional), notes and reminder_sent (empty or 1 / 2).

You can fill the sheet by pasting a Stripe or Lemon Squeezy CSV export each morning, or with another n8n flow that writes failed-payment webhooks there. This guide assumes the rows are already in Sheets.

Step 1: prepare the failed-charges sheet

Keep failed_on in a consistent date format and only leave rows that are real declines (not refunds or voluntary cancellations). Put your customer-portal or card-update checkout link in payment_link when you have one; leave it blank otherwise so the prompt won't invent one. Use notes for useful preferences ("prefers WhatsApp", "already called the bank").

Step 2: trigger and read

Add a daily Schedule Trigger at 09:20 (check that the workflow timezone in Settings is correct for you). Connect it to Google Sheets → Get Row(s) on your "Failed charges" sheet.

Step 3: filter declines that still need a reminder

Add a Code node (Run Once for All Items) with this code:

const today = new Date(); today.setHours(0, 0, 0, 0);
const out = [];
for (const i of $input.all()) {
  const c = i.json;
  if (!c.email || !c.failed_on) continue;
  const days = Math.round((today - new Date(c.failed_on)) / 86400000);
  if (days < 0 || days > 14) continue; // only declines from the last 2 weeks
  const already = Number(c.reminder_sent || 0);
  let stage = null;
  if (already < 1 && days >= 0) stage = 1;        // first reminder when detected
  else if (already === 1 && days >= 3) stage = 2; // second reminder after 3+ days
  if (!stage || stage > 2) continue;
  out.push({ json: { ...c, days, stage } });
}
return out;

Each failed charge gets at most two reminders. If nothing is pending, the workflow ends without calling the AI.

Step 4: draft the reminder with AI

Add a Basic LLM Chain with a small, cheap model (for example gpt-4o-mini) and this prompt:

You work at [BUSINESS NAME]. Write a short email to
{{ $json.customer }} letting them know that the recurring charge for their
{{ $json.plan }} plan (amount {{ $json.amount }}) failed on {{ $json.failed_on }}
({{ $json.days }} days ago). Known reason (if any): {{ $json.reason }}.
Link to update the card or retry payment (include it if present; if empty, do not invent one): {{ $json.payment_link }}
Notes: {{ $json.notes }}
- Warm, professional tone, max 6 sentences.
- Explain the failure without blame or alarm; invite them to update the card or reply.
- If payment_link exists, invite them to fix it in one click; otherwise ask them to reply to this email.
- Do not invent amounts, discounts, cut-off dates or links that are not in the data.
Return only the email body.

The facts come from your sheet; the AI only sets the tone. If your gateway already sends the first automatic email, use this flow only for a polite second reminder.

Step 5: create the draft and mark the reminder

Connect a Gmail → Create Draft node with recipient {{ $('Code').item.json.email }}, subject We couldn't charge your {{ $('Code').item.json.plan }} and the AI text as the body. Drafts let you review before sending, just like subscription renewal reminders or contract renewal reminders.

Then a Google Sheets → Update Row node that looks up by email + failed_on and writes the stage into reminder_sent.

Once you trust the wording, you can switch Create Draft to Send.

How to test it

  1. Add a test row with your own email and a failed_on of today, with reminder_sent empty.
  2. Run the workflow by hand and check that a draft appears and reminder_sent becomes 1.
  3. Run it again: no new draft should be created.
  4. Change failed_on to 4 days ago (leaving reminder_sent at 1) and confirm the second reminder is prepared.

Cost and good practices

  • Cost: each reminder costs well under a tenth of a cent on the AI API. Set a monthly spend limit in the provider's dashboard.
  • Don't nag: at most ~2 reminders per failed charge; if they don't reply, log it and hand them to a win-back inactive customers flow or a human call.
  • Don't invent payment links: if payment_link is empty, the prompt asks them to reply to the email.
  • Catch failures: add an error workflow so you know if Gmail or Sheets fails, as in n8n error handling.
  • Combine it with subscription renewal reminders to warn before the charge, and with unpaid invoice reminders if the decline has already become an open invoice.

Start with ready-made templates

If you'd rather skip the basic n8n setup, download the WhatsApp agent for free or check out the AgentKiosk pack: 8 ready-to-import agents in English and Spanish, each with workflow, prompt and guide, ready to combine with these failed-payment reminders.