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
PassonMerchantStatus 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
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 or failed 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”.
Read every store in the answer
The answer’ssearch 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 withsearchAt, which matches the store by its id, its domain, or its name:
store-line.ts
Call the API directly
A streamedPOST /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:
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:- Send “a men’s linen shirt” to your agent as a test shopper.
- Watch a line appear for each store,
searchingfirst. - See each line change as its store answers, and the answer’s
searchlist the same stores withfinal: true.