# How we chase down overdue invoices

An accounts-receivable agent we run on Kortix — connected to Stripe, email, and the accounting ledger. It finds overdue invoices, sends the right reminder, logs every touch, and reconciles when payment lands.

Canonical page: https://openchatly.com/use-cases/ar-chaser

Chasing overdue invoices is steady, repetitive work that still needs judgment.
Most reminders are routine: an invoice is a few days late, a polite note goes out,
the customer pays. But the timing, the tone, and the escalation depend on how late
the balance is and how large it is, and some accounts are sensitive enough that no
automated email should go out without a person looking first.

We run an accounts-receivable agent on Kortix that does this chasing on a daily
schedule. This is how we collect on our own invoices, including the connections
and guardrails involved.

- **Team:** Kortix
- **Runs on:** A daily cron
- **Connected systems:** Stripe · Email · Accounting ledger
- **Mode:** Read-mostly · reminders and status notes gate-able

## The problem

Receivables slip because no one has time to work the list every day. An invoice
goes a week late, then two, and the reminder that should have gone out on day one
never does. The ones that need a firmer note get the same generic email as the
ones that are barely late, and the sensitive accounts — a large balance, a
disputed line, something heading to legal — get chased the same way as everything
else.

The common fixes are incomplete. Stripe's built-in reminders send on a fixed
cadence regardless of balance size or account context. A spreadsheet and a
calendar reminder depend on someone actually working it. A generic automation
sends the same email to everyone and has no way to hold the risky ones back.

## What we built

On Kortix, a daily cron triggers an agent. Each morning it spawns an isolated
session (a cloud sandbox) with scoped access to Stripe, our email, and the
accounting ledger. It finds every invoice that's overdue or coming due soon,
decides the right reminder for each based on how late and how large the balance
is, sends it, logs the touch, and reconciles the invoice when payment lands.
Anything sensitive stops at a human approval gate before it sends.

## How it works

### Copy the setup prompt into a new session

Open your Kortix workspace, start a new session, paste this prompt and send it.
The agent writes the agent file, the invoice-math skill and the weekday
trigger, and opens a change request for you to review. Prefer clicks? Choose
**Use this template** instead.

**Setup prompt**

```
Set up an overdue-invoice chaser agent in this workspace.

1. Create the agent agents/ar-chaser.md. Its job is to chase overdue Stripe invoices with email reminders and post a daily summary. It may use the Stripe and Slack connectors. It only reads Stripe.

2. Create the skill skills/invoice-math/SKILL.md with these rules:
   - Measure age from the due date. Send a courtesy notice in the 7 days before it, a first reminder at 1 to 7 days overdue, a second reminder at 8 to 30, and a final notice at 31 to 60.
   - Hold anything 61 or more days overdue for a person. Do not send.
   - Send at most one reminder per invoice per run, and never two to the same invoice within 72 hours.
   - Hold any balance over the approval threshold, anything disputed, and anything marked for collections or legal. Ask me for the threshold.
   - Stop chasing an invoice as soon as it is paid, and note it in the summary in #finance.

3. Add a cron trigger daily-check to kortix.yaml. It runs the ar-chaser agent every weekday at 09:00 with the prompt "Review overdue and soon-due Stripe invoices with the invoice-math skill, send the right reminder for each, and post the summary to #finance."

4. Tell me which of these connectors are not connected yet.

5. Open a change request with all of it. Do not merge it.
```

### Connect your tools

Open **Connectors** in your workspace and connect Stripe, the mailbox the
reminders come from and Slack. Credentials are brokered server-side and never enter the
agent's machine.

- **Stripe** (Required):
Reads overdue invoices and reconciles payments, read-only.
- **Gmail** (Required):
Sends the courtesy notice, reminders and final notice.
- **Slack** (Required):
Posts the daily summary and the invoices held for a person.

### Run it once with this prompt

Merge the change request, then start a session with the **ar-chaser** agent
and send this prompt. Check the reminders it sent and the invoices it held
before you let the schedule take over.

**Prompt**

```
Run one invoice check on Stripe.

1. List open invoices that are overdue or due in the next 7 days, with amount, due date and payment status.
2. Pick the reminder tier for each from the invoice-math skill. Skip any invoice reminded in the last 72 hours.
3. Send each reminder by email and log the touch.
4. Do not send for balances over the approval threshold, disputed invoices, or invoices marked for collections or legal. List them for me instead.
5. Post a summary to #finance: reminders sent, invoices paid since the last run, and anything held.
```

### Let the weekday schedule take over

The change request added this trigger to `kortix.yaml`. From now on the agent
runs every weekday at 09:00, each run in a new session on its own cloud computer. To change the time, edit the cron line, or open
**Triggers** in the workspace.

**kortix.yaml**

```yaml
triggers:
  - slug: daily-check
    name: Daily invoice check
    on:
      cron: "0 0 9 * * 1-5"
    run:
      agent: ar-chaser
      prompt: Review overdue and soon-due Stripe invoices with the invoice-math skill, send the right reminder for each, and post the summary to #finance.
```

### Hold large or disputed balances for a person

Routine reminders go out on their own. A balance over the threshold, a
disputed invoice, or an account marked for collections or legal gets no
email. The agent lists it in the summary with the reason, and a person decides
the next step. The agent never issues a refund, changes a plan or edits an
invoice.

### Read the summary

Each run ends with one message in the channel. This is what a run looks like
in the session:

> **Daily invoice check · 09:00**
>
> Prompt: Review overdue and soon-due Stripe invoices with the invoice-math skill, send the right reminder for each, and post the summary to #finance.
>
> Sent **9** reminders: **4** first reminders, **3** second reminders and **2**
> final notices. **3** invoices were paid since the last run and are off the
> list. **2** are held for you: one disputed invoice and one balance over the
> approval threshold.

> **The pattern**
> A daily **cron** spawns a session with scoped **connectors** into Stripe, email,
> and the ledger. The collections policy is encoded as **skills** and **memory**.
> The agent stays read-mostly, sensitive accounts wait for a human, and every
> touch is logged.

## Make it do more

Once it works, paste any of these into the same session.

**Track promised payment dates**

```
When a customer replies with a payment date, log it and skip reminders for that invoice until the date passes.
```

**Weekly aging report**

```
Every Monday, post the open balance in each aging bucket to #finance, with the change since last week.
```

**Escalate final notices**

```
For each invoice that reaches a final notice, send its account owner a Slack DM with the balance and the days overdue.
```

## Guardrails

The agent sends email on our behalf and touches invoice state, so the access is
scoped and contained:

- **Isolation.** Every run happens in its own per-task isolated sandbox. The
  session reads Stripe and the ledger and can send only the reminders and status
  notes it's scoped to; nothing else is written back out.
- **Scoped secrets.** The Stripe, email, and ledger credentials are encrypted in
  the Secrets Manager and injected into the sandbox at runtime, scoped to the agents you grant them to.
- **Human approval gate.** A large balance, a disputed invoice, or an account
  heading to legal stops for a person to approve before any email goes out.
- **Everything is code.** The agent's configuration, skills, and per-system
  permissions are files in the repo, versioned and changed through a reviewed
  **change request** rather than a dashboard setting.

## The outcome

- **Every morning:** The full receivables list worked on schedule
- **Read-mostly:** Only reminders and status notes are written
- **3 systems:** Stripe, email, and the ledger in one agent

Overdue invoices now get the right reminder on the day they should, with each
touch logged and each payment reconciled when it lands. Routine chases run on
their own, the sensitive accounts wait for a person, and the receivables list no
longer depends on someone finding time to work it.
