Event-triggered order-to-cash agent for SME/Jua Kali manufacturers in Kenya — USSD/SMS/Voice via Africa's Talking, M-Pesa, and an owner-facing LiveKit voice assistant.
# Order-to-Cash Agent
An event-triggered agent for SME and Jua Kali manufacturers. It takes an order,
confirms and schedules it, collects payment by M-Pesa, and chases late payment
with an escalating SMS then a Voice call. Built for the Africa's Talking
Manufacturing Hackathon, Nairobi, 27 Aug 2026.
See `BUILD_PLAN.md` for the full design, the call sequences, and the demo script.
See `AI_COMPONENTS.md` for the two AI systems in this build: the order-parsing
brain and the owner voice assistant, "Friday".
## Architecture
```mermaid
flowchart TD
CPhone["Customer's phone USSD / SMS / Voice"]
ATChannels["Africa's Talking (USSD + SMS + Voice, the spine)"]
subgraph Server["Node server (src/)"]
Intake["Intake routes/ussd.js, routes/sms.js"]
Parse["Parse claude.js → DeepSeek V4 Flash (OpenRouter, tool use)"]
Orders["orders.js / invoices.js"]
Agent["Collections tick agent.js (cron, every minute)"]
ATjs["africastalking.js (SMS + Voice out, retry/backoff)"]
VoiceRoute["routes/voice.js (dial-plan XML)"]
Mpesa["mpesa.js / routes/mpesa.js (OAuth, STK push, callback)"]
Dashboard["routes/dashboard.js"]
Api["routes/api.js"]
end
DB[("Postgres customers · products · orders invoices · messages")]
Daraja["Safaricom Daraja STK push + callback"]
Friday["Friday, voice-agent/ separate Python process LiveKit + Groq STT/LLM/TTS"]
OwnerBrowser["Owner's browser"]
OwnerPhone["Owner's phone (voice)"]
CPhone --> ATChannels --> Intake --> Parse --> Orders --> DB
Orders -- "confirmation SMS" --> ATjs --> ATChannels
DB --> Agent
Agent -- "reminder SMS #1 / #2, owner alert" --> ATjs
Agent -- "voice escalation" --> VoiceRoute --> ATChannels --> CPhone
Orders -- "STK push, on demand" --> Mpesa --> Daraja --> CPhone
Daraja -- "callback" --> Mpesa --> DB
DB --> Dashboard --> OwnerBrowser
DB --> Api
Api Friday OwnerPhone
```
The customer never sees a screen. Every order arrives by USSD, SMS, or Voice
through Africa's Talking, gets parsed and priced, and lives in one Postgres
schema that both …