The short version: AssetChat is our early-access IT asset management product, and it has a chat agent that works on WhatsApp and on the web. Staff can assign, transfer, return and dispatch devices, approve and deliver dispatches, raise incidents and list assets by sending a message. The design rule is simple to state: the language model never writes to the database. It turns a message into a proposed intent and a few details. Fixed code does everything else: it finds the right employee and asset, asks for what is missing, checks the user's role, shows a summary, waits for an explicit confirmation, and only then makes the change.
AssetChat is our own product, not a client deployment. This article describes the backend as it is built, including the parts we have not finished, because the pattern matters more than the product, and it applies to almost any agent that touches business records.
Why the model does not get write access
A wrong answer from a chatbot is an annoyance. A wrong write from an agent is a record that says a laptop is with someone who never received it, a consent form issued against the wrong employee, or a recovery notice sent to the wrong person. Language models are good at reading messy human messages and bad at being guaranteed right. They can also be steered by whatever text reaches them, which is the prompt-injection problem every agent has.
So we gave the model the narrowest possible job. Its output is a proposal in a fixed shape. The worst a confused or manipulated model can do is propose the wrong thing, and every proposal then has to pass through code that checks it against the database, against the user's role and, finally, against the user's own eyes.
The pipeline, step by step
- 1. Message in. A WhatsApp message arrives on the official WhatsApp Business Platform webhook, or a web chat message arrives on the API. Both go to the same handler.
- 2. Who is this? On WhatsApp, the sender's number maps to a user and a role. On the web, the session carries the user and role.
- 3. Load the session. A lock is taken on the session so two messages cannot race, and its state is loaded: the active workflow, the details collected so far, any pending question, and a stack of paused workflows.
- 4. Handle what needs no model. Cancel words, greetings, numbered menu choices, the answer to the question the agent just asked, and a reply to a pending choice are all handled by code, without calling the model.
- 5. Parse. Anything else goes to the parser, the only component in the system that calls a language model.
- 6. Check the role. The proposed intent maps to a required permission. If the user's role lacks it, the request stops there and the denial is logged.
- 7. Fill and resolve. The workflow's required details are collected one by one, and names are resolved to real records.
- 8. Validate. Business rules run against current data.
- 9. Confirm. A summary built from database records is shown, with "1. Confirm and proceed" and "2. Cancel this action".
- 10. Execute. After a "1", fixed code for that workflow makes the change, and the action is written to the audit log and the activity history.
What the parser does, and what it does not do
The parser sends the message to a hosted model (Gemini, today) with a system prompt that lists the supported intents and slot names, and asks for one JSON object: an intent, the slots it found, and a confidence. The intents are a closed list: transfer, dispatch, approve a dispatch, mark it in transit, mark it delivered, assign a delivered dispatch, revoke, return, list assets, show available or under-maintenance assets, show open incidents, a system summary, add an employee, add an asset, raise, track or view an incident, confirm, cancel, and unknown. Anything outside the list becomes unknown. The call runs at a temperature of 0.1, with a hard cap on output tokens and a JSON response type, because the output is always small and always the same shape.
For example, "Transfer laptop from Ajay to Rahul" becomes a transfer intent with a source user of "Ajay", a target user of "Rahul" and a category of "Laptop". Those are strings, not records. The model never sees the database, holds no credentials, has no tools to call, and does not decide which Rahul is meant.
Some commands never reach the model at all. A message with a dispatch reference such as DSP003 and the word "approve", "in transit" or "delivered" is parsed by a regular expression first, because those commands are exact and we want them handled exactly. Parses are cached for a few minutes by a hash of the message. That is safe because a parse depends only on the message, not on the conversation; the conversation's state lives in the session. If the model call fails, transient errors are retried twice with a short backoff, and then a rule-based parser takes over, so the agent keeps working while understanding less. Fallback results are not cached, so one outage does not poison later requests.
Asking for what is missing
Each action is a workflow defined in code: the slots it needs, their order, which slots depend on which, the question to ask for each, and whether a confirmation is required. A transfer needs the current holder, then an asset (listed from what that person actually holds), then the recipient. A dispatch needs the recipient, the asset, a delivery address (the agent offers the address already saved for that employee), a reason chosen from a fixed list, and proof where the reason requires it.
When a slot is missing, the agent asks for it. When the user answers, the answer fills that slot directly, without another trip through the model. Workflows can also nest. If the recipient of a transfer is not in the system, the agent offers to add them. The transfer is pushed onto a stack, the add-employee workflow runs with its own confirmation, and then the transfer resumes with the new employee already filled in.
Finding the right employee and asset
The resolver turns what the user typed into record IDs, and it follows three rules. No match: say so and ask again, or offer to add the employee. Exactly one match: fill it in, unless the workflow says to always show the choice. Several matches: show a numbered list and wait. It never guesses between candidates. When a user types "Rahul" and there are three of them, the agent lists all three. For incidents, the asset list is always shown even when the employee holds only one device, so the user picks it consciously.
Then the validator checks business rules against current data: the asset exists, it is actually assigned to the person it is being transferred from, the recipient is a different person who exists, and the asset is not locked by another operation. A failure produces a plain message and, where it makes sense, the next question rather than a dead end.
Roles, on WhatsApp and on the web
There are three roles. An Executive can see their own assets and raise and track incidents. An Admin can also dispatch, transfer, return and revoke assets and manage the employee and inventory records. A SuperAdmin can do everything. Each action maps to a required permission, and the check runs when a workflow starts and again whenever the user switches to a different workflow in the middle of a conversation.
Scoping is enforced in two places. When an Executive asks to list assets, the workflow fills in their own user ID as the target. If a request still asks for another person's assets, the executor itself refuses: "Executives may only view their own assigned assets." Because WhatsApp and the web share one handler, an Executive sees exactly the same in chat as on the web, and so does every other role.
The confirmation step
Every workflow that changes data has confirmation switched on; read-only queries do not. The summary is built by code from the resolved records, not written by the model: the operation, the asset with its serial number, from whom, to whom, the delivery address, the reason and the proof, as applicable. The user replies 1 or 2. That reply is matched by code against the pending choice and is never sent to the model, so no phrasing in a message can stand in for the confirmation.
After a "1", the engine runs the whole workflow again from the top: slots, resolution, validation, and only then the executor. If something changed between the summary and the reply, such as the asset being assigned elsewhere in the meantime, validation catches it. The executor, a fixed class per workflow, makes the change through the same data layer the web screens use, and the result is logged.
Trade-offs we accepted
- More turns. A free-form agent would finish some requests in one message. Ours often asks two or three questions and always asks for a confirmation. For records that matter, we think that is the right default.
- New capabilities need code. Adding an action means a workflow definition, an executor and a permission entry, not a prompt change. That is slower, and it is also exactly what makes the agent's reach reviewable: you can read the complete list of things it can do.
- No planning. The model does not chain actions on its own. Multi-step work happens through explicit nested workflows that the user confirms one at a time.
- Degraded mode. The rule-based fallback keeps the agent usable when the model is unavailable, but it understands far fewer phrasings.
What is not finished
This is early access, and the open items are real:
- Identity and sign-in. Linking a WhatsApp number to an employee and the web sign-in are being moved to verified, token-based identity with deny-by-default role checks before the product goes beyond supervised early-access pilots.
- The audit trail should be a table. Actions are written as structured JSON log lines plus an activity history. We would move to an append-only audit table that also stores the parse result and the exact summary the user confirmed.
- Single instance. Sessions, locks and the parse cache live in SQLite, which is fine for one server. Running several instances means moving them to a shared store.
None of these touches the core rule, which is the part we would keep in any agent we build: the model proposes, code decides, and a person confirms.
Using this pattern in your own systems
The same design works for orders, tickets, inspections, approvals and field visits: a closed list of intents, typed workflows, resolution against your real records, role checks in code, and a confirmation built from data. We build agents this way as a service; see WhatsApp AI agents for business and enterprise AI agent systems. If you want the design worked out against your own systems first, we usually start with a two-week Architecture Sprint. The product itself is described on the AssetChat page.