DEV Community

WorkflowStash
WorkflowStash

Posted on

I automated the invoice-chasing emails I kept putting off (n8n + Google Sheets)

I automated the invoice-chasing emails I kept putting off

The worst email in my week was never the angry one. It was the polite one: "Hi, just following up on invoice 1042…" I would draft it at 11pm, decide it sounded either too soft or too desperate, and send it three days later than I should have. Multiply that by every open invoice and I was basically running an accounts-receivable department out of guilt and browser tabs.

So I built the thing I actually needed: a workflow that reads a spreadsheet of invoices once a day, works out which ones are due for a nudge, and sends the nudge — friendly early, firmer later, and it stops the second an invoice is marked paid. That last part is the whole point, and it's where my first version nearly went wrong. More on that below.

The setup: a boring spreadsheet, on purpose

No invoicing platform, no API keys from an accounting tool. Just a Google Sheet with nine columns:

Invoice ID, Client name, Client email, Amount, Currency, Due date, Status, Reminders sent, Last reminded
Enter fullscreen mode Exit fullscreen mode

My daily habit shrank to two things: add a row when I send an invoice, flip Status to Paid when the money lands. Everything else is the workflow's job. You can also park a row as On hold or Disputed, and it will never be chased — useful when a client emails you saying the amount looks wrong and you need the robot to shut up while you talk it through like a person.

The workflow, node by node

Nine nodes total. Nothing exotic.

1. Daily Check (Schedule Trigger) — fires at 09:00. Chasing email at 9am on a weekday looks like business. Chasing email at 11pm looks like me, panicking, which is what we're replacing.

2. Read Invoices Sheet (Google Sheets) — pulls every row.

3. Filter & Stage (Code) — this is where all the judgement lives. For each row it computes the days between today and the due date, and only lets a row through if it lands in one of four buckets:

  • pre — due in exactly 3 days
  • due — due today
  • overdue7 — exactly 7 days overdue
  • final — 14 or more days overdue

4. Route by Stage (Switch) — sends each invoice down one of four paths.

5a–5d. Four Gmail nodes, one per stage, each with its own template. The tone escalates on purpose. The pre-due note is basically a favour ("if it's already in your payment run, ignore this"). The day-7 note stops being cute and asks a direct question: pay this week, or tell me the date you will. The final notice says what happens next — and I had to edit that one carefully, because a template should never promise consequences (pausing work, collection, late fees) that your actual contract doesn't allow. A robot sending threats you can't back up is worse than no robot.

6. Update Invoice Row (Google Sheets) — writes back Reminders sent +1 and Last reminded = today, matched by Invoice ID. This node looks like bookkeeping. It is actually the safety system.

The edge case that broke version one

My first version matched stages by exact day for all four buckets — including the final notice, which only fired on day 14 precisely. Then I added a test invoice that was already 20 days overdue (the way real invoices actually arrive in a sheet: late, imported from somewhere else, found in a drawer). It sailed through the workflow and got… nothing. It wasn't 3 days early, wasn't due, wasn't day 7, wasn't day 14. It was day 20, and day 20 didn't exist.

Two fixes came out of that:

  1. The final bucket is now 14 or more days, not exactly 14.
  2. Every stage also checks the guards before sending: Status must be exactly Unpaid, Reminders sent must be under 4, and the last reminder must be at least 3 days ago.

That third guard is the one I'd defend in an argument. Because the workflow writes Last reminded back to the sheet, re-running it manually — say you fix a typo and hit Execute again — can't double-send. And the paid check is absolute: the filter only ever looks at Unpaid rows. The scenario that kept me honest while building this was a client paying on day 6 and getting the firm day-7 email anyway because I'd forgotten to update something. With this design there's exactly one thing to update, the Status cell, and it's the same cell I was already maintaining by hand.

Testing it without embarrassing yourself

Before this ever touched a real client, I ran it against myself: a test row with my own email, due date set to today + 3, so it hit the pre stage. Got the friendly email. Ran it again immediately — nothing, the 3-day spacing guard blocked it. Then I changed the due date to 7 days ago, cleared Last reminded, and got the firmer one. Only after all three behaved did I switch it on.

Honest limits

A few, so nobody oversells this in either direction:

  • It only knows what the sheet knows. If you forget to flip a paid invoice to Paid, it will chase a person who has paid. The automation removes the writing-and-remembering work, not the two-second status update.
  • Gmail has daily sending caps (roughly 500/day on a consumer account). Fine for a freelancer's invoice volume, not fine for a 2,000-invoice billing run.
  • The workflow file itself: I built it from standard n8n node types and structure-checked the JSON carefully, but I haven't run a live import test on a production n8n instance — which is exactly why the self-test routine above exists, and why you should do it with your own email first.

Steal the pattern

The general shape — read a sheet, bucket rows by days-since-a-date, act per bucket, write back what you did — works for anything with a due date and an awkward follow-up attached: contract renewals, trial expiries, "you left this document unsigned" nudges.

If you want to poke at working examples, I keep a few free n8n workflows here: github.com/newbeechong-glitch/free-n8n-workflows. And if you'd rather skip the building part, the packaged version of this one — workflow file, the sheet template, all four email templates written out, setup guide with the testing checklist — is the Invoice Chaser on my Ko-fi shop for $19.

Either way, send the polite email on time. That's the entire trick.

Top comments (0)