Kali Discovery: Phase 1 — Mission Brief
Now propose your solution. Include: architecture, sequence, state management, edge cases, success criteria. Be specific – this is your build plan.\nKali’s Response: Okay, here’s my proposed build plan for the debt chasing and enforcement sub-bot.\n**Architecture:**\n* I will operate as an isolated sub-agent within OpenClaw, receiving instructions from the Durga agent via A2A.\n* I will interact with the Xero API (through the and scripts), external scoring services (through ), and Parvati (through dedicated scripts yet unseen).\n* I will use OpenClaw’s file system for persistent state management ().\n* I will use OpenClaw’s cron jobs to perform periodic tasks such as checking for new aged receivables.\n* I will rely on human approvals via Telegram before escalating to Stage 2 and above.\n**Sequence of Operations:**\n1. **Initialization:** On session start, I will read , , and the latest files.\n2. **Periodic Check (Cron Job):** A cron job will trigger me to check for new aged receivables in Xero.\n3. **Data Retrieval:** I will use to retrieve aged debt data from the Xero API. I will need to refresh the Xero token via if it has expired.\n4. **Debtor Scoring:** I will use to score each debtor based on risk and relationship value.\n5. **Escalation Engine:** I will use to determine the correct escalation stage for each debtor.\n6. **Action Execution:**\n * **Stage 1 (30-60 days):** Send a friendly reminder via the Xero email API using .\n * **Stage 2 (61-90 days):** Generate a firm reminder and request Anthony’s approval via Telegram. If approved, send the reminder.\n * **Stage 3 (91-120 days):** Generate a formal letter (using Parvati) and request Anthony’s approval via Telegram. If approved, send the letter via Parvati.\n * **Stage 4 (120+ days):** Generate a statutory demand (using Parvati) and request Anthony’s approval via Telegram. If approved, send the demand via Parvati.\n * **Stage 5:** Flag the debtor for legal action. This requires a human decision and is outside my automated scope.\n7. **State Management:** I will update to track the escalation stage for each debtor and prevent duplicate actions.\n8. **Reporting:** I will report all actions and state changes to Durga via A2A.\n**State Management ():**\n\n**Edge Cases:**\n* **Xero API Errors:** Implement robust error handling for Xero API calls, including token refresh failures.\n* **Debtor Scoring Failures:** Handle cases where debtor scoring fails gracefully (e.g., use a default score or flag for manual review).\n* **Communication Failures:** Handle failures to send reminders or letters (e.g., retry or log for manual intervention).\n* **Approval Delays:** Implement timeouts for approval requests to prevent blocking the process indefinitely.\n* **Data Consistency:** Implement checks to ensure data consistency between and the Xero API.\n**Success Criteria:**\n* I can successfully retrieve aged debt data from the Xero API.\n* I can accurately score debtors based on risk and relationship value.\n* I can correctly determine the escalation stage for each debtor.\n* I can automatically send friendly reminders (Stage 1) without human approval.\n* I can generate escalation communications (Stages 2-4) and request human approval via Telegram.\n* I can accurately track the escalation stage for each debtor in .\n* I can reliably report all actions and state changes to Durga via A2A.\n* I can handle edge cases gracefully and prevent process failures.\n* I adhere to the defined constraints (no sending communications without approval, no modifying invoice data, etc.).\nI will need the scripts (, , , , ), and the A2A interface to Durga defined, before I can proceed.\nI will create the file with the initial structure.