On this page
To design reliable catalog lookup for AI sales agents, replace plain-text RAG over product PDFs with a strict JSON-schema tool backed by live SKU variant and bundle resolvers. Use a two-step narrowing flow—matching the parent product first, then resolving exact option combinations against sellable stock—and automatically trigger an in-stock substitute lookup instead of ending conversations at out-of-stock dead ends.
Editorial disclosure: This engineering guide is published and compiled by TrolyPage, whose platform includes built-in catalog lookup, order-drafting AI action tools, and omnichannel inbox automation evaluated alongside custom tool-calling architectures below.
Why Plain-Text Catalog RAG Breaks on Multi-Variant Ecommerce
Most teams launch their first AI sales assistant by uploading a product spreadsheet or scraping storefront pages into a vector database. That pattern works for a 15-item catalog, yet it fails quickly on physical ecommerce catalogs with colorways, sizes, pack counts, and bundles. Vector similarity excels at prose descriptions ("breathable summer shirt"), not deterministic SKU constraints ("Olive, Medium, shippable today").
Consider a mid-market apparel or home-goods merchant running 400 parent products averaging 12 variants each (4,800 active SKUs). As documented in Shopify's product merchandising documentation (checked 2026-11-27), modern product models support up to 3 options and scale up to 2,048 variants per parent product via GraphQL APIs. Flattening 4,800 SKUs into text chunks consumes 220,000 to 280,000 tokens; even pulling six 800-token chunks per turn feeds 4,800 tokens of dense tables while leaving the model guessing whether stock changed minutes ago.
Plain-text retrieval also treats inventory numbers as static prose instead of operational state. Per Shopify's inventory quantities and states specification (checked 2026-11-27), counts split across on_hand (physical units), committed (allocated to orders), reserved (draft checkouts), safety_stock, and available (sellable). When RAG reads on_hand: 3 while committed: 3, the agent confirms availability on a sold-out SKU.
Every wrong-SKU promise carries direct margin damage. As a unit-economics illustration, on a $68.00 US apparel order with $6.50 outbound postage, a $7.50 return label, and $4.00 in restocking labor, one oversold colorway or mismatched size burns $18.00 in reverse-logistics cost—erasing over half the order's gross margin.
Comparing Three Catalog Lookup Architectures for AI Sales Agents

When designing the retrieval and tool layer for an AI sales agent's catalog lookup and SKU variants, engineering teams choose among three distinct patterns. The differences are not cosmetic; they govern schema compliance, token burn, stale-stock exposure, and recovery rates when a shopper's first-choice SKU is unavailable.
| Architecture Option | Schema & Argument Determinism | Inventory & Bundle Accuracy | Token Overhead & Latency per Turn | Primary Technical & Economic Failure Cost |
|---|---|---|---|---|
| Option A: Typed Catalog Lookup Tool + Live Inventory & Bundle Resolver | 100% schema adherence when using strict JSON Schema (strict: true, additionalProperties: false, explicit enums/nullables). |
Reads live available stock minus safety buffers at query time; computes virtual bundle stock dynamically from component minimums. |
Modeled 250–400 tokens of structured JSON returned for top 5–8 candidate variants; target 120–280 ms DB/cache lookup budget before LLM synthesis. | Requires upfront schema maintenance and attribute normalization (e.g., mapping "navy" and "midnight" to canonical option values). |
| Option B: Free-Text Tool Arguments Without Enum or Schema Constraints | Unbounded string parameters allow malformed SKUs, concatenated attributes ("Olive / M / Pack2"), or omitted currency/channel filters. |
Queries live stock only when the backend fuzzy-parser guesses the intended variant; silent misses force empty arrays or ambiguous matches. | Modeled 400–900 tokens per lookup cycle when fuzzy matches return up to 25 unranked rows or malformed arguments force retry turns. | Silent lookup misses when unnormalized synonyms fail fuzzy parsing, forcing 1–2 extra retry turns that roughly double tool-payload tokens and push ambiguous requests to human agents. |
| Option C: Pure Text RAG Over Exported PDFs or Crawled Product Pages | Zero runtime parameter validation; the LLM extracts variant prices and stock status probabilistically from prose chunks. | Stale by hours or days between re-index jobs; cannot subtract committed stock or compute multi-component bundle bottlenecks dynamically. |
Modeled 3,500–5,500 prompt tokens per turn from retrieved product tables; high hallucination risk across adjacent price rows. | Illustrative $18.00+ reverse-logistics and refund loss per wrong-SKU or oversold order, plus stalled out-of-stock sessions with no guided alternative. |
Why Option B Fails Quietly in Production
Many teams leave tool parameters loosely typed—accepting a single query: string field—and assume the model will format arguments cleanly. Under real Messenger, Instagram DM, or Website Chat messages, shoppers write messy shorthand ("got the merino crew in charcoal xl or l?"). Without strict schemas, the model passes full sentences into sku or invents non-canonical color names ("Light Grey" instead of "Heather Ash"). When the backend returns an empty array, the LLM either hallucinates a plausible-sounding answer or dumps an unformatted wall of text.
Core Engineering Pattern: Two-Step Variant Narrowing

Shoppers rarely start with an internal SKU code like MRN-CRW-OLV-04; they start with a style name or price ceiling ("men's wool sweater under $120"). Two-step narrowing separates parent discovery from variant resolution:
- Step 1 — Parent Discovery (
mode: "discover_parent"): Search by product family, budget, or partial attributes (product_query: "Merino Crewneck",color: "Olive",size: null). Return the parent price ($98.00) and a compact matrix of in-stock option values, hiding sold-out sizes unless asked. - Step 2 — Exact Variant Lock (
mode: "resolve_sku"): Once the shopper picks the missing option ("Medium"), call the tool with exact attributes orparent_id, verifyavailable > 0minus safety stock, and return the canonical SKU and order-draft payload.
Strict JSON Tool Schema for catalog_lookup and substitute_sku_lookup
Both OpenAI's Function Calling guide and Structured Outputs documentation (checked 2026-11-27) specify that "strict": true requires "additionalProperties": false on every object schema and requires every property in "required" (using nullable unions like ["string", "null"] for optional parameters). Anthropic's tool definition guide (checked 2026-11-27) likewise emphasizes detailed tool and parameter descriptions for reliable invocation.
The two-tool schema below works cleanly across strict OpenAI-compatible and Claude tool runners:
{
"tools": [
{
"type": "function",
"function": {
"name": "catalog_lookup",
"description": "Search catalog, narrow SKU variants, and verify live available stock or bundle capacity. Use discover_parent when options are missing; resolve_sku once options are known.",
"strict": true,
"parameters": {
"type": "object",
"properties": {
"mode": { "type": "string", "enum": ["discover_parent", "resolve_sku", "check_bundle"] },
"sku_code": { "type": ["string", "null"] },
"parent_id": { "type": ["string", "null"] },
"product_query": { "type": ["string", "null"] },
"color": { "type": ["string", "null"] },
"size": { "type": ["string", "null"], "enum": ["XS", "S", "M", "L", "XL", "XXL", "Queen", "King", "OneSize", null] },
"quantity": { "type": "integer" },
"max_price_usd": { "type": ["number", "null"] },
"channel": { "type": "string", "enum": ["website_chat", "messenger", "instagram_dm", "whatsapp"] }
},
"required": ["mode", "sku_code", "parent_id", "product_query", "color", "size", "quantity", "max_price_usd", "channel"],
"additionalProperties": false
}
}
},
{
"type": "function",
"function": {
"name": "substitute_sku_lookup",
"description": "Mandatory fallback when catalog_lookup returns available_qty < requested quantity. Returns up to 3 in-stock substitutes within +/-20% price.",
"strict": true,
"parameters": {
"type": "object",
"properties": {
"unavailable_sku": { "type": "string" },
"preserve_attribute": { "type": "string", "enum": ["size", "color", "bundle_function", "price_tier"] },
"max_results": { "type": "integer", "enum": [1, 2, 3] },
"allow_bundle_split": { "type": "boolean" }
},
"required": ["unavailable_sku", "preserve_attribute", "max_results", "allow_bundle_split"],
"additionalProperties": false
}
}
}
]
}
Resolving Virtual Bundles Without Overselling Components
Bundles and starter kits expose the biggest weakness in naive catalog lookups. Suppose a home-goods shop sells a Linen Sleep Bundle at $185.00 (saving $25.00 versus separate pieces) containing one Queen duvet cover (LIN-DUV-SND-Q), one Queen fitted sheet (LIN-SHT-SND-Q), and two standard pillowcases (LIN-PIL-SND-S). Storing a standalone bundle_stock = 12 counter in a spreadsheet breaks the moment single pillowcases sell on the storefront and drop pillowcase inventory to available = 1.
Per Shopify's product bundles architecture (checked 2026-11-27), fixed bundles group up to 30 component items whose sellable inventory must be calculated dynamically from underlying component stock rather than manually maintained static counts—and nested bundles inside bundles are unsupported. Your resolver should compute sellable bundle capacity at read time across fulfillable locations using the bottleneck component formula:
bundle_available = min(floor(max(0, component.available - component.safety_stock) / component.required_qty))
In our Linen Sleep Bundle example, if the duvet cover has 9 available units, the fitted sheet has 6 available units, and pillowcases have 3 available units (with 2 required per bundle and safety stock = 0), floor(3 / 2) = 1. Only 1 bundle can be sold right now—not 3, and not 6. If the customer asks for 2 bundles, the agent must report that exactly 1 complete bundle is ready to ship today, or offer to pair 1 complete bundle with an alternate pillowcase colorway via substitute_sku_lookup.
Deterministic Narrowing, Bundle Resolver & Prompt Guardrail Asset
Below is a production-ready resolver specification paired with the system prompt guardrail block that enforces two-step narrowing and prohibits dead-end out-of-stock responses:
# 1. DETERMINISTIC RESOLVER LOGIC (Backend Tool Handler)
def resolve_bundle_availability(components, location_id):
sellable_counts = []
bottleneck_sku = None
min_bundles = float("inf")
for comp in components:
row = inventory_db.get_level(sku=comp["sku"], location_id=location_id)
# Never use physical on_hand; subtract committed, reserved, and safety buffer
net_available = max(0, row["available"] - row["safety_stock"])
possible = net_available // comp["required_qty"]
if possible < min_bundles:
min_bundles = possible
bottleneck_sku = comp["sku"]
sellable_counts.append({"sku": comp["sku"], "possible": possible})
return {
"bundle_available_qty": 0 if min_bundles == float("inf") else int(min_bundles),
"bottleneck_sku": bottleneck_sku,
"component_breakdown": sellable_counts
}
# 2. SYSTEM PROMPT GUARDRAIL BLOCK (Agent Instructions)
"""
CATALOG & INVENTORY EXECUTION RULES:
1. NEVER quote a price, variant option, or stock status from memory or general knowledge.
Every product claim must come from a catalog_lookup or substitute_sku_lookup output in this thread.
2. TWO-STEP NARROWING:
- If the shopper names a product without all required options (e.g., missing size or color),
call catalog_lookup(mode='discover_parent'). Reply with the price and ONLY the in-stock options
so the shopper can pick in one tap/reply.
- Once all options are known, call catalog_lookup(mode='resolve_sku') before confirming availability.
3. NO OUT-OF-STOCK DEAD ENDS:
- Whenever catalog_lookup returns available_qty < requested quantity, you MUST immediately call
substitute_sku_lookup before replying to the customer.
- Present 2 to 3 verified in-stock alternatives (matching size first for apparel, or matching
color/function for home goods & bundles), showing exact USD price and current stock readiness.
- Never fabricate restock dates unless a confirmed incoming_eta field exists in the tool payload.
4. CHANNEL FORMATTING:
- On Messenger/Instagram DM, keep replies under 650 characters and limit product cards to at most
10 items per carousel payload. Ask one clear closing question to advance the order draft.
"""
Channel Constraints Across Website Chat, Messenger, and Instagram DM
Catalog lookup architecture cannot be decoupled from the messaging channel delivering the answer. On Website Chat, a shopper can comfortably read a structured comparison of three in-stock alternatives with clickable links. Inside Facebook Messenger or Instagram DM, a 280-word reply gets truncated behind a fold and kills reply momentum.
When formatting structured product cards on Meta channels, note that Meta's Messenger Product Template documentation (checked 2026-11-27) enforces a strict cap of 10 product elements per horizontal carousel message and pulls live title, image, and price fields directly from your Page-owned Meta catalog. Meanwhile, WhatsApp Business Messaging catalog standards (checked 2026-11-27) bind multi-product messages to registered Commerce Manager retailer SKU IDs. Sending 3 focused, pre-validated in-stock substitutes respects mobile screen real estate while keeping every SKU clickable and inventory-accurate.
Economics of Out-of-Stock Fallbacks: Dead Ends vs. Guided Substitutes
To evaluate the unit-economics impact, suppose a lean US direct-to-consumer store handles 2,000 chat-assisted product inquiries per month at a $68.00 average order value (AOV) and models a 22% partial-variant ambiguity or out-of-stock rate—440 blocked conversations per month (typically on core sizes like Medium/Large or seasonal colorways):
- Blunt out-of-stock dead end: Replying "Sorry, the Merino Crewneck in Olive Size M is currently sold out" ends buyer intent immediately. Under an illustrative 0%–5% manual recovery baseline (when shoppers must restart browsing on their own), that yields only 0 to 22 recovered orders.
- Automatic in-stock substitute recommendation: Triggering
substitute_sku_lookupwithpreserve_attribute: "size"and responding "Olive in Size M just sold out, but we have Charcoal ($98.00) and Heather Navy ($98.00) in Size M ready to ship today—plus the 2-pack Merino Bundle at $178.00. Want me to reserve Charcoal M for you?" turns a dead end into a single-reply decision. Under a modeled 18% substitute-conversion target across those 440 inquiries, the store recovers roughly 79 orders per month—about $5,372 in monthly gross merchandise value.
Even on bundles, allow_bundle_split: true recovers partial baskets. If a shopper wants a $185.00 Linen Sleep Bundle whose matching pillowcases are out of stock, offering the in-stock duvet cover + fitted sheet pair ($152.00) plus an in-stock contrast pillowcase set prevents losing the entire $150+ ticket.
How TrolyPage Implements Catalog Lookup and Where Custom Glue Is Still Needed
Not every SMB team wants to host and maintain custom OpenAI or Claude tool-calling middleware on AWS Lambda or Laravel workers. Platforms like TrolyPage package knowledge-grounded AI agents alongside built-in catalog, inventory, and order workflows in a unified inbox covering Facebook Messenger, Instagram DM, WhatsApp Cloud API, Telegram, Zalo, Website Chat, and email.
In TrolyPage, teams configure catalog lookup across three layers:
- Built-in AI Action Tools & Internal Catalog: TrolyPage provides native AI action tools for product lookup, order drafts, shipping fee calculation, and payment link or QR verification, paired with its internal catalog, order, and inventory records. Before going live, teams can verify variant narrowing and out-of-stock substitute behavior inside the built-in
evaluationpre-live test chat and enforce PII filtering via Data Safety rules. For step-by-step catalog grounding practices, see our guide on training AI chatbots on product catalogs and policies. - Trigger-Condition-Action Rules + Human Escalation: Rather than brittle flowcharts, TrolyPage combines AI instructions with deterministic trigger-condition-action automation rules and human
handoffcontrols that pause automated replies whenever a VIP request, custom bulk quote, or damaged-stock dispute requires a live teammate. - MCP Gateway & Webhooks for External Stacks: For engineering teams connecting external workflows or AI clients (Claude, ChatGPT, Cursor, VS Code), TrolyPage exposes a workspace MCP gateway (listing 291 tools across a unified server and 11 domain servers on its live MCP overview page, though legacy pricing copy still mentions 86 tools), alongside outbound/inbound trigger webhooks, Zapier Webhooks, and Google Sheets OAuth sync.
Honest Architectural Boundaries to Plan Around
To avoid mid-project surprises, evaluate these explicit TrolyPage boundaries before committing your architecture:
- No visual drag-and-drop chatbot flowchart builder: TrolyPage deliberately uses AI system instructions, knowledge grounding, and trigger-condition-action rules instead of node-and-arrow conversation trees. If your team insists on drawing rigid multi-screen visual trees manually, you will miss a canvas builder.
- No native two-way Shopify, WooCommerce, or BigCommerce order/refund sync: While you can install TrolyPage Website Chat on Shopify (as well as WooCommerce and BigCommerce) and manage products inside TrolyPage's built-in catalog, TrolyPage does not provide native two-way storefront admin refund or fulfillment widgets. Stores that treat Shopify as the single source of truth for live warehouse counts must synchronize inventory changes into TrolyPage via webhooks, Zapier, or scheduled sheet/API pipelines rather than expecting out-of-the-box bidirectional Shopify admin sync.
- No public developer REST API yet: Custom integrations rely on webhooks, Google Sheets sync, or the MCP gateway rather than a generally available public REST API.
- Support timezone vs. AI uptime: Automated AI catalog replies run 24/7, while live TrolyPage vendor staff support operates during Vietnam business hours (
UTC+7). - Pricing structure & trial limits: On TrolyPage pricing, the Free plan ($0.00/mo, 100 MAU, 50,000 AI tokens/month) is a one-time time-limited workspace trial—not a permanent free tier. Paid self-serve plans scale by monthly active customers, service connections, and AI token quotas: Lite at $8.00/mo (250 MAU, 4M tokens), Starter at $16.00/mo (500 MAU, 16M tokens), Pro at $32.00/mo (1,600 MAU, 40M tokens), and Scale at $104.00/mo (10,000 MAU, 200M tokens), with add-ons at $1.00/mo per extra seat and $4.00–$24.00 for extra AI token packs.
7-Point Production Rollout Checklist
Before routing live paid ad traffic into an AI catalog agent on Messenger, Instagram DM, or Website Chat, verify these seven engineering gates:
- Enforce strict schemas on every catalog tool: Set
additionalProperties: false, declare nullable union types for optional filters, and validate canonical option enums so the LLM cannot invent color or size names. - Separate
discover_parentfromresolve_sku: Never let the agent confirm availability until all variant options are resolved against a unique variant ID. - Query
available, neveron_hand: Subtract committed checkout holds and safety stock buffers before returning sellable quantities. - Calculate bundle stock from bottleneck components: Recompute virtual bundle availability on every read using
min(floor((available - safety_stock) / required_qty)). - Make
substitute_sku_lookupmandatory on zero stock: Block dead-end apologies at the prompt and tool-orchestration layer by automatically surfacing 2–3 in-stock alternatives preserving size or price tier. - Cap response density per channel: Limit Messenger/Instagram carousels to 10 items max (ideally 3 substitutes in chat) and keep replies scannable on mobile screens.
- Test edge cases in pre-live evaluation: Run 20 adversarial test prompts—misspelled colors, mixed bundle + single-SKU carts, quantity exceeding stock, and multi-warehouse splits—inside your staging sandbox or TrolyPage
evaluationchat before enabling live traffic.
Comments
Your comment will appear after review.
Sign in to commentNo comments to show.