Example: Ngamia Invoice helper
A complete, tested example of a business agent: the help assistant for Ngamia Invoice , the Swahili-first invoicing app for Tanzanian businesses. It answers users’ questions in Kiswahili or English, such as how to link WhatsApp, turn a proforma into an invoice, record an M-Pesa payment, or whether a receipt is fiscal. Answers come from Invoice’s own help content, with sources.
Source: examples/invoice-assistant/
| File | What |
|---|---|
agent.json | Agent definition: instructions, knowledge: true, max_steps 4, max_total_tokens 30,000 |
knowledge.json | 16 bilingual help documents written from Invoice’s README, chat-to-invoice guide, in-app docs and product code |
eval.json | 16 real user questions with the document each must find |
setup.py | Creates or updates the agent, loads knowledge, checks retrieval, asks a question (Python standard library only) |
Run it
export NGAMIA_TOKEN=<platform token, developer role or above>
python3 examples/invoice-assistant/setup.py --check --ask "Nawezaje kuunganisha WhatsApp?"created agent invoice-helper
loaded 16 knowledge documents
ok Mnafungua ankara vipi kwa WhatsApp? nawezaje kuunganisha Wha -> ['whatsapp-assistant', 'customer-whatsapp-requests', 'chat-to-invoice']
ok Je risiti ya Ngamia Invoice ni risiti ya EFD ya TRA? -> ['what-is-ngamia-invoice', 'fiscal-tax', 'document-types']
ok Mteja amelipa kwa M-Pesa, narekodi vipi malipo? -> ['payments-and-receipts', 'customer-whatsapp-requests', 'developers-mcp-payments']
…
16/16 questions found the right document in the top 3That is a real result from the platform’s knowledge engine with its multilingual embedding model.
The instructions
The agent’s instructions show the pattern from Write good agents:
- who it helps (business owners, staff, accountants and developers using Invoice);
- answer in the user’s language, short and practical, with exact menu names;
- always search the knowledge and answer only from it; say so when unsure;
- boundaries: it explains the product but cannot see or change invoices; it never asks for or repeats keys, passwords or codes; it gives no tax or legal advice and states that Invoice documents are not EFD/VFD fiscal receipts.
Calling it from Invoice
The Invoice Go backend keeps a runs-only key and asks on behalf of each
signed-in user:
body, _ := json.Marshal(map[string]any{
"input": question,
"user": "invoice:" + userID,
})
req, _ := http.NewRequestWithContext(ctx, http.MethodPost,
"https://api.ngamia.com/v1/agents/invoice-helper/runs", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("NGAMIA_AGENT_KEY"))
req.Header.Set("Content-Type", "application/json")Live invoice data is the next step. Questions like “which invoices are overdue?” need tools that call Invoice for the signed-in business. Invoice exposes them over MCP; on Ngamia they would come through the tools engine as a provider with a per-workspace credential and a KATIBA policy allowing read and draft tools only. Until then this agent explains how to do things in the app.