On this page
To eliminate phantom and wrong orders in an AI sales agent, separate draft assembly from order creation using four mandatory confirmation gates: lock canonical SKUs and quantities, validate recipient phone and street address fields, compute itemized subtotal, shipping, and grand total server-side inside a summary card, and block execution until the customer returns an explicit approval token tied to that exact draft version and an idempotency key.
Editorial disclosure: This engineering guide is published and compiled by TrolyPage, whose platform includes built-in AI order-drafting action tools, shipping fee calculation, payment link verification, and human handoff controls evaluated alongside custom tool-calling architectures below.
Why Conversational Checkout Fails Without an Order Draft Boundary
Read-only product search and state-mutating order creation carry very different blast radii. If catalog lookup returns a broad match, the shopper asks a follow-up question. When an AI agent triggers an order write prematurely or with unverified parameters, the business immediately absorbs payment fees, inventory locks, packing labor, and carrier surcharges.
Under the OWASP LLM06:2025 Excessive Agency specification (checked 2026-11-27), granting an LLM unchecked autonomy to run irreversible external actions—without downstream validation and human approval outside the prompt context—turns routine ambiguity into high-impact operational incidents. On Messenger, Instagram DM, WhatsApp, and Website Chat, shoppers write shorthand like "yeah send the olive medium to my place" before ever seeing shipping charges.
Take a US direct-to-consumer merchant at a $74.00 average order value (AOV), 45% gross margin ($33.30 gross profit), and $7.50 outbound shipping. One phantom order from an ambiguous reply—or a duplicate write from a retried webhook—that ends in a card dispute incurs a $15.00 to $25.00 chargeback fee plus $7.50 in lost postage, wiping out $22.50 to $99.00. Even a non-disputed wrong-address shipment triggers a $20.00+ mid-transit carrier correction fee or a $26.50 Return-to-Sender and reshipment cycle ($7.50 out + $7.50 return + $7.50 reship + $4.00 handling), erasing 80% of order gross profit.
Comparing Three Order Creation Architectures: Option A vs. Option B vs. Option C
Engineering teams implementing conversational order draft confirmation gates ai agent workflows generally converge on one of three designs. Each pattern makes fundamentally different trade-offs across agency containment, schema determinism, operational labor, and post-purchase error cost.
| Architecture Option | Confirmation & Agency Control | Payload Determinism & Idempotency | Operational Overhead per 1,000 Orders | Primary Failure Mode & Unit Cost |
|---|---|---|---|---|
| Option A: 4-Gate Order Draft + Itemized Summary Card + Explicit Approval Token | Server blocks commit_order until the buyer approves a versioned summary card showing SKU, qty, shipping, total, address, and phone. |
Strict JSON Schema (strict: true), server-computed totals, SHA-256 draft_hash lock, and 24-hour UUID v4 idempotency_key. |
0 manual re-keying minutes on clean orders; ~350–500 extra structured tokens per checkout (~$0.001–$0.003 at API rates). | Adds 1 explicit confirmation turn; ~2%–4% extra drop-off among window-shoppers who never intended to buy. |
| Option B: Implicit Single-Turn Auto-Commit | LLM invokes create_order directly as soon as it infers purchase intent from conversational cues without an itemized recap. |
Loose or missing parameter validation; model frequently estimates totals or commits unverified street strings and duplicate retries. | 0 pre-order minutes, but generates 40–65 exception tickets per 1,000 orders for address edits, cancellations, and duplicate refunds. | $1,350–$2,245 per 1,000 orders across phantom chargebacks ($22.50–$99.00 each) and RTS/address-correction fees ($20.00–$26.50 each). |
| Option C: Free-Text Chat Summary + Manual Agent Re-Entry | Bot summarizes order details in unstructured chat text and notifies human staff to manually key the order into the POS or backend. | No schema enforcement; customer edits split across multiple messages force agents to scroll chat history to assemble the cart. | ~58.3 hours of manual data entry per 1,000 orders (3.5 min/order), costing $1,400/mo at $24.00/hr loaded support labor. | 1%–2% human transcription typos (10–20 wrong-SKU or wrong-ZIP errors per 1,000 orders) plus delayed off-hours fulfillment. |
Why Option B Leaks Margin and Option C Breaks Scaling
Option B optimizes for perceived speed while sacrificing fulfillment integrity. When 2.5% of 1,000 monthly chat orders become unwanted phantom or duplicate commits and 3% ship with uncaught mobile address typos, direct dispute and reshipment losses reach $1,350 to $2,245 per month before support labor.
Option C prevents automated phantom orders by requiring staff on every sale, yet it forfeits AI automation economics. Paying agents $24.00/hr for 3.5 minutes of manual order re-keying costs $1,400 per 1,000 orders and reintroduces copy-paste typos during peak hours.
The 4 Mandatory Confirmation Gates Before Creating an Order

Option A eliminates both automated phantom writes and manual re-keying by splitting conversational checkout into a deterministic state machine. The LLM gathers intent and renders structured cards, while application code enforces all four confirmation gates before any order row or payment capture is committed.
Gate 1: Cart and Line-Item Lock (Canonical SKU, Quantity, Unit Price)
Never allow an order-creation endpoint to accept a free-text product name like "Merino Crewneck Olive" or a model-supplied unit price. Gate 1 requires every line item inside the draft to resolve to a canonical sku_id returned by the catalog tool, paired with a positive integer quantity and live sellable inventory verification (available >= quantity).
- Server-side price authority: The LLM passes only
sku_id,quantity, and optionalpromo_code. The backend queries the authoritative price book and writesunit_price_centsdirectly into the draft record. - Atomic draft versioning: Every addition, removal, or quantity change increments
draft_version(for example, fromv1tov2) and immediately voids any earlier confirmation token. - Line-item cap and sanity checks: Enforce sensible per-SKU quantity ceilings (such as
max_qty: 20for retail DTC) so a speech-to-text glitch like "two zero" cannot silently draft 20 units without triggering a human review flag.
Gate 2: Recipient Identity and Deliverable Address Validation
According to Baymard Institute's address validator UX research (checked 2026-11-27), 47% of ecommerce sites fail to provide an address validator at checkout, leaving mobile typos, wrong states, transposed postal codes, and missing apartment numbers undetected until carriers fail delivery. In chat threads—where shoppers type quickly on phone keyboards without browser autofill—error rates are even higher.
Gate 2 blocks shipping calculation and summary card generation until the recipient payload passes deterministic validation outside the LLM:
- Recipient name: Non-empty full name (at least two tokens or verified account name, rejecting placeholders like
"Me"or"Test"). - Phone normalization: Normalize and validate against E.164 or country-specific rules (for US/Canada, 10 digits formatted to
+1XXXXXXXXXX, rejecting repeated digits like5555555555or incomplete strings). - Structured street and postal checks: Require
address_line1(containing both street number and street name),city, 2-letterstate_code, and validated 5-digit or ZIP+4postal_code. When an address validator (USPS, Loqate, Google Address Validation, or Smarty) flags a missing secondary unit indicator on a multi-unit building, Gate 2 transitions to a targeted clarification prompt: "Looks like 742 Evergreen Ave has multiple units—what is your apartment or suite number?"
Gate 3: Deterministic Pricing, Shipping Fee, and the Order Draft Summary Card
Surprising buyers with shipping fees or tax at the last moment drives abandonment and post-purchase cancellations. Baymard Institute's cart abandonment research (checked 2026-11-27) reports an average ~70% abandonment rate across online checkouts, with unexpected extra costs (shipping, taxes, fees) acting as a top driver. In chat sales, hiding shipping fees until after order creation converts pre-checkout abandonment into angry support tickets and refund fees.
Gate 3 forbids the language model from performing arithmetic. Once Gate 1 and Gate 2 are green, the backend calculates:
subtotal_cents = sum(unit_price_cents * quantity)discount_cents(validated against active promo rules and minimum spend thresholds)shipping_fee_cents(queried from the carrier rate table or flat-rate zone engine usingpostal_codeand cart weight)tax_cents(computed from destination jurisdiction)grand_total_cents = subtotal_cents - discount_cents + shipping_fee_cents + tax_cents
The server hashes the canonical JSON snapshot of line items, shipping address, phone, and pricing breakdown into a SHA-256 draft_hash, stores the snapshot with a 30-minute expiration timestamp, and instructs the agent to render the Order Draft Summary Card verbatim before asking for approval.
Gate 4: Explicit Customer Approval Token and Idempotent Commit
Gate 4 enforces the core principle of OWASP LLM06:2025 Excessive Agency mitigation: authorization lives in application code, never in the LLM's subjective judgment. The backend refuses to execute commit_order unless all three cryptographic and conversational conditions hold:
- Post-card explicit confirmation: The customer's latest message occurred after the current
draft_versionSummary Card was sent and contains an unambiguous confirmation signal—either a structured quick-reply payload (APPROVE_DRAFT_v2_9f3a) or an explicit affirmative text match (such as"confirm","yes, place order", or"place my order") with zero unresolved edit requests in the same turn. - Hash parity check: The
draft_hashpassed intocommit_ordermatches the active server-side draft record and has not expired. If the customer tweaked quantity or ZIP code, the hashes mismatch and the commit is rejected cleanly. - Idempotency key enforcement: Following Stripe's Idempotent Requests specification (checked 2026-11-27), every
commit_orderwrite requires a client-generated high-entropyidempotency_key(UUID v4, retained for at least 24 hours) tied to that specificdraft_idanddraft_version. If a social platform retries a webhook or the LLM retries a timed-out tool call with the same key and parameters, the backend returns the existingorder_idwithout creating a second order; if parameters differ, the server rejects the conflicting call.
Production Asset 1: 4-Gate State Machine & Order Draft Summary Card Spec

Use the state machine and formatted Summary Card specification below as the contract between your conversational orchestrator, UI renderer (Messenger generic/button template, WhatsApp interactive reply buttons, or Website Chat card), and order persistence service.
STATE MACHINE: 4-GATE ORDER DRAFT
[1] COLLECTING_ITEMS (Gate 1)
Req: canonical sku_id, int qty >= 1, live available >= qty, server unit_price_cents.
Edit -> draft_version += 1, void prior approval_token.
[2] VALIDATING_DESTINATION (Gate 2)
Req (server-side): full_name, E.164 phone (+1XXXXXXXXXX), street line,
multi-unit check (Apt/Suite if required), city, 2-letter state, valid ZIP.
[3] QUOTED_AWAITING_CONFIRMATION (Gate 3)
Server computes subtotal, discount, shipping_fee, tax, grand_total;
writes draft_hash = sha256(snapshot), expires_at = now + 30m, UUID v4 idempotency_key.
Action: Send Summary Card verbatim; block commit_order until next buyer turn.
Branch: edit -> [1]/[2]; 2 address fails or total > $500 -> HUMAN_HANDOFF.
[4] COMMITTED (Gate 4)
Verify: explicit approval after card sent + draft_hash match + !expired + 24h idempotency lock.
ORDER DRAFT SUMMARY CARD (GATE 3)
Order Draft #DRF-84920 (v2) — Review Before Confirming
Items:
- 2x Merino Crewneck Sweater (Olive / M) [MRN-CRW-OLV-M] — $98.00 ea ($196.00)
- 1x Cedar Care Comb [ACC-CMB-CDR-01] — $14.00 ea ($14.00)
Subtotal: $210.00 | Promo (WELCOME10): -$21.00 | USPS Priority (94107): $8.50 | Tax: $17.85
Grand Total: $215.35 USD
Deliver To: Maya Lin | +1 (415) 555-0194 | 742 Brannan St, Apt 4B, San Francisco, CA 94107
Valid 30 min. Reply "CONFIRM" or tap [Confirm Order - $215.35] to place your order.
Production Asset 2: Strict Order Draft JSON Schema & System Prompt Guardrail
Per OpenAI's Structured Outputs specification (checked 2026-11-27), enabling "strict": true enforces 100% schema adherence at decoding time, provided every object sets "additionalProperties": false and lists every key inside "required" (using nullable unions such as ["string", "null"] for optional values). Similarly, Anthropic's Claude Tool Use architecture (checked 2026-11-27) delegates tool execution entirely to your host application, allowing backend middleware to inspect the state machine before executing any write.
Split draft assembly (upsert_order_draft) from irreversible order creation (commit_order), and pair both tools with the system prompt guardrail below.
{
"tools": [
{
"type": "function",
"function": {
"name": "upsert_order_draft",
"description": "Create or update an unconfirmed order draft, check SKU stock, validate phone/address, and compute subtotal, shipping, tax, and grand total. Never creates an order.",
"strict": true,
"parameters": {
"type": "object",
"properties": {
"conversation_id": {"type": "string"},
"draft_id": {"type": ["string", "null"]},
"line_items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"sku_id": {"type": "string"},
"quantity": {"type": "integer"}
},
"required": ["sku_id", "quantity"],
"additionalProperties": false
}
},
"promo_code": {"type": ["string", "null"]},
"recipient": {
"type": "object",
"properties": {
"full_name": {"type": ["string", "null"]},
"phone_raw": {"type": ["string", "null"]},
"address_line1": {"type": ["string", "null"]},
"address_line2": {"type": ["string", "null"]},
"city": {"type": ["string", "null"]},
"state_code": {"type": ["string", "null"]},
"postal_code": {"type": ["string", "null"]},
"country_code": {"type": "string"}
},
"required": ["full_name","phone_raw","address_line1","address_line2","city","state_code","postal_code","country_code"],
"additionalProperties": false
}
},
"required": ["conversation_id","draft_id","line_items","promo_code","recipient"],
"additionalProperties": false
}
}
},
{
"type": "function",
"function": {
"name": "commit_order",
"description": "Finalize a quoted draft ONLY after the Summary Card was sent and the buyer explicitly confirmed the matching draft_version and draft_hash.",
"strict": true,
"parameters": {
"type": "object",
"properties": {
"conversation_id": {"type": "string"},
"draft_id": {"type": "string"},
"draft_version": {"type": "integer"},
"draft_hash": {"type": "string"},
"idempotency_key": {"type": "string"},
"confirmation_text": {"type": "string"},
"payment_method": {"type": "string", "enum": ["payment_link","cod","bank_qr"]}
},
"required": ["conversation_id","draft_id","draft_version","draft_hash","idempotency_key","confirmation_text","payment_method"],
"additionalProperties": false
}
}
}
]
}
SYSTEM PROMPT GUARDRAIL:
1. Never calculate prices, shipping, taxes, or totals yourself; always call upsert_order_draft.
2. Never call commit_order in the same turn as upsert_order_draft. Show the full Order Draft Summary Card (SKU, qty, unit price, shipping fee, grand total, recipient, phone, address) and wait for the buyer's reply.
3. Never treat "ok", "thanks", or emojis as confirmation. Call commit_order only on explicit confirmation ("CONFIRM", "Yes, place order", or approval button) with zero edits.
4. Escalate to human handoff after 2 failed address/phone checks, orders over $500, or custom fee requests.
Edge-Case Handling: Mid-Confirmation Edits, Retries, and Timeout Windows
Production chat threads rarely move in a straight line from Gate 1 to Gate 4. Three recurring edge cases determine whether your architecture holds up under real customer behavior:
- Mid-confirmation edits ("Confirm, actually make it 1 sweater and ship to my office"): Even though the message starts with "Confirm", it mutates both Gate 1 and Gate 2. Your orchestrator must never call
commit_orderon a mixed edit-and-confirm utterance. Instead, route back toupsert_order_draft, incrementdraft_versiontov3, recompute shipping for the new ZIP code, generate a freshdraft_hash, and render a new Summary Card. Because Gate 4 checks hash parity on the server, any mistakencommit_orderattempt using the oldv2hash fails safely. - Duplicate webhook deliveries and network timeouts: Meta Messenger and WhatsApp Cloud API can redeliver identical webhook events if your endpoint takes more than a few seconds to respond. Binding a deterministic UUID v4
idempotency_keyto(draft_id, draft_version)inside a 24-hour key store guarantees that a retriedcommit_orderrequest returns the already-createdorder_idrather than double-charging a card or emitting two fulfillment tickets. - Expired quotes and inventory drift: If a buyer asks for a draft at 10:00 AM and replies "CONFIRM" at 6:00 PM, unit prices, promo codes, or stock levels may have changed. Set a 30-minute
expires_atTTL on Gate 3 quotes. When an expireddraft_hashhitscommit_order, reject the commit, re-runupsert_order_draftagainst live stock and rates, and confirm any changed total before finalizing. - Escalating tricky orders cleanly: When address validation fails twice, total order value exceeds your automated threshold (such as $500+ COD), or the buyer requests custom delivery splits, trigger deterministic escalation following these 5 human handoff rules for AI chatbots so staff receive the partial draft without the bot continuing to reply.
Implementing Order Draft Guardrails in TrolyPage vs. Custom Stacks
Teams do not always need to build a custom LangGraph or FastAPI orchestrator from scratch to enforce the four gates. Inside TrolyPage's unified inbox and AI agent platform, several pieces of this confirmation pipeline are already built as native AI Action Tools—specifically product lookup, order drafts, shipping fee calculation, and payment links/QR verification—paired with a deterministic handoff lock that pauses automated AI replies the moment a conversation escalates to a human agent.
If your team connects external AI workflows or internal tooling, the TrolyPage MCP gateway exposes 291 tools across a unified server and 11 domain servers for Claude, ChatGPT, Cursor, or VS Code (note that TrolyPage's pricing page still displays legacy 86-tool copy from an earlier release), while outbound trigger webhooks, Zapier Webhooks, and Google Sheets OAuth sync push confirmed order records to external fulfillment sheets or ERPs.
At the same time, account for TrolyPage's documented boundaries before committing your stack:
- No visual drag-and-drop chatbot flowchart builder: TrolyPage configures behavior via knowledge bases, system instructions, and trigger-condition-action rules rather than node-and-edge trees.
- No native two-way Shopify, WooCommerce, or BigCommerce order or refund sync: TrolyPage offers a built-in catalog, orders, and inventory system plus Website Chat embeds, while external stores sync via webhooks, Zapier, or Google Sheets.
- Public API and support hours: No generally released public developer REST API exists yet (automation relies on webhooks and MCP), and while AI agents run 24/7, live staff support operates during Vietnam business hours (
UTC+7).
From a budget perspective on TrolyPage's USD pricing plans, teams can validate the 4-gate summary card prompt and action tools on the time-limited Free workspace trial ($0.00/mo, 100 MAU, 50,000 AI tokens—not a permanent free tier), then scale on Lite ($8.00/mo, 4M tokens), Starter ($16.00/mo, 16M tokens), Pro ($32.00/mo, 40M tokens), or Scale ($104.00/mo, 200M tokens), with extra human seats at $1.00/mo each.
Pre-Launch Validation Checklist for Conversational Order Drafts
Before routing live traffic through an AI order-drafting agent, verify all six controls in staging:
- Same-turn commit block: Attempt
upsert_order_draftandcommit_orderin one user turn; confirm the backend rejects the commit withSUMMARY_CARD_NOT_SENT. - Server price authority: Verify
commit_orderignores chat prose prices and reads solely from the hashed server draft. - Address and phone rejection: Submit an 8-digit phone or missing apartment number; verify Gate 2 blocks Gate 3 and requests the missing field.
- Edit invalidation: Show a
v1Summary Card, reply "change quantity to 3", and verifyv1fails hash validation untilv2is confirmed. - Idempotency replay: Replay
commit_ordertwice with the same UUID v4idempotency_key; confirm only one order is created. - Handoff pause: Trigger an agent takeover and verify automated AI replies stay paused until staff release the thread.
Comments
Your comment will appear after review.
Sign in to commentNo comments to show.