Chasing invoices is repetitive, easy to forget and slightly uncomfortable, which makes it a good automation target. It is also a place where a mistake is costly: a wrongly worded or duplicate reminder reaches a client. So the design below drafts reminders for review instead of sending them. This guide builds the workflow node by node in n8n. It assumes you can open the n8n editor and add nodes; no prior n8n experience with Code nodes is needed.
What you need
- An n8n instance (self-hosted Community Edition or n8n Cloud).
- An invoice list with at least these columns:
invoice_id,client_name,client_email,amount,currency,due_date,status,last_reminder_tier. - Dates in ISO format (
2027-01-31). Day-first and month-first formats such as03/04/2027are ambiguous and are the most common source of wrong reminders.
Step 1: a schedule trigger
Add a Schedule Trigger node set to run every day at 08:00. Set the workflow timezone in Workflow settings first (or set GENERIC_TIMEZONE on a self-hosted instance); otherwise "today" is calculated in the instance's default timezone and a reminder can fire a day early or late. For testing, also add a Manual Trigger and connect both triggers to the same next node, so you can click Execute workflow without waiting for 08:00.
Step 2: read the invoice list
For a CSV, use Read/Write Files from Disk (operation Read File(s) From Disk) followed by Extract From File (operation Extract From CSV). Each row becomes one n8n item. Two things trip people up here. First, on n8n 2.x file access is limited to the ~/.n8n-files folder by default, so put the file there (in the official Docker image that is /home/node/.n8n-files) or change N8N_RESTRICT_FILE_ACCESS_TO. Second, the first row of the CSV must be the header row, spelled exactly as above. For a Google Sheet, use the Google Sheets node (Get row(s) in sheet) instead; see Google Sheets credentials and permission errors for the credential setup.
Step 3: decide which reminder each invoice needs
Add a Code node (mode Run Once for All Items, language JavaScript). It skips invoices that are paid, void or disputed, computes days past due, finds the right tier, and drops invoices whose tier was already used:
const order = ['pre_due', 'd1', 'd7', 'd14', 'd30'];
const tiers = [ // checked from the most overdue down
{ key: 'd30', days: 30 }, { key: 'd14', days: 14 },
{ key: 'd7', days: 7 }, { key: 'd1', days: 1 },
{ key: 'pre_due', days: -3 }
];
const today = new Date($now.toISODate() + 'T00:00:00Z');
const out = [];
for (const item of $input.all()) {
const r = item.json;
const status = String(r.status || '').trim().toLowerCase();
if (['paid', 'void', 'disputed'].includes(status)) continue;
const due = new Date(String(r.due_date).trim() + 'T00:00:00Z');
if (isNaN(due)) continue; // unreadable date: handle in a separate "problems" branch
const daysOver = Math.round((today - due) / 86400000);
const tier = tiers.find(t => daysOver >= t.days);
if (!tier) continue; // more than 3 days before the due date
if (order.indexOf(String(r.last_reminder_tier || '').trim()) >= order.indexOf(tier.key)) continue;
out.push({ json: { ...r, days_overdue: daysOver, tier: tier.key } });
}
return out;
Notes on the logic. The tiers are checked from the most overdue down, so an invoice 20 days late gets d14, not d1. Comparing positions in order means a tier fires once: after d7 is recorded, an invoice at day 8 is skipped until it reaches day 14. If the workflow was off for a week, a 9-day-late invoice jumps straight to d7 rather than sending every missed tier.
Step 4: write the reminder
Add a second Code node (or an Edit Fields node) that builds the subject and body from a template per tier. Keep the wording factual: invoice number, amount, due date, how to pay. A reasonable progression:
| Tier | When | Tone | What it says |
|---|---|---|---|
| pre_due | 3 days before due | Heads-up | The invoice is coming due, here is the link. |
| d1 | 1 day late | Friendly | Probably an oversight; invoice attached again. |
| d7 | 7 days late | Polite but clear | Asks for a payment date. |
| d14 | 14 days late | Firm | States the amount outstanding and asks for payment or a reply this week. |
| d30 | 30 days late | Final notice, courteous | Says you will pause work or follow your contract terms if unresolved. |
Only mention late fees or pausing work if your contract says so. Reminder wording is not legal advice, and what you may charge depends on your contract and local law.
Step 5: output a draft, not a sent email
With Gmail credentials added, the Gmail node can create a draft (resource Draft, operation Create) addressed to client_email. Without credentials you can still use the workflow: write each reminder to a text file (Convert to File, then Read/Write Files from Disk Write File to Disk) and copy it into your mail client. Either way, a person presses send. Avoid the temptation to switch to a Send action until you have run the draft version for a few weeks and trust the output.
Step 6: remember what you drafted
Duplicate reminders are the failure that annoys clients most. After drafting, write the used tier back to last_reminder_tier. With Google Sheets, use Append or Update Row matching on invoice_id. With a CSV, the safest approach is to write a new file (for example invoices.next.csv) that you review and then use to replace the original, because n8n cannot edit a single cell in a CSV in place.
Common mistakes
- Skipping partial payments. If you record partial payments, reduce
amountto the balance due, or the reminder will quote the original total. - Treating "due today" as overdue. Use
days >= 1for overdue wording, and keep day 0 in the "not yet late" bucket. - Mixing currencies in totals. Group by currency whenever you add amounts up.
- Silent failures. Add a branch for rows with a missing email, an unreadable date or an amount that is not a number, and list them in a daily "problems" note rather than dropping them.
- Giving an AI model the chance to change facts. If you add an AI rewrite, check that the invoice number and amount are still in the output and fall back to the template text if not.
Test before you trust it
Create a sample CSV with one invoice for each tier plus awkward rows: a paid invoice, a disputed one, a blank email, an amount like "n/a", and a date typed as 13/45/2027. Run the workflow with $now replaced by a fixed date in the Code node and check each result by hand. Then switch back to the real date.
Variations worth considering
- A weekly "who owes me" digest. A second workflow, run on Monday morning, reads the same list and groups unpaid invoices into ageing buckets (not yet due, 1 to 30 days late, 31 to 60, 61 to 90, over 90), with totals per currency. It never contacts anyone; it simply puts the number in front of you.
- Per-client tone. Add a
tonecolumn ("relaxed" or "formal") and choose the template with an IF or Switch node. Long-standing clients often prefer the softer version. - Payment links. Put your payment link and accepted methods in one Config value so every reminder uses the same wording.
- A "problems" file. Each run can write a short note listing rows it could not process: missing email, unreadable date, non-numeric amount. Silent skipping hides exactly the invoices you most need to see.
When a reminder should not be sent at all
Automation does not know that a client called yesterday to say payment is coming Friday, that an invoice is in dispute, or that a client is in hospital. Keep a status value such as hold that the Code node treats like paid, and get into the habit of setting it the moment you have a conversation. Reading the day's drafts before pressing send is the second safety net; it takes about two minutes for a handful of invoices.
How to read the execution log when something looks wrong
Open Executions, click the run, and click each node to see its input and output items. If the Code node outputs nothing, check the input first: is due_date present under that exact name, or did the CSV header contain a hidden space or a byte-order mark? A header that looks like invoice_id but is really \ufeffinvoice_id will make that field "missing". Re-saving the CSV as plain UTF-8 fixes it. If the output has items but the draft is wrong, look at days_overdue and tier on the item, which show which branch of the logic was taken.
Sources
- n8n docs: Schedule Trigger, Gmail node, built-in methods and variables.