Post #3 Companion — The CFO & AI Series

The Agent That Chases Invoices
So You Don't Have To

30% of a solo accountant's week goes to AR and invoicing. This agent monitors your overdue invoices, ranks them by risk, and writes the reminder emails — automatically.

📄 Boris Dračka · ⏱ 5 min read · 📦 Code on GitHub

This is a personal, non-commercial side project I built to learn — not a product or service, and not connected to any company I work with.

30% Of week on invoicing & AR
12h Saved per accountant per week
Monday 7:00 AM — runs automatically
The problem
Where 30% of the week actually goes

In Post #3, I showed you the time breakdown of a typical solo accountant in a 50-person company. The biggest single category — 30% of the week — is invoicing and accounts receivable.

That's 12 hours every week spent on: checking which invoices are overdue, figuring out who to chase, writing reminder emails, following up again when there's no response. Manually. Repeatedly. Every single week.

One accountant's week  ·  40 hours  ·  where the time goes
Invoicing & AP/AR
30%
Payroll & HR admin
20%
Month-end close
20%
Tax & compliance
15%
Ad hoc requests
10%
Forecasting & analysis
5%

"The highest-value work — forecasting, scenario analysis, proactive cash management — gets 5% of the time. Because the other 95% is already spoken for."

This is what the Overdue Invoice Agent addresses. It doesn't replace the accountant. It takes the 30% that doesn't require judgment — and handles it automatically.


Step 2 & 3 output
What the agent sees every Monday morning
The agent reads your invoice data, detects what's overdue, and ranks everything by financial risk — before anyone arrives at the office.
invoices.csv — Overdue Analysis Monday 07:00
€104,900 Total at risk
8 Overdue invoices
3 Critical (60d+)
2 Warning (30–60d)
# Invoice Client Amount Overdue Status Risk Score
1 INV-003 Gamma s.r.o. €31,000 81 days Critical
2,511,000
2 INV-007 Eta Solutions €22,000 97 days Critical
2,134,000
3 INV-005 Epsilon Ltd €15,000 10 days Watch
150,000
4 INV-001 Acme Corp €12,500 64 days Critical
800,000
5 INV-004 Delta AG €8,200 25 days Warning
205,000
6 INV-006 Zeta Corp €6,400 7 days Watch
44,800
7 INV-002 Beta GmbH €4,800 45 days Warning
216,000
8 INV-008 Theta GmbH €3,200 3 days Watch
9,600

Step 4 output
What the AI reminder email looks like
For each overdue invoice, the agent writes a personalized reminder — tone adjusted to severity. Critical invoices get a firm email. First-time reminders stay polite.

How it works
5 steps. Every Monday. Automatic.
The agent runs without any human trigger. By 7:15 AM, the accountant has a full overdue report with draft emails ready to review or send.
1
🔌
Pull invoice data
Reads your invoice file — CSV, Google Sheet, or ERP export. Invoice ID, client name, amount, due date, payment status. No manual preparation needed.
CSV · Google Sheets · ERP export
2
🔍
Detect overdue invoices
Compares each invoice due date against today's date. Classifies every overdue invoice into three severity tiers: Critical (60+ days), Warning (30–60 days), Watch (< 30 days).
🔴 Critical · 🟡 Warning · 🟢 Watch
3
📊
Prioritize by financial risk
Calculates a risk score for each invoice: Amount × Days overdue. A €31,000 invoice that's 81 days late ranks above a €5,000 invoice that's 90 days late. The accountant sees the highest-impact items first.
Risk score = Amount × Days overdue
4
🤖
Generate personalized reminders
For each overdue invoice, Gemini AI writes a tailored reminder email. The tone adapts to severity — polite for first reminders, firm and urgent for invoices past 60 days. Client name, invoice number, and amount are included automatically.
Gemini API · Tone by severity · Personalized per client
5
📬
Deliver summary to the accountant
Sends one email to the accountant with the full overdue report: totals, severity breakdown, and all draft reminder emails ready to copy, review, and send. No chasing. No manual writing.
Email delivery · Draft reminders included

Build it yourself
How to set this up in 30 minutes
You need Python, a free Gemini API key, and a spreadsheet with your invoices. That's it.
1
Clone the repo and install dependencies
terminal
# Clone the repository
git clone https://github.com/LuliBobo/cfo-agents.git
cd cfo-agents

# Install the two required packages
pip install -r requirements.txt
2
Add your invoice data
data/invoices.csv
# Edit this file with your real invoices
invoice_id,client,amount_eur,due_date,contact_email,status
INV-001,Acme Corp,12500,2026-04-01,finance@acmecorp.com,unpaid
INV-002,Beta GmbH,4800,2026-04-20,ap@betagmbh.de,unpaid
INV-003,Your Client,31000,2026-03-15,billing@client.com,unpaid
3
Configure your API key and email
.env
# Copy the template and fill in your values
cp .env.example .env

# .env file contents:
GEMINI_API_KEY=your_key_from_aistudio.google.com
SENDER_EMAIL=your@gmail.com
SENDER_PASSWORD=your_gmail_app_password
RECIPIENT_EMAIL=accountant@yourcompany.com
COMPANY_NAME=Your Company Name
4
Run the agent and see the output
terminal
# Run it manually first to test
python invoice_agent.py

# You'll see output like this:
══════════════════════════════════════════════════════
  Invoice Agent — Overdue AR Monitor
  2026-06-05 07:00
══════════════════════════════════════════════════════

[Step 1] Pulling invoice data from: data/invoices.csv
  ✓ Loaded 8 invoices
[Step 2] Detecting overdue invoices...
  ✓ Found 8 overdue invoices
    [CRITICAL] INV-003 — Gamma s.r.o. — €31,000 — 81d overdue
    [CRITICAL] INV-007 — Eta Solutions — €22,000 — 97d overdue
[Step 3] Prioritizing by financial risk...
[Step 4] Generating AI reminder emails...
  ✓ Generated reminder for Gamma s.r.o.
[Step 5] Delivering report...
  ✓ Report sent to accountant@yourcompany.com
5
Automate — runs every Monday at 7:00 AM
.github/workflows/overdue_check.yml
on:
  schedule:
    - cron: '0 7 * * 1'   # Every Monday 7:00 AM UTC
  workflow_dispatch:        # Or run manually from GitHub

# Add your secrets in GitHub:
# Settings → Secrets → GEMINI_API_KEY, SENDER_EMAIL, ...

Under the hood
Built with 3 tools you already know

📊 Data source

A simple CSV file with your invoice data. Export it from any accounting system or keep it as a Google Sheet.

invoices.csv → Python

🧠 AI model

Google Gemini writes the reminder emails. Free tier handles weekly runs without any cost.

gemini-2.0-flash

⏰ Scheduler

GitHub Actions runs the agent every Monday morning. No server, no infrastructure, completely free.

cron: '0 7 * * 1'

📬 Delivery

One email to your accountant with the full report and all draft reminders ready to review and send.

Gmail SMTP

Get the full
source code

The complete Invoice Agent is in the same repository as the CFO Report Agent from Post #2. Clone it once — get both agents.

github.com/LuliBobo/cfo-agents

What's in the repository

  • invoice_agent.py — complete 5-step pipeline
  • cfo_agent.py — Weekly CFO Report from Post #2
  • data/invoices.csv — sample invoice data to test immediately
  • GitHub Actions workflow — runs every Monday at 7:00 AM
  • README with full setup guide (30 minutes)