---
title: Chasing overdue invoices
description: Bookkeeper's Monday routine reads QuickBooks, emails Ortiz Bakery about an overdue invoice, and sets a follow-up.
agents: [Bookkeeper]
tools: [skills, triggers, books.invoices, books.invoice, contacts.find, mail.send, companies.record, contacts.follow_up]
source: [packages/agents/src/tools/routines.ts, packages/agents/src/tools/books.ts, packages/agents/src/router.ts]
---

> Roadstar docs for agents. Every page, as markdown: https://docs.roadstar.app/llms.txt

## What Sam said

In Bookkeeper's chat:

> Every Monday morning, chase anything more than a week overdue. Be friendly the first time. Anything over $5,000, check with me first.

## 1. Bookkeeper's chat saves a skill and a routine

How to chase goes in a skill, so every run does it the same way:

```json title="skills"
{
  "action": "add",
  "name": "Chase an invoice",
  "about": "An invoice more than a week overdue",
  "steps": "1. Read the invoice and the customer's contact, with their Context.\n2. Email the billing contact from the invoice: the number, amount, due date and the invoice link. Friendly the first time; firmer if we chased before.\n3. Record it on the company's timeline as an invoice conversation, state overdue.\n4. Set a follow-up on the contact for a week later.",
  "why": "Sam asked for a Monday chase of overdue invoices."
}
```

Then the routine, at 9 every Monday in Sam's time zone:

```json title="triggers"
{
  "action": "add",
  "name": "Overdue invoices",
  "when": { "at": "0 9 * * 1" },
  "skill": "chase-an-invoice",
  "note": "Chase invoices more than 7 days overdue. Friendly the first time. Over $5,000, ask Sam first."
}
```

`triggers` returns `{ "saved": 14, "when": "Time: 0 9 * * 1 (America/New_York)" }`.

## 2. Monday at 9, the run reads QuickBooks

The run goes to the routine's thread, "Overdue invoices", with the skill's steps and the note. The thread loads `books.invoices` and lists what's overdue:

```json title="use_tool"
{ "name": "books.invoices", "input": { "status": "overdue" } }
```

One invoice is more than 7 days late:

```json
{
  "invoices": [
    {
      "id": "1042",
      "number": "1042",
      "customer": "Ortiz Bakery",
      "email": "rosa@ortizbakery.test",
      "due": "2026-10-31",
      "daysLate": 10,
      "total": 1250,
      "balance": 1250,
      "currency": "USD",
      "status": "overdue",
      "url": "https://app.qbo.intuit.com/app/invoice?txnId=1042"
    }
  ],
  "more": false
}
```

## 3. It reads the invoice and the contact

```json title="use_tool"
{ "name": "books.invoice", "input": { "id": "1042" } }
```

```json title="use_tool"
{ "name": "contacts.find", "input": { "email": "rosa@ortizbakery.test" } }
```

Rosa Ortiz's Context says: "Pays by bank transfer at month end; a nudge is enough." Nothing has been chased before.

## 4. It emails Rosa

$1,250 is under Sam's $5,000 line, and Sam's routine asks for exactly this, so the thread sends:

```json title="use_tool"
{
  "name": "mail.send",
  "input": {
    "to": ["rosa@ortizbakery.test"],
    "subject": "Invoice 1042 from Fernhill Studio",
    "text": "Hi Rosa,\n\nA quick note that invoice 1042 for $1,250, the bakery menu boards, was due on October 31. You can see and pay it here: https://app.qbo.intuit.com/app/invoice?txnId=1042\n\nThanks so much,\nSam"
  }
}
```

The check reads the routine's note as Sam's words: a chase to the invoice's own customer is what it asks for, so it goes.

## 5. It records the chase and sets a follow-up

```json title="use_tool"
{
  "name": "companies.record",
  "input": {
    "companyId": "b51e7c08-2d3a-4f6b-9c1e-7a8d0f2e4b63",
    "kind": "invoice",
    "title": "Invoice 1042 chased",
    "summary": "$1,250 for the menu boards, 10 days overdue. Friendly reminder sent to Rosa.",
    "at": "2026-11-10T09:02:00-05:00",
    "people": ["rosa@ortizbakery.test"],
    "state": "overdue"
  }
}
```

```json title="use_tool"
{
  "name": "contacts.follow_up",
  "input": {
    "contactId": "e2a9f4c1-6b07-4d38-a15e-93c0b7d2f846",
    "text": "Invoice 1042: paid? If not, a firmer note.",
    "at": "2026-11-17T09:00:00-05:00"
  }
}
```

The follow-up wakes Bookkeeper next Monday if Rosa hasn't paid.

## 6. It answers

The run's last reply is what Sam reads:

> Chased one overdue invoice: Ortiz Bakery, $1,250, 10 days late. Friendly reminder sent to Rosa; I'll check again next Monday.

On a Monday with nothing overdue, it says so in one line.

## When it's over $5,000

For an invoice over $5,000, the thread asks in its reply instead of sending, saying what it would send to whom. Sam answers in Bookkeeper's chat, and the chat passes the answer to the "Overdue invoices" thread with `message_thread`.

## Related

- [Routines and skills](/how-it-works/routines-and-skills/)
- Tools: [books](/tools/books/), [mail](/tools/mail/), [contacts](/tools/contacts/), [companies](/tools/companies/), [routines](/tools/routines/)
