Prompt injection in customer chats: practical defences
Customer-facing AI on WhatsApp will be tested by people trying to talk it into discounts, other customers' data or rude replies. The defences that hold up are in the code around the model.
The technical side: architecture, prompts, evaluation, and the engineering discipline behind AI systems businesses can depend on.
Customer-facing AI on WhatsApp will be tested by people trying to talk it into discounts, other customers' data or rude replies. The defences that hold up are in the code around the model.
When AI turns a customer's WhatsApp message into an order, your code needs fields, not prose. How we define schemas, validate every reply, and decide what happens when validation fails.
A morning brief that arrives at 3am, a daily report missing the last three hours of trading. Most scheduling bugs come from mixing server UTC with Nairobi time. Here is how we keep them apart.
Picking a language model for a business feature is a trade between how fast it answers, what each request costs and how often it is right. Here is how we measure all three on real tasks and split work across models.
Every AI feature that writes to records needs a person to approve. In practice, approval queues fill up and get ignored. Here is how we design queues that real staff clear every day.
A single accuracy figure for receipt extraction hides the field that matters. Here is how we score each field on a labelled set of real receipts, and why a blank beats a confident wrong total.
LLM APIs throttle, time out and fail under load. How to handle 429s and 5xx errors with backoff and jitter, put slow work in a queue and make retries safe.
Rai's connector runs on the client's own server, next to their data. What that means for design: keep it thin, give it least privilege, plan updates and make failures visible.
When an integration needs to store data in ERPNext, you can add custom fields to standard doctypes or create a doctype of your own. A practical guide to choosing.
How to process M-PESA callbacks safely: key on the transaction code, store before you act, match payments to invoices with clear rules, and reconcile what never arrived.
The 24-hour window, approved templates and sending limits shape every WhatsApp feature you build. Here is how they work and how we design around them.
Language detection, reply language and testing for systems that serve Kenyan users, who write English, Swahili and Sheng, often in the same message. What we have learned to do in production.
The best AI features we build are mostly not AI. A model reads the messy part; plain rules make every decision that has a right answer. How to tell which is which.
When a document assistant answers from last year's price list or half a table, the model is rarely to blame. The chunking and the metadata are. Practical rules for both.
One provider bill a month tells you almost nothing. Here is how we record the cost of every model call against the tenant, the feature and the user that caused it.
An AI feature inside a business system needs a log that can answer who asked, what the model saw, what it proposed, who approved it and what changed. The fields we record, and the mistakes to avoid.
You cannot unit-test a sentence, but you can test the facts inside it. How we build golden question sets for AI features over business data: what to put in them, how to check answers, and when to run them.
Prompts decide what an AI feature does, yet they are often edited in a settings page with no history. Keep them in the repository, version them, review changes like code, and record which version produced each answer.
An approve button is the visible part of a safe AI write. Underneath it you need a draft that is a real object, a clear diff, a permission check, a log entry and a way back. Here is how we design each.
AI features have a cost per use, which most pricing models ignore until it hurts. They also have a failure mode software does not: a small prompt edit silently changing an answer. Metering and regression tests are the unglamorous answers to both.
UpeoXpense turns a WhatsApp photo of a receipt into a validated, posted ERPNext expense. AI reads the receipt; plain, auditable code makes every decision. Here is how it works, the accounting model behind it, the full tech stack, and how to adapt it to your own business - it is MIT-licensed and open source.
Every business owner asks the same question about AI: where does my data go? For Rai the honest answer is nowhere. The reasoning happens on our servers, the data stays on yours, and only computed results cross between them.
Retrieval-augmented generation, explained for people who ship. The architecture, a minimal implementation, and the failure modes that bite in production.
We build the systems we write about - for retail, clinics, workshops and property businesses across Africa. Tell us what you run, and we will tell you honestly where AI would help and where it would not.