Blog / AI training
AI training2 min read
Get an email every morning listing overdue invoices, with Google Apps Script
A short script, free with any Google account, that checks your invoices sheet at 8am and emails you what’s overdue. Paste it in, run it once, and it keeps running on its own.
Google Apps Script is built into Google Sheets, Docs and Gmail, and it’s free with a Google account. A few lines of it can take over a job you do by hand every week. This one checks an invoices sheet each morning and emails you a list of anything overdue and unpaid.
What you need
A Google Sheet with a tab called Invoices, with a header row and these columns in this order: client, invoice number, amount, due date, status. The due date column must contain real dates, not text, and paid invoices should say Paid in the status column.
The script
In the sheet, open Extensions → Apps Script, delete what’s there, and paste this in:
// Email me a list of overdue, unpaid invoices.
function alertOverdueInvoices() {
const sheet = SpreadsheetApp.getActive().getSheetByName('Invoices');
const rows = sheet.getDataRange().getValues().slice(1); // skip the header
const today = new Date();
const overdue = rows.filter(r => r[3] instanceof Date && r[3] < today && r[4] !== 'Paid');
if (!overdue.length) return;
const lines = overdue.map(r =>
`${r[0]} · ${r[1]} · £${Number(r[2]).toFixed(2)} · due ${r[3].toDateString()}`);
MailApp.sendEmail(
Session.getEffectiveUser().getEmail(),
`${overdue.length} overdue invoice${overdue.length === 1 ? '' : 's'}`,
lines.join('\n'));
}
// Run this once to check the script every morning between 8 and 9am.
function scheduleDaily() {
ScriptApp.newTrigger('alertOverdueInvoices').timeBased().atHour(8).everyDays(1).create();
}Turn it on
- Save the project, then choose alertOverdueInvoices from the function menu and press Run. Google will ask you to authorise the script to read the sheet and send email as you.
- Check your inbox. If anything is overdue, you’ll have an email listing it.
- Choose scheduleDaily and press Run once. From now on it runs every morning on its own.
To stop it, open Triggers (the clock icon) in the Apps Script editor and delete the trigger.
Where AI helps
You don’t need to be a programmer to adapt this. Paste the script into Claude, ChatGPT or Gemini and ask for what you want: “Also include invoices due in the next three days,” or “Send it to accounts@ instead of me.” Ask it to explain each change, and test on a copy of your sheet first.
