{
  "schema_version": "1.0.0",
  "id": "collections-chaser-agent",
  "title": "Draft one overdue-invoice chaser each morning",
  "category": "ai-agents",
  "difficulty": "intermediate",
  "featured": false,
  "description": "Every weekday morning, pick the next overdue invoice flagged in the receivables sheet, have AI pick a tone by days overdue, and leave a Gmail draft.",
  "tags": [
    "ai-agent",
    "collections",
    "accounts-receivable",
    "gmail",
    "google-sheets"
  ],
  "apps": [
    "Schedule by Zapier",
    "Google Sheets",
    "Filter by Zapier",
    "AI by Zapier",
    "Gmail"
  ],
  "plan": {
    "minimum": "Professional",
    "reasons": [
      "multi-step Zap: 5 steps after the trigger",
      "Filter by Zapier",
      "AI by Zapier"
    ]
  },
  "tasks": {
    "typical": 4,
    "max": 4
  },
  "trigger": {
    "app": "Schedule by Zapier",
    "event": "Every Day",
    "kind": "schedule",
    "title": "Weekday morning",
    "why": "Runs once each weekday morning.",
    "config": {
      "Time of Day": "9am",
      "Trigger on Weekends?": "No"
    },
    "outputs": [
      "pretty_date",
      "date",
      "day_of_week",
      "week_of_year"
    ],
    "sample": "sample-trigger.json"
  },
  "steps": [
    {
      "key": "due",
      "kind": "search",
      "app": "Google Sheets",
      "event": "Lookup Spreadsheet Row",
      "title": "Find the next invoice to chase",
      "why": "Finds the first row whose `chase` column says yes. A sheet formula sets that column when an invoice is overdue and was not chased in the last 5 days.",
      "fields": {
        "Drive": "My Google Drive",
        "Spreadsheet": "Receivables",
        "Worksheet": "Invoices",
        "Lookup Column": "chase",
        "Lookup Value": "yes",
        "Should this step be considered a \"success\" when nothing is found?": "Yes"
      },
      "outputs": [
        "row_number",
        "_zap_search_was_found_status",
        "client",
        "contact_name",
        "contact_email",
        "invoice_number",
        "amount",
        "currency",
        "due_date",
        "days_overdue",
        "times_chased"
      ]
    },
    {
      "key": "found",
      "kind": "filter",
      "app": "Filter by Zapier",
      "event": "Only continue if...",
      "title": "Only when there is something to chase",
      "why": "Quiet mornings stop here without using another task.",
      "conditions": [
        [
          {
            "field": "{{due._zap_search_was_found_status}}",
            "operator": "(Boolean) Is true"
          }
        ]
      ],
      "usually": true
    },
    {
      "key": "write",
      "kind": "ai",
      "app": "AI by Zapier",
      "event": "Analyze and Return Data",
      "title": "Write the chaser in the right tone",
      "why": "Tone follows days overdue and how often the client was already chased, so the sequence escalates politely.",
      "fields": {
        "Model": "Default (fast)",
        "Instructions": "Write a payment reminder email. Tone rules: under 15 days overdue and never chased = friendly nudge; 15 to 44 days or chased once = clear and direct; 45 days or more or chased twice or more = firm, mention pausing work, still courteous. Never threaten legal action. Return subject, body (plain text, signed \"Accounts, Quillfield Agency\"), and tone (nudge, direct, firm).",
        "Input data": "Client: {{due.client}}\nContact: {{due.contact_name}}\nInvoice: {{due.invoice_number}} for {{due.amount}} {{due.currency}}, due {{due.due_date}}\nDays overdue: {{due.days_overdue}}\nTimes chased before: {{due.times_chased}}",
        "Output fields": "subject, body, tone"
      },
      "outputs": [
        "subject",
        "body",
        "tone"
      ]
    },
    {
      "key": "draft",
      "kind": "action",
      "app": "Gmail",
      "event": "Create Draft",
      "title": "Leave the chaser as a draft",
      "why": "Drafted, never sent: the owner knows if the client already promised payment on a call.",
      "fields": {
        "To": "{{due.contact_email}}",
        "Subject": "{{write.subject}}",
        "Body Type": "plain",
        "Body": "{{write.body}}"
      },
      "outputs": [
        "id"
      ]
    },
    {
      "key": "mark",
      "kind": "action",
      "app": "Google Sheets",
      "event": "Update Spreadsheet Row",
      "title": "Record that a chaser was drafted",
      "why": "Stamps the date and tone, which resets the sheet's `chase` formula so tomorrow picks the next invoice.",
      "fields": {
        "Drive": "My Google Drive",
        "Spreadsheet": "Receivables",
        "Worksheet": "Invoices",
        "Row": "{{due.row_number}}",
        "Columns": {
          "last_chased": "{{meta.human_now}}",
          "last_tone": "{{write.tone}}"
        }
      },
      "outputs": [
        "id",
        "row_number"
      ]
    }
  ]
}
