Skip to main content
The @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

The package runs on Node 18 or later and has no dependencies. The browser entry @agent-cards/commerce-sdk/browser imports no Node module, so any build tool takes it.

Wire it up

agent.ts
The snippet builds one 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.