@agent-cards/commerce-sdk package gives your agent a buy tool that searches stores, builds a cart, and places the order once the shopper approves it. The package also hands your server a message, ready to post into the shopper’s chat, for each moment the shopper should hear about, such as a saved card or a placed order.
Install
@agent-cards/commerce-sdk/browser imports no Node module, so any build tool takes it.
Wire it up
agent.ts
AgentcardClient, one buy tool for the shopper user-42, and one turn for the shopper’s message. Pass turn to your model as its tool. The Quickstart page walks through each framework.
When a shopper writes to your agent in several chats at once, such as group chats, build one tool per shopper and chat, and pass your own id for the chat as threadId. Each message about that chat’s purchase carries the chat as threadId, so post it into that chat. Keep a purchase per chat shows how.
Exports
Every name below comes from@agent-cards/commerce-sdk, except the browser entry.
Client
Buy tool
Turn
Listen
Webhooks
Messages and steps
Browser entry
The browser entry also re-exports the action-link helpers.
Guides
Each guide shows what the shopper sees, the code that implements it, and how to check it in the sandbox.- Quickstart
- Showing products and carting the one the shopper picks
- Showing stores and their menus
- Sending each link: approval, Vault and store sign-in
- Adding a card for a new shopper
- Approving a purchase
- Signing in to a store’s account
- Taking the next step once the shopper finishes outside the chat
- Showing the cart
- Bring back a saved cart
- Answering each shopper message in its own turn
- Acknowledging the shopper: a reaction or a short text