Logo Lanfrica

AymanAbdiMohamed/simple-mpesa-payment-agent-via-lua

Domaine:

digital infrastructure

Type de record:

software
Créateur:
Aym
Hôte:
# M-Pesa Bill Payment Agent A Lua AI agent called **Lipa** that helps Kenyan customers check outstanding bills and pay them via M-Pesa STK push — all through a conversational interface. ## What it does - Check outstanding bill amounts for Safaricom Postpaid, KPLC (prepaid & postpaid), and Nairobi Water - Initiate M-Pesa STK push payments — the user gets a prompt on their phone to confirm with their PIN - Handles phone number formatting automatically (e.g. `0712345678` → `254712345678`) - Responds in a friendly, conversational style with occasional Swahili (Sawa, Poa, Karibu) ## Project structure ``` mpesa-payment-agent/ ├── src/ │ ├── index.ts # Agent definition (default export) │ └── skills/ │ ├── payment.skill.ts # Groups the two payment tools │ └── tools/ │ ├── CheckBalanceTool.ts # Looks up outstanding bill amount │ └── InitiatePaymentTool.ts # Sends M-Pesa STK push ├── lua.skill.yaml # Lua platform manifest (auto-managed) ├── env.example # Environment variable reference ├── package.json └── tsconfig.json ``` ## Getting started ```bash # Install dependencies npm install # Chat with the agent in sandbox mode lua chat # Test tools individually lua test # Deploy to production lua push all --force --auto-deploy ``` ## Tools ### `check_account_balance` Looks up the outstanding bill for a given account and service. | Input | Type | Description | | --------------- | ------ | ----------------------------------------------------------------------- | | `accountNumber` | string | Customer account or phone number | | `service` | enum | `safaricom_postpaid`, `kplc_prepaid`, `kplc_postpaid`, `nairobi_water` | Returns the amount due in KES and whether the account is `outstanding` or `clear`. ### `initiate_mpesa_payment` Send …