DEV Community

WorkflowStash
WorkflowStash

Posted on

Your invoice chaser is probably annoying your best clients

Your invoice chaser is probably annoying your best clients

A few weeks ago I published the invoice chaser I use myself: a Google Sheet of invoices, a daily n8n run, four reminder stages that get firmer as an invoice ages. It worked. Then I sat down and read it the way a client would receive it, and found the flaw in almost every chasing automation, including mine:

The robot treats every row in the sheet as equally true and equally urgent.

A typo'd email address in the sheet? The chaser cheerfully emails a stranger — or dies trying. The same invoice pasted onto two rows during a sheet cleanup? Two final notices. And the client who has paid you on time for two years, who happens to be 15 days late once because their accounts person is on holiday? They get the same day-14 final notice as the client who has never once paid on time. The automation can't tell the difference, because I never taught it to check anything before it started chasing.

So I rebuilt it. Same four stages, same email templates — but with a safety layer in front of them. The workflow went from 9 working nodes to 21. Here's the build, node by node, including the parts I'd steal for any automation that sends email on your behalf.

The shape of it

The daily habit is unchanged: a Google Sheet with nine columns (Invoice ID, Client name, Client email, Amount, Currency, Due date, Status, Reminders sent, Last reminded), one new tab called Chase Log, and a run at 09:00. You add a row when you send an invoice; you flip Status to Paid when the money lands.

What changed is everything between "read the sheet" and "send the email":

  1. Daily Check (09:00) — schedule trigger.
  2. Read Invoices Sheet — loads the invoice list.
  3. Filter & Stage — keeps only Unpaid invoices that hit a stage today.
  4. Validate Chase Rows → Is Row Valid? → bad rows go to Log Invalid Row (the Chase Log tab) and are never emailed.
  5. Dedupe by Invoice ID → Is Duplicate? → repeats go to Log Duplicate Row; only the first row is chased.
  6. Route by Stage — a Switch with four outputs: pre, due, overdue7, final.
  7. Four Gmail nodes, one per stage, then Update Invoice Row writes back Reminders sent +1 and Last reminded — but only after a successful send.
  8. Collect High-Value Finals → Any High-Value Finals? → Send Owner Alert Digest — one email to you, not to clients.
  9. Prep Send Failure / Log Send Failure — every Gmail node continues on error; failures land in the Chase Log with the error message.

Step 1: validate before you chase

This is the node I now consider non-negotiable in anything that sends email from a spreadsheet. Spreadsheets are typed by humans at 11pm. Humans transpose digits in amounts and paste email addresses with a trailing space, or into the wrong row entirely.

// A staged row is only chased when ALL of these hold:
//   - Client email is present and looks like a real address
//   - Invoice ID (the invoice number) is present
//   - Amount is a number and not negative
// Anything else is written to the Chase Log tab with the reason
// and never reaches Gmail.
const emailRe = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;
const reasons = [];
const emailRaw = String(row['Client email'] || '').trim();
if (!emailRaw) reasons.push('Missing customer email');
else if (!emailRe.test(emailRaw)) reasons.push('Customer email format looks invalid: ' + emailRaw);
if (!String(row['Invoice ID'] || '').trim()) reasons.push('Missing invoice number (Invoice ID)');
const amount = parseFloat(String(row['Amount'] ?? '').replace(/[^0-9.\-]/g, ''));
if (isNaN(amount)) reasons.push('Amount is not a number');
else if (amount < 0) reasons.push('Amount is negative');
row.valid = reasons.length === 0;
row.invalid_reason = reasons.join('; ');
Enter fullscreen mode Exit fullscreen mode

Two details matter here. First, the amount parse strips currency symbols and commas, so $1,280.00 and 1280 both pass — the check is for garbage, not for formatting pedantry. Second, a failed row isn't dropped silently: it's appended to the Chase Log with every reason found ("Customer email format looks invalid: david@northpeak" — you can see the missing .com immediately). Fix the row in the sheet and the next daily run picks it up again. The log is the workflow's way of saying "these ones need a human," and it's the tab I actually check once a week.

Step 2: dedupe by invoice number

Sheets accrete duplicate rows — a copy-paste during cleanup, an import that ran twice. In v1, a duplicated invoice got chased twice, which is exactly the kind of thing that makes a good client feel harassed by a robot.

The dedupe node groups the staged rows by Invoice ID within the run. The first row in sheet order is chased; every later row with the same number is logged as a duplicate and skipped. One invoice number gets at most one chase email per stage per day, no matter how messy the sheet gets.

Step 3: the four stages (unchanged, deliberately)

The chasing sequence itself didn't change, because it wasn't the problem:

Stage Sent when Tone
pre Due date is exactly 3 days away Friendly heads-up
due On the due date Neutral, helpful
overdue7 Exactly 7 days overdue Firmer, asks for a date
final 14+ days overdue Final notice

The guards from v1 still apply: only Status = Unpaid rows are ever considered (park a row as On hold or Disputed and it will never be chased), a maximum of 4 reminders per invoice, and at least 3 days between reminders so a manual re-run can't double-send.

Step 4: escalate to a human — once a day, in one email

Here's the part that fixes the "annoying your best clients" problem, and it's aimed at the owner, not the client.

The final notice is the email most likely to damage a relationship, and in v1 it just… went out. I might not notice for days that my best client had received one. The obvious fix — email me every time a final notice is sent — creates a new problem: five final notices in a morning means five alert emails, and alert fatigue means I stop reading them by Thursday.

So the escalation collects instead. After the sends, one Code node gathers the day's final notices at or above a threshold:

// Final-notice invoices at or above this amount are collected into
// ONE daily alert email to you. Amounts are compared in each
// invoice's own currency, exactly as written in the sheet.
const OWNER_ALERT_THRESHOLD = 500;
const hits = rows.filter(j => j.stage === 'final' && Number(j.amount_num || 0) >= OWNER_ALERT_THRESHOLD);
Enter fullscreen mode Exit fullscreen mode

If there's at least one hit, I get a single digest: invoice number, client, amount, due date, days overdue, one line each. The $80 invoice from the chronically late client still gets its final notice from the sequence — that's what the sequence is for. But the $2,100 final notice to the client who's never been late before lands in my inbox the same morning, while I can still pick up the phone and have the "is everything OK?" conversation instead of letting the robot have it.

The threshold is one constant at the top of the node. Set it to whatever "big enough that I'd want to know" means in your business.

Step 5: failures are logged, not fatal

Every Gmail node in v2 is set to continue on error. A failed send is shaped and appended to the Chase Log with the Gmail error message, and — this is the important part — the invoice row is not marked as chased, because the write-back node only runs after a successful send.

That interacts with the stages in a way worth knowing: the final stage covers every day from day 14 onward, so a failed final notice retries naturally on the next run. The exact-day stages (pre, due, overdue7) can't retry — their day has passed — so if one of those fails, the Chase Log entry is your cue to chase that one by hand. I'd rather tell you that here than let you discover it.

Honest limits

  • It only knows what the sheet knows. Forget to flip a paid invoice to Paid and it will chase someone who has paid. The automation removes the writing-and-remembering work, not the two-second status update.
  • Gmail caps daily sends (roughly 500/day on a consumer account, 2,000 on Workspace). The once-a-day staged design keeps normal invoice volumes far below that.
  • The workflow file is structure-checked — valid JSON, standard n8n node types, every connection reviewed — and its staging, validation, dedupe and digest logic was exercised offline against sample invoices. It has not been import-tested on a live n8n instance. The setup guide walks you through a first run against your own email address; do that before it ever touches a real client.

Where to get it

The free workflows live here: https://github.com/newbeechong-glitch/free-n8n-workflows

The packaged version of this one — the v2 workflow file, the sheet template, all four email templates written out in full, and a setup guide with the testing checklist — is the Invoice Chaser on Ko-fi for $19. If you bought v1, the v2 file is a free re-download from the same product page; your sheet carries over, you just add the Chase Log tab.

And if you'd rather have a workflow like this built around your own invoicing setup instead of adapting a template, that's the Custom n8n Workflow Build service — $99, built to your forms and tools.

Either way: check your rows before you chase them. Your best clients will never know you did — which is rather the point.

Top comments (0)