Keep the turn open
A streamed turn stays open after the reply while a store or a travel search is still out, for up to 60 seconds. The shopper’s next message ends the wait at once. A call that does not stream answers at the reply and waits for nothing.- SDK
- MCP
- API
The buy tool streams every turn by default and reads the late results for you. Nothing else to set.
Stop the dots at the reply
Once the reply is written, Agentcard says so, though the turn is still open. Stop your typing dots then, so the shopper reads the reply as finished.- SDK
- MCP
- API
Pass
onReplyDone to buyTool or buy.turn:chat.ts
hideDots stands for your own code. onReplyDone comes once a call, after the tool showed the whole reply through onText, or through onItem or onMessage with replyAsWritten: true. A turn with nothing still out hears none, and its call answers at once.Show the check for a better price
On a best-price ask, a quiet line under the reply tells the shopper that more stores are still being checked. Take the line away once the check is done.- SDK
- MCP
- API
Pass
onBetterPriceCheck:chat.ts
showQuietLine and hideQuietLine stand for your own code. checking carries text as Agentcard wrote it. done comes once, after checking, with found set to true when a better price was shown.Show a better price
A store that answers after a best-price reply, at least 5% and at least $1 below the price the reply led with, sends onebetter_price message. Show its text as one message and its product as a row of its own under it, with the “Best price” tag on that product and off the reply’s card.
A shopper who says yes, taps the card, or names the store gets that product in the cart. Agentcard keeps the message in the conversation, so your agent’s next turn hears it too.
- SDK
- MCP
- API
Pass
onBetterPrice:chat.ts
removeBetterRow and showBetterRow stand for your own code. card is a product card, as sendLink hands one, with bestPrice: true. leadProductId names the reply’s card that gives up the tag. product carries the same values one by one, with leadPriceCents, the price it beats.The same eventId again, with replaced: true, means a store found a lower price still: replace the message and the card in place. withdrawn: true means the product is gone, such as sold out: take the message and the row away, and give the tag back to leadProductId. A tap on the card sends card.productId as the shopper’s pick.Without onBetterPrice, the message goes where the turn’s messages go and the card to sendLink, once.Show more hotels or flights
A hotel or flight search can ask more than one source. When the slower one adds results after the reply, Agentcard sends onemore_found message, such as “I found 2 more hotels.”, with up to 12 of them for a row of their own. The reply’s cards keep their place and their numbers. A shopper who taps one, or names it, gets it in the cart.
- SDK
- MCP
- API
Pass
onMoreFound:chat.ts
removeRow and showRow stand for your own code. Each card in cards is a card as sendLink hands one, and a tap sends its productId as the pick. The same eventId again, with replaced: true, replaces the row in place. onFound’s more leaves the row’s cards out while the row shows.Without onMoreFound, the message goes where the turn’s messages go and each card to sendLink, once.Show a late store behind “show more”
A store that answers after the reply, with nothing below the price the reply led with, sends no message. Its products join the turn’s products behind “show more”, so a shopper who asks for more sees them first.- SDK
- MCP
- API
The late products reach
onFound’s more. The cards the reply showed stay as they were.Show each message once
A better price can reach your app twice: live in the stream, and as apurchase.message webhook with the same event id. Drop a webhook whose event id the stream already delivered. Agentcard sends no webhook copy when the stream wrote the message and your request sent stream_purchase_messages: true. A webhook still follows when the shopper left before the stream wrote it, when the call did not stream, or when the request sent late_results: 'hold'.
- SDK
- MCP
- API
Pass your buy tools’ client to the webhook handler, and it drops a message the stream already showed.
agentcard is the client your buy tools share, and postToChat stands for your own code:app/agentcard/webhooks/route.ts
listen and agentcard.updates drop it the same way. A message you read another way can be checked with agentcard.shownInStream(message.eventId).Answer at the reply instead
A texting app that cannot add a message after its reply asks Agentcard to end the turn at the reply. The stream then waits for nothing after the reply, and a better price found later reaches your webhook endpoint as apurchase.message.
- SDK
- MCP
- API
sms.ts
Show a row again later
A shopper who reloads the chat, or whose connection dropped, still sees the rows. Agentcard keeps each late message in the conversation, after the reply.- SDK
- MCP
- API
agentcard.conversation(conversationId) returns the reply in latest_reply.messages, with a better price’s text among them. The SDK does not read rows of more hotels or flights yet: read them from GET /buy/conversations/:id, as the API tab shows.