Skip to main content
A search for “a men’s linen shirt” asks several stores at once. Your chat can show each one the moment Agentcard starts on it, checking Gap, and change the line when the store answers: two shirts at Gap, nothing at 1-800-Flowers, Sephora too slow to wait for. The shopper sees work happening before the first product arrives. Store statuses reach your app once Agentcard turns them on for every company. Until then, onMerchantStatus hears no update and the answer’s search is null, so code written from this guide shows no store line and needs no change when they turn on.

Show each store as its status changes

Pass onMerchantStatus to the buy tool. The callback hears a store each time the store’s status changes: searching when Agentcard starts on it, then the status it ends with.
chat.ts
An update carries these fields: Key your line by merchant and replace it on each update: a store can change more than once in a turn, and a store searched twice reads searching again.

Read what each status means

A timed_out, failed or unavailable store says nothing about whether the store carries the product. Say so to the shopper in your own words, and never as “none at Sephora”.

Show a store you could not reach

Pass the stores the shopper named to merchantStatusLine, and show the line it gives:
chat.ts
A shopper who asked for a candle at Walmart while Agentcard could not reach Walmart reads still loading Walmart beside the products from the stores that did answer. A store the shopper did not name gets no line: it drops out, and the other stores fill the answer. For the whole turn at once, searchStatusLines(result.search ?? null, shopper.namedStores) gives every line. An app on an SDK version before 0.18.8 leaves an unavailable store out of search and never hears its update. To word the line yourself, read status and the store’s merchantName.

Read every store in the answer

The answer’s search holds every store the turn searched, in the order their searches started, with the same fields in snake case. final is true once no store is still being searched.
chat.ts
search is null for a turn that searched no store, such as a reply about the cart.

Follow one store

A chat that searched one store reads that store’s line with searchAt, which matches the store by its id, its domain, or its name:
store-line.ts

Call the API directly

A streamed POST /buy sends each change as a merchant event. The following events come from a run of “a men’s linen shirt”, with the milliseconds since the call started:
Each event also carries conversation_id and search_id. The envelope carries the whole list as search, with search_id, final, elapsed_ms, merchants and index. index holds how many products Agentcard’s own product index answered and how long its read took, or null when the turn read none.

Check it in the sandbox

Once store statuses are on for your company:
  1. Send “a men’s linen shirt” to your agent as a test shopper.
  2. Watch a line appear for each store, searching first.
  3. See each line change as its store answers, and the answer’s search list the same stores with final: true.