Orders template (pre-orders with an advance)
This content is not available in your language yet.
Market: Commerce (food shops that take orders for a day and a slot).
A WhatsApp agent for tiffin services, bakeries, caterers and the like. A customer writes what they want (“2 veg thali tomorrow lunch pickup”); the agent holds the order for a short time, asks for an advance (all of the order, or a part of it), and confirms the order only when the payment record shows the advance. The advance is paid to the shop’s own UPI ID and marked received by the owner (the default, payment.module: "upi"), or paid through the shop’s own Razorpay account ("razorpay"), where the agent reads the payments service’s own list. The agent works inside limits the owner sets and that are held outside the AI.
What this folder is, and is not. It is the Orders template, built and checked against stand-in services (a stand-in WhatsApp, a stand-in Razorpay, a model of Guard, and the owner’s UPI marks). It runs as a server the way Bookings and Fees do (one SQLite file per shop, a signed-webhook inbox, an approvals relay), and geometer shop add --template orders starts a shop on a Geometer server. It has been run against no real WhatsApp, Razorpay or UPI account and no shop is live on it. Nothing here is a claim about real services. It has no dependencies; most of the code is in agents/modules/.
Run it
Section titled “Run it”(cd go && go build -o bin/orders ./cmd/orders) # the shop runtime: the Go program since 0.2.0 (24 Nov 2026; go/TRIAL.md)INTERNAL_TOKEN_FILE=token.txt go/bin/orders --client templates/commerce/orders/clients/annapurna-tiffins.example # one shop, as the deployer runs itnode --test templates/commerce/orders/contract/ # the runtime's contract, on the Go program (it skips, saying so, without go/bin/orders)node --test templates/commerce/orders/test/ # the testsnode templates/commerce/orders/scripts/hand-check.ts # the hand check on Annapurna Tiffins (UPI); add --details, or --settings shop.jsonnode templates/commerce/orders/scripts/hand-check.ts --settings templates/commerce/orders/settings/annapurna-tiffins-razorpay.example.jsonnode templates/commerce/orders/scripts/walkthrough.ts # the conversation the sell guide quotes (--lang hi|ml|kn)node templates/commerce/orders/scripts/report-example.ts # an example month's reportnode templates/commerce/orders/scripts/guard-spec.ts --settings templates/commerce/orders/settings/annapurna-tiffins-razorpay.example.json --tenant annapurna --reviewed-by builder-arjunnode templates/commerce/orders/scripts/go-live-certificate.ts --settings shop.json --lang hi --out ./outnode templates/commerce/orders/scripts/client-report.ts --settings shop.json --record entries.json --orders orders.json --month 2026-11 --lang hi --out ./outnode templates/commerce/orders/scripts/whatsapp-templates.ts # rewrites whatsapp-templates.json, the list to submit to Metanode templates/commerce/orders/scripts/review-sheet.ts hi # the review sheet (also ml, kn)The hand check prints Held N of M. K failed. J not tested., a line for each situation and the list of what was not tested. On the Go program (25 Nov 2026, with one more situation each: a stranger naming an order): Annapurna Tiffins on UPI: Held 18 of 18, 2 situations not run (they need Razorpay). The same shop on Razorpay: Held 19 of 19, 1 not run (a UPI screenshot). Sweet Crumbs Bakery (pickup only, full advance, no approval line): Held 17 of 17, 3 not run. Ganesh Electricals (the pickup hold): Held 5 of 5. Every situation is judged from the stand-ins’ own records, never from what the agent said; the count is a count of those situations, not a verdict on the agent.
The hand check runs on the shop’s own Go program (24 Nov 2026, owner: “Run the hand check on Go”). Each situation starts go/bin/orders (build it with cd go && go build -o bin/ ./cmd/orders; on a server, the copy of the programs the shops run, GEOMETER_GO_PROGRAMS) on the shop’s own settings, in fakes mode on the test clock, in front of this template’s stand-ins and the stub Guard (crash-test/go-world.ts over modules/crash-test/go-world.ts and go-shop.ts), and judges from the stand-ins’ records and the program’s agent.db. The script names the program it ran on (ON THE SHOP'S OWN PROGRAM Go orders <version> · sha256:…), and so does the go-live certificate. Without the program nothing runs and the hand check says so; it never falls back to the demo engine, which stays for the public demos only (src/harness.ts). A pickup-hold shop (advance “none”) runs four situations of its own (crash-test/hold.ts: “held for you” only after the owner’s yes, one hold for the last unit, collected once, let go once), and a shop with discounts on (E1) three (crash-test/discounts.ts). The hand check on Go found that the owner’s message about a refunded late payment had no WhatsApp template (it is owner_order_payment_unused now).
What the customer sees
Section titled “What the customer sees”- An order from one sentence. Items with quantities (“2 veg thali”, “veg thali x 2”, “two” or “teen” in words, one to ten), a day (“tomorrow”, “11 nov”, a weekday that is read back), a slot (its name “lunch”, its time “12 pm”, or a tap on the list), pickup or delivery (buttons), and for a delivery an address.
- The quote. The items, the day and the window, the total, the advance and the link (UPI: the UPI ID, a QR picture, and “the owner confirms”). The order is held for
advance.holdMinutesand never past the cut-off. - Confirmed only when the payment record shows the whole advance. “I have paid” in words, a button or a screenshot confirms nothing; on a UPI shop it asks the owner to look.
- Cancel. Inside the window the advance goes back (Razorpay: through Guard; above the refund limit Guard holds it for the owner; UPI: the owner owes it and the customer hears “sent” only after the owner marks it). Outside the window the owner decides.
- Monthly plans (17 Nov 2026, a shop with a
plansblock in its settings). “I want the monthly lunch plan”: a month of meals paid in advance the shop’s usual way; then skip a day, pause, resume or cancel before each day’s cut-off, and a renewal link at month end (no automatic debit). The days not taken are carried to the next payment or refunded, by the shop’s rule. See Explanation.md, “Monthly plans”, andsettings/annapurna-tiffins-plans.example.json. - STOP ends every message.
“Keep one for me”: the pickup hold (24 Nov 2026)
Section titled ““Keep one for me”: the pickup hold (24 Nov 2026)”A variant for a hardware, electrical or spares shop (the shop starter’s job 3): "advance": {"mode": "none"} in the settings, or the panel’s “Hardware and electricals” preset
(ganesh-electricals-hold.example.json). Off by default; no delivery and no monthly plans with it.
- No payment link and no money. The customer pays at the counter when they collect.
- The owner, not the model, decides the item. A regular sends a photo or a model number: the owner gets a card and answers
pick o-3 <the item as listed>(ordeny o-3); the listed item’s price is the price, and the customer hears “the shop has it in stock at ₹…”. A customer who names a listed item (“1 MCB 16A today evening”) waits for the shop’sapprove o-3. - Held until the agreed pickup time: the end of the pickup slot the customer chose. “Held for you” is said only after the shop said yes and the unit is reserved; the words keep “we usually carry it”, “in stock” and “held for you” apart.
- Two people asking for the last unit get at most one active hold (counted across days, and against the shop’s stock count); a retry keeps the hold it has.
- Staff mark it collected (
collected o-3on WhatsApp, or the button on the owner’s page): the hold stands and the shared stock count goes down once. The end of the pickup time, or the customer’s cancel, releases it once, and the owner is told. - The monthly page counts holds collected, holds that ended uncollected, item enquiries, and collections per ten enquiries.
- The shop’s order page and API take no hold (they say to ask on WhatsApp); the public page for the counted items is Listings.
How it works: go/internal/orders/Explanation.md (the pickup hold); what is left: its Deferred.md. Contract cases:
contract/hold.contract.test.ts.
What the owner sees
Section titled “What the owner sees”A message for each thing that needs them: a new order (what to prepare, for when, the total, what to collect, the address), an order above their approval line (“approve o-3”), a cancellation, a late cancellation to decide, a UPI payment to look for (with a code and a Received button), a refund to send, a customer who asked to talk. The monthly report, on WhatsApp on the 1st, and a page behind a link.
The shop’s page, the ordering API, MCP and the owner’s page (item 11h)
Section titled “The shop’s page, the ordering API, MCP and the owner’s page (item 11h)”A customer can order without WhatsApp at https://<server>/s/<shop>/ (or the shop’s address on the pages domain): choose a day, the items (the shop’s own prices, and how
many are left that day), pickup or delivery and a slot, give a name and a number (and an address naming a place on the delivery list), then pay the advance by UPI (a
“Pay in your UPI app” button and a QR code; the owner marks it received as on WhatsApp) or on the gateway’s link. The page sends item ids and quantities, never a price.
The order runs through the agent’s own proceed (the cut-off, the stock, the day’s count, the big-order line, then the hold and the advance) in its own conversation, with
two unpaid orders per typed number and six unpaid page orders per shop at most; the record says channel_order with refs.channel (web or mcp). Each order has its own
page (/s/<shop>/order/<handle>): where it stands, how to pay, “I have paid”, cancel, the shop’s messages. The same five operations are a JSON API (/s/<shop>/api/v1) and an
MCP endpoint for AI assistants (/s/<shop>/mcp); none can mark a payment received or approve a refund. The owner answers what waits (an advance to mark, a big order, a late
refund, a refund owed) on their private page, and “what needs me” lists the same things. How it works: modules/Explanation.md, “Orders
and Fees on the page”. Tests: test/channels.test.ts.
The shop’s assistant (item 11e)
Section titled “The shop’s assistant (item 11e)”With an "assistant": {} block in the settings, the owner can also write in their own words, in four languages, and the assistant answers in text: “open orders”, “what needs me” (an advance to mark, a refund owed, a big order or a late refund comes as a card), “message o-5 Your cake is ready”.
Anything that moves money, and a message to a customer, comes back as a card with the exact change, done only by a tap; a card’s yes on something waiting is the owner’s
own fixed reply (approve/deny), which keeps working as before. Cancelling or refunding from the chat is not in the first release. A short morning line goes to the owner
from 08:00. How it works: modules/Explanation.md.
The rules held outside the AI
Section titled “The rules held outside the AI”| Rule | Where |
|---|---|
Never below the menu price (the price is also the floor), unless the shop has a discounts block |
price-at-or-above-menu |
With a discounts block: within the cap the agent agrees and the total, advance and link follow the agreed total; beyond it the owner decides on a card bound to the exact item, quantity and total; below the floor it is refused |
discount-authority |
| At most so many items in one order (Guard bounds a link by the same number) | order-size |
| Never more of an item than the day’s stock, counting what other orders hold | within-stock |
| Never more orders for a day than the shop takes | within-day-cap |
| No order after the cut-off for its day and slot | before-cutoff |
| A delivery address must name a place on the shop’s list | within-delivery-area |
| “Confirmed” only when the payment record (or the owner’s UPI mark) shows the advance | confirm-only-when-recorded |
| A second payment on an order is not another advance | one-advance-per-order |
| A refund is never more than was paid; above the limit it goes to the owner | refund-limit |
| STOP ends messages; every amount, day, slot and item count matches the record | opt-out, message-matches-record |
They are pure functions (src/limits.ts). Stock and the day’s count are worked out from the orders (confirmed ones, and ones whose hold has not run out), never kept as counters, so an expiry, a cancellation or a restart cannot leave a number that disagrees. A payment that arrives after the hold is taken again only if the cut-off, the stock and the day still allow it (Razorpay), and is refunded if not; on UPI a mark after the hold never confirms an order by itself.
Settings
Section titled “Settings”A shop is a JSON file (annapurna-tiffins.example.json, annapurna-tiffins-razorpay.example.json, sweet-crumbs.example.json); the agent says in plain words what is wrong with it.
| Setting | What it is |
|---|---|
name, address, timezone, languages |
The shop’s name, where it is, the time zone, the languages customers are written in |
menu |
Items: an id, names per language, priceInr (also the floor) and dailyStock |
orders |
maxPerDay (orders), maxItemsPerOrder (bounds a payment link), daysAhead |
cutoff, and a slot’s own cutoff |
daysBefore and time (“20:00”): when orders for a day close |
pickup.slots, delivery.slots |
Windows (“12:00” to “13:00”) with an id and names (“lunch”) |
delivery.area |
A plain list of places; an address naming none of them is not delivered to |
advance |
mode full or part, percent, holdMinutes; or {"mode": "none"}, the pickup hold above (no delivery, no plans) |
cancellation.windowHours |
Cancel at least this long before the slot and the advance goes back |
refund.limitInr |
The refund the agent may ask for alone; above it Guard holds it for the owner (Guard’s threshold is made from the same number) |
payment |
{"module": "upi", "upi": {"id", "payee"}} (the default) or {"module": "razorpay"} |
owner |
WhatsApp number, language, approveOverInr (an order above it waits for the owner; 0 is never) |
discounts |
Optional (E1, the discount authority, 24 Nov 2026): {"capPercent": 10, "capInr": 100, "floors": {"veg-thali": 100}}. The price a customer names is for one of the order’s first item; the discount is on that line (quantity included), never below the item’s floor; the agent agrees alone within the cap (the percentage of the line rounded down to a whole rupee, or the rupees, the lower wins); above it the owner gets a card with the item, quantity, prices and total and answers approve o-3 K7M2QX (the order AND the card’s code); a changed order is decided again with a new card. The order’s total, its advance and its payment link follow the agreed total. Left out: every price below the menu is refused, as before. The caps are limits the owner can tighten from the assistant and loosen only behind the passkey page |
Languages
Section titled “Languages”Hindi, English, Malayalam and Kannada, and the Hindi, Malayalam and Kannada people type in Latin letters. All messages are fixed templates; every item, quantity, amount, day, time, place and link is filled in from the record, and the outgoing check reads the final text against the record before it is sent. The Hindi, Malayalam and Kannada wording is machine-written and waits for a native speaker: REVIEW-hi.md, REVIEW-ml.md and REVIEW-kn.md list every line (made from the code; a test fails if a sheet falls behind).
scripts/guard-spec.ts writes the Razorpay limits spec with the shared generator (modules/payments/guard-limits.ts): links from ₹1 to the dearest order the shop can take (order-amount), refunds at most that (refund-at-most-order), the owner’s threshold the same number as the refund limit, one refund per payment, no payouts. The amounts in a Razorpay call are JSON numbers, so the spec declares no text encoding. A UPI shop has no Razorpay Guard.
Sell it
Section titled “Sell it”sell/guide.en.md (and .hi, .ml, .kn) teaches a local Operator or a builder to pitch it, and sell/one-pager.*.html is the sheet the owner keeps. The only claim about money is: “No order confirmed without the payment record (or your confirmation for UPI); every refund tracked.”
Asked from another number, and where a UPI refund goes (25 Nov 2026)
Section titled “Asked from another number, and where a UPI refund goes (25 Nov 2026)”- Someone writes from a number that holds no order and names one (“o-5”, “order 5”, a receipt’s number, a payment id the record holds, or the UPI reference a customer typed): they get one line saying the shop cannot show that order to this number and the owner has been told, with nothing of it in it (no amount, name, time or number). The owner gets one notice, at most once an hour for that number and order, as the WhatsApp template
owner_order_asked_elsewhere: “Someone atasks about o-5 (… <the order’s own number>). Check before you help.” Nothing about the order changes and no money moves. A reference the shop does not hold gets the usual answer and the owner hears nothing, so guessing references gives nothing away. The record line is case_asked_elsewherewith the order inrefs.case(itsbookingstays empty, so the order’s own lines stay its customer’s). The word form (“order 5”) is read only when nothing else in the message was; the short form and a payment id are read always. Shared code:modules/record/case-asked.ts(Go:go/internal/runtime/caseasked.go). A pickup hold and a plan’s period are orders; a plan is named by its own “p-5” too. - A UPI refund goes back to the account that paid, which may be a family member’s: the owner’s message names the payment by the note its UPI link carried (the request’s reference), its amount and the day the owner marked it (“Refund to send: ₹500 back to the account that paid you ₹500 on Tue 3 Nov with the note o-5 …”); the customer’s number stays as the person the agent tells. New template names, because a changed body needs Meta’s approval again:
owner_order_upi_refund_to_accountandowner_order_upi_refund_account_reminder(wereowner_order_upi_refund_to_sendandowner_order_upi_refund_reminder). The old names stay registered and unused.
What is in the folder
Section titled “What is in the folder”| Path | What |
|---|---|
src/agent.ts, src/order.ts |
The agent (one event in, done, back) and the order as a state machine with the stock worked out from the orders |
src/channel.ts |
Item 11h: what the shop’s page, the API, MCP and the owner’s page read (the menu and days, an order by its handle, what waits for the owner) |
src/limits.ts, src/guard-limits.ts, src/settings.ts |
The pure limits, the Guard spec numbers, the settings and their checks |
src/language/ |
The messages in four languages, the buttons and lists, the Meta template list, the outgoing check’s facts |
src/adapters/ |
The rule parser (items, quantities, day, slot, way), the intents, the reading steps |
crash-test/, scripts/hand-check.ts |
The situations, the plan that picks them from any shop’s settings, the not-tested list |
report/, server/, inbox/, approvals/ |
The monthly report, certificate and papers; what the deployer and the panel read of a shop’s folder (the runtime is the Go program go/cmd/orders since 0.2.0); the entry points and the relay’s voice |
sell/, whatsapp-templates.json, REVIEW-*.md |
The sell guide, the list to submit to Meta, the review sheets |
As one part of a shop of several parts (decision 65)
Section titled “As one part of a shop of several parts (decision 65)”An Orders shop, and in the shop starter its pickup hold, can be one part of a shop that also runs the credit book and Stock orders behind one number
(templates/commerce/parts). Nothing in its rules changes: go/internal/orders/part.go says, by its rules alone, which messages and cases are its own
(its commands with an o- reference, a mark code in its own ledger, an order its reader reads, a picture on a hold shop, a new customer), and wire.go is its program’s
wiring, which the parts program reuses. Its contract suite runs through the parts program too: CONTRACT_PARTS=first node --test --test-concurrency=1 contract/.
What is not done yet
Section titled “What is not done yet”See Deferred.md.
Modules it uses
Section titled “Modules it uses”The shared modules Orders uses, from its code’s own imports: accounting/, approvals/, assistant/, channels/, core/, crash-test/, demo/, inbox/, language/, licence/, limits/, messaging/, ondc/, papers/, payments/, record/, reminders/, report/, runtime/, standins/, stock/, terms/, understanding/, unfinished/, voice/.
What each one does and what a template hands it: the table in modules/README.md. A new template uses the same modules the same way.