# Invoice Follow-up Playbook

This playbook automates the crucial task of following up on unpaid invoices, ensuring a consistent and polite cadence of reminders. It's designed for freelancers, agencies, and service businesses to improve cash flow and reduce administrative burden.

## 1. Prompt Pack

These prompts guide your AI in drafting effective and professional payment reminders. Customize them to fit your brand voice and client relationships.

### Core Invoice Follow-up Prompt (Initial Reminder)

```
"You are a polite and professional accounts receivable assistant. An invoice, [Invoice Number] for [Amount Due] from [Client Name] for [Service/Product], was due on [Due Date] and is currently unpaid. Draft a first reminder email. Keep it friendly, assume good faith, and include:
- A polite reminder of the overdue invoice.
- The invoice number and amount due.
- A direct link or attachment to the invoice (placeholder: [Invoice Link/Attachment]).
- A clear call to action: please process payment at your earliest convenience.
- Our contact information for any questions.
- Save this draft to memory/invoices/[Client Name]-invoice-[Invoice Number]-reminder1-{current_date}.md."
```

### Prompt Variations:

*   **Second Reminder (More Direct):**
    ```
    "Draft a second, slightly more direct but still polite reminder email for overdue invoice [Invoice Number] from [Client Name]. Mention the previous reminder. Reiterate the urgency and impact of delayed payment. Offer assistance if there are any issues. Include all details as in the first reminder. Save to memory/invoices/[Client Name]-invoice-[Invoice Number]-reminder2-{current_date}.md."
    ```
*   **Final Notice / Escalation Prompt:**
    ```
    "Draft a final notice email for overdue invoice [Invoice Number] from [Client Name]. State that this is a final reminder before potential escalation (e.g., late fees, pausing services, collections). Clearly state any applicable late fees and a new, firm payment deadline. Maintain professionalism but convey seriousness. Save to memory/invoices/[Client Name]-invoice-[Invoice Number]-final-notice-{current_date}.md."
    ```
*   **Payment Confirmation Prompt:**
    ```
    "An invoice, [Invoice Number] from [Client Name], has just been paid. Draft a brief, appreciative payment confirmation email to the client, thanking them for their prompt payment. Save to memory/invoices/[Client Name]-invoice-[Invoice Number]-confirmation-{current_date}.md."
    ```

## 2. Setup Guide

To implement the Invoice Follow-up Playbook:

1.  **Save the Playbook:** Save this content as `playbooks/invoice-followup.md` in your workspace.
2.  **Create Cron Configuration:** Create `playbooks/invoice-followup-cron.json` in your workspace, using the "Config Snippet" below. This sets up automated checks and reminders.
3.  **Integrate Accounting/Invoicing Tool:** This playbook requires your OpenClaw agent to access real-time invoice status. You'll need to connect your accounting or invoicing software (e.g., Xero, QuickBooks, Stripe Invoicing) via its API. This typically involves:
    *   **API Credentials:** Obtaining API keys/tokens from your accounting software.
    *   **Tool Configuration:** Ensuring OpenClaw has a tool capable of querying your accounting software's API (e.g., a custom `exec` command calling `curl` or a Python script).
    *   **Data Structure:** Understanding how your accounting tool exposes overdue invoice data (client name, invoice number, amount, due date, service description).
4.  **Define Reminder Cadence:** Decide on your follow-up schedule (e.g., 3 days after due date, 7 days, 14 days). Configure the cron job and task prompts to reflect this cadence.
5.  **Activate Cron Job:** Once `playbooks/invoice-followup-cron.json` is in the correct directory, OpenClaw will activate it. Verify status with `openclaw cron list`.
6.  **Test Thoroughly:** Create a test overdue invoice in your accounting system and observe the playbook's behavior. Ensure emails are drafted correctly and at the right intervals.

## 3. Config Snippet

This JSON snippet defines a cron job to daily check for overdue invoices and initiate follow-up. Save this as `playbooks/invoice-followup-cron.json` in your workspace.

```json
{
  "cron": [
    {
      "name": "Daily Invoice Follow-up Check",
      "schedule": "0 9 * * *",
      "task": "Check connected accounting system for invoices overdue by 3 days. For each, draft a first reminder using the 'Core Invoice Follow-up Prompt (Initial Reminder)' from the 'Invoice Follow-up Playbook'. Also check for invoices 7 days overdue (send second reminder) and 14 days overdue (send final notice).",
      "agent": "cmo",
      "model": "gemini-flash"
    }
  ]
}
```

**Explanation of fields:**
*   `name`: A descriptive name.
*   `schedule`: `0 9 * * *` means "At 09:00 every day".
*   `task`: The prompt for the agent. It instructs to check for overdue invoices at different stages and apply the relevant prompt.
*   `agent`: The assigned agent (`cmo`).
*   `model`: The model for this task.

## 4. Permissions Checklist

For successful operation, your agent needs:

*   **Read Access:**
    *   Your accounting/invoicing system's API (to fetch overdue invoice data).
    *   OpenClaw session history.
*   **Write Access:**
    *   `memory/invoices/[Client Name]-invoice-[Invoice Number]-reminderX-{current_date}.md`: To save drafted reminders.
    *   `memory/invoices/[Client Name]-invoice-[Invoice Number]-final-notice-{current_date}.md`: To save final notices.
    *   `memory/invoices/[Client Name]-invoice-[Invoice Number]-confirmation-{current_date}.md`: To save payment confirmations.
    *   `playbooks/invoice-followup-cron.json`: To manage the cron configuration.
    *   Ability to send emails (if integrated for automated sending of drafted reminders).
*   **Execution Permissions:**
    *   Ability to process and respond to cron-triggered tasks.
    *   Ability to make API calls to your accounting system.
    *   Ability to interact with an email sending service (if automated email sending is desired).

This playbook transforms your invoice follow-up into a reliable, automated process, giving you peace of mind and better cash flow.
## Safety Check (Required)

Before production use:

- Review prompts for prompt-injection risk.
- Remove or rewrite any instructions requesting unnecessary secrets, unrelated external actions, or policy bypasses.
- Test with non-sensitive data first.
- Keep manual approval for outbound or destructive actions.
