# How we follow up on invoices that are past due

Our receivables agent on Machine works with Stripe, email and the accounting ledger. It spots late invoices, sends the right reminder, records each contact and reconciles payments as they arrive.

Canonical page: https://themachine.myapps.ai/use-cases/ar-chaser

Following up on late invoices is a chore that never quite ends, yet it still
asks for good judgment. Most of it is easy: a bill is a few days overdue, you send
a friendly nudge, the money arrives. But when to write, how firm to sound and when
to escalate all depend on how late the bill is and how big. And a few accounts are
delicate enough that no automatic email should leave until someone has checked it.

So an agent on Machine handles the follow-ups for us, once a day. Here's how we
collect what we're owed, including what it's connected to and the rails that keep
it safe.

- **Team:** Machine
- **Runs on:** A timer that fires once each morning
- **Connected systems:** Stripe · Email · Accounting ledger
- **Mode:** Mostly reads · reminders and status notes can require sign-off

## The problem

Money owed to you slips through when nobody has a spare hour to go down the list
each day. An invoice is a week late, then a fortnight, and the note that should
have gone out on the first day just doesn't. Bills that deserve a sterner message
get the same bland email as ones that are barely overdue. Meanwhile the delicate
cases, like a big balance, a line the customer disputes or an account on its way
to legal, are chased exactly like everything else.

The usual answers only go part of the way. Stripe's own reminders run on a set
schedule and ignore how large the balance is or what's going on with the account.
A spreadsheet plus a calendar alert only works if somebody actually sits down with
it. And a one-size automation emails everyone the same thing, with no way to hold
back the risky ones.

## What we built

A timer on Machine wakes an agent each morning. It opens a **session**: a fresh
cloud computer (a sandbox) used only for that run, with narrow access to Stripe,
our email and the accounting ledger. The agent finds every invoice that's late or
about to be. For each one it picks the reminder that fits how overdue and how
large the balance is, sends it and records the contact. When payment comes in, it
reconciles the invoice. Anything delicate pauses for a person to approve before it
goes out.

## How it works

### Kick off one run every morning

A **cron trigger** (a timer) goes off once a day and creates a brand-new
**session** in a sandbox of its own. Every run starts the receivables list from
the top, so there's no leftover state from yesterday. If a morning gets skipped,
the next run simply carries on. One run, one session, one throwaway computer.

### Write down how you collect

How we collect is written down in **skills** and **memory**, the playbook the
agent keeps and improves. It covers how often to send reminders at each stage of
lateness, how the tone builds from a first notice to a final one, which balance
sizes call for a different approach, and which accounts are marked disputed or
sensitive. When we change our approach, we update the playbook, and the next run
follows it.

### Hook up Stripe, email and the ledger

The agent uses **connectors**: scoped connections to your tools, with keys held on
the server so the model never sees a raw token. With them it can:

- **Pull invoices from Stripe**: what's late, what's coming due, and how big and
how old each balance is.
- **Email reminders**: the right step-up notice for each invoice, sent from the
agent's own address.
- **Check the accounting ledger**: confirm balances and reconcile them with what
Stripe shows.
- **Record each contact and status note**: every reminder and every
reconciliation, filed against its invoice.

### Hold the delicate ones for a person

The agent is **read-mostly**. It reads Stripe and the ledger, and the only things
it writes are reminder emails and status notes. Anything delicate, such as a big
balance, a disputed invoice or an account heading to legal, waits at a **human
approval gate** until someone signs off. Credentials are stored encrypted in the
**Secrets Manager** and only handed to the agents you grant them to.

### Let the morning run do the chasing

From then on, each daily run picks out invoices that are late or nearly due,
sends every account the reminder its timing and balance deserve, and records the
contact. A routine nudge on day three just goes. A big or disputed balance waits
for a person's okay. And when money arrives, the agent ties it to the right
invoice and marks it paid up.

> **The pattern**
> A daily **cron** opens a session with narrow **connectors** into Stripe, email
> and the ledger, and your collections rules live in **skills** and **memory**.
> The agent mostly reads, delicate accounts wait for a person, and each contact
> is recorded.

## Guardrails

This agent emails customers in our name and changes invoice status, so its
access is narrow and fenced in:

- **Isolation.** Each run gets its own sandbox for that one task. The session
  reads Stripe and the ledger and may send only the reminders and status notes it
  has been scoped to. Nothing else leaves it.
- **Scoped secrets.** The Stripe, email and ledger credentials are stored
  encrypted in the Secrets Manager, delivered into the sandbox when the run
  starts, and only handed to the agents you grant them to.
- **Human approval gate.** A big balance, a disputed invoice or an account on
  its way to legal pauses until a person approves, before any email is sent.
- **Everything is code.** The agent's setup, skills and permissions for each
  system are files in your repo. They're versioned, and you change them through a
  reviewed **change request**, not a dashboard toggle.

## The outcome

- **Every morning:** Whole receivables list worked through on time
- **Read-mostly:** Reminders and status notes are its only writes
- **3 systems:** Stripe, email and ledger handled by a single agent

Late invoices now get the right nudge on the right day, every contact is on
record, and each payment is reconciled as soon as it arrives. Everyday follow-ups
take care of themselves, the delicate accounts wait for a person, and collecting
what you're owed no longer hangs on someone carving out an hour for it.
