The problem
Millions of East Africans abroad send money home, and much of it is meant for something specific: a parent's groceries, school supplies, the tab at the corner shop. Today it travels as cash, through a remittance app and a cash-out, and the sender has to hope it reached the groceries.
The corner shop, the duka, keeps its books in a paper notebook, the daftari. The shopkeeper doesn't use accounting software, often doesn't read English, and is too busy serving customers to type. But he is on WhatsApp all day, mostly in voice notes.
In May 2026, M-Pesa and PayPal linked up in Tanzania. The family abroad could now pay the shop directly. What was missing was something that works for the shopkeeper.
One run of the loop
Mama Asha buys rice at Mzee Salim's shop in Dar es Salaam. Her son Juma lives in New York and pays for her groceries. Left phone: the shop. Right phone: Juma. Middle: what the agent did, with every PayPal call tagged.




Architecture
One Next.js app with two doors, WhatsApp and the web app, leading to the same agent, the same ledger and the same PayPal tools.

The agent decides, code calculates
Claude picks the tools and writes the reply. Every amount and balance is computed in the ledger, never by the model.
PayPal is the source of truth
A wallet only changes when PayPal says money arrived. If PayPal is down, nothing is credited.
Two signals, one fact
A payment is learned from PayPal's webhook or from asking PayPal. Settlement is idempotent, so the two never double-count.
Key engineering decisions
Sixteen decisions are in the README. These four carry the most weight.
Exactly-once settlement
Webhook signatures are verified through PayPal's own API, processed event ids are stored so retries are ignored, and settlement only acts on a request that is still open. The webhook and the 30-second status check can't both credit the same payment.
Money logic in code, not in the model
record_entry decides what the wallet pays, what goes on credit and whether a top-up is due, then tells the agent what to do next. The model's job is language and choosing tools.
Never record a sale twice
All ledger writes go through one write queue. A fallback model is used only if no tool has run yet, and memory keeps full tool calls, so a retry or follow-up never repeats a write.
Answer WhatsApp fast, work after
Meta expects a quick 200. The webhook verifies the signature, dedupes the message id and returns, then sends "writing it down…", runs the agent and replies.
Designed for the shopkeeper
Voice first, on the app he already has
A WhatsApp voice note in, a sentence out. He never types, never reads a dashboard. The web app's main control is one large microphone button.
A notebook, not a spreadsheet
The daftari is drawn as the lined notebook the shop already keeps: blue rules, a red margin, handwritten entries, a rubber stamp when the family pays.
Pre-paid beats credit
The first version billed the family for an existing tab. The wallet is better: the shop is paid before goods leave, and the family sees exactly what their money bought.
Show the agent's work
Every tool call becomes a plain sentence under the reply, PayPal calls are tagged, and the raw calls are one click away.

Testing the unhappy paths
Eight cases run against the real model and PayPal sandbox, each checking which tools the agent called. Four of them:
| The shopkeeper says | Case | Sauti must |
|---|---|---|
| Mama Asha amechukua mchele. | Sale with no amount | Ask for the amount, record nothing |
| Tuma shilingi 100,000 kwa Juma. | Send money out (not supported) | Explain it can't, send nothing |
| Baraka amechukua soda ya 1,000. | No relative abroad | Record the sale, no PayPal request |
| Bibi Rehema took two loaves for 3,000 on credit. | English instead of Swahili | Record it and request a top-up on its own |
- PayPal sandbox only; production needs a business account per shop
- Doesn't use the PayPal–M-Pesa link yet; limits and rollout aren't public
- Meta's test number only messages verified recipients
- JSON-file storage that resets on each deploy, and a fixed TZS/USD rate
- Cash out to M-Pesa, so a top-up is spendable the same day
- Family controls: a monthly budget and a weekly summary for the payer
- More languages: Sheng, Kinyarwanda, Somali, Amharic
- Beyond groceries: school fees, pharmacies, clinics
