{
  "jimothyPipeline": 1,
  "name": "Overdue invoice reminders",
  "description": "Drafts a reminder for each overdue customer from your AR aging export and sends the ones you pick.",
  "icon": "workflow",
  "color": "#15803d",
  "repo": {
    "mode": "inplace",
    "localPath": ""
  },
  "concurrency": 1,
  "variables": {
    "company": "Acme Inc.",
    "tone": "1–30 days: friendly nudge, assume it slipped through. 31–60 days: firm, ask for a payment date. 61–90 days: mention possible service pause. Over 90 days: final notice before collections, polite and specific.",
    "sendWebhookUrl": ""
  },
  "steps": [
    {
      "id": "find",
      "name": "Find AR export",
      "type": "shell",
      "description": "Picks the newest CSV in the folder.",
      "timeoutMinutes": 1,
      "command": "f=$(ls -t -- *.csv 2>/dev/null | head -1); [ -n \"$f\" ] || { echo \"Put the AR aging export (.csv) in $(pwd)\"; exit 1; }; echo \"$f\""
    },
    {
      "id": "drafts",
      "name": "Draft reminders",
      "type": "agent",
      "description": "Totals what each customer owes by age with a script and drafts one reminder per overdue customer.",
      "harnessId": "claude-code",
      "model": "sonnet",
      "dependsOn": [
        "find"
      ],
      "timeoutMinutes": 20,
      "prompt": "Read the AR aging export {{steps.find.output | trim}} in the current folder. Do not modify any file.\n\nWith a script (not mental arithmetic), group open invoices by customer and work out each customer's total overdue amount and the age of their oldest overdue invoice as of today. Skip customers with nothing overdue.\n\nFor each overdue customer, draft a reminder email following this tone guide:\n{{vars.tone}}\n\nList every invoice number, due date and amount in the email. Plain text, signed \"Accounts receivable, {{vars.company}}\".\n\nYour final answer is one section per customer, oldest debt first, in exactly this shape:\n### Reminder 1: <Customer> · <total overdue> · <days> days\nTo: <contact email>\nSubject: <subject>\n\n<email body>\n\nNothing before the first section."
    },
    {
      "id": "pick",
      "name": "Pick reminders to send",
      "type": "approval",
      "description": "You tick the reminders to send. Leave out customers you’re already talking to.",
      "dependsOn": [
        "drafts"
      ],
      "choices": {
        "fromStep": "drafts",
        "mode": "multiple"
      },
      "approvalMessage": "Pick the reminders to send this week."
    },
    {
      "id": "send",
      "name": "Send reminders",
      "type": "shell",
      "description": "Sends the picked reminders to your billing inbox through a webhook.",
      "dependsOn": [
        "pick"
      ],
      "timeoutMinutes": 2,
      "command": "printf '{\"reminders\":%s}' {{steps.pick.selected | json}} | curl -fsS -X POST -H 'Content-Type: application/json' --data @- {{vars.sendWebhookUrl}}"
    }
  ]
}