Host callbacks
Callback buttons let a card trigger code on the host page: add to cart, open a size picker, start checkout.
1. Add the button to a card template
Section titled “1. Add the button to a card template”In Appearance → Components (plans with custom card designs), for example in the product card:
<div class="my-card"> <img src="{{imageUrl}}" alt="{{title}}"> <p>{{title}} · {{priceFormatted}}</p> <button data-action="callback" data-name="addToCart" data-product-id="{{id}}" data-payload='{"quantity":1}'>Add to cart</button></div>data-name must match ^[a-zA-Z][\w-]{0,63}$. data-payload is optional JSON of at most 1 KB.
2. Handle the event
Section titled “2. Handle the event”window.Helpvane.on('action', async (event) => { if (event.action !== 'addToCart') return; await cart.add(event.product.externalId, event.payload.quantity); window.Helpvane.close();});or, independent of load order:
window.addEventListener('helpvane:action', (event) => { /* event.detail */ });The event
Section titled “The event”{ action: 'addToCart', component: { kind: 'productCard', toolCallId: '…' }, payload?: { quantity: 1 }, product?: { id, externalId, title, url, price, salePrice, currency, availability, … }, forwardTo?: string}product comes from the stored card data, matched by data-product-id, so the id and price are the real values, not whatever the page’s HTML says. The event object is frozen.
Add to cart from the product carousel
Section titled “Add to cart from the product carousel”Product recommendations arrive as a swipeable row of cards, each with a round bag button over the image. You do not need a card template for it: give the page a cart hook and the button adds to your cart; without one it opens the product page instead.
Either serve an addToCart client tool (no setup on the tenant is needed for this button; the chat runs the handler directly, without a model round trip):
window.Helpvane.registerTool('addToCart', async (input) => { // input: { productId, externalId, title, url, quantity } await cart.add(input.externalId, input.quantity); return { ok: true };});or listen to the addToCart event (also helpvane:addToCart on window), or pass onAddToCart to mount() / the React component:
window.Helpvane.on('addToCart', async ({ product, quantity }) => { await cart.add(product.externalId, quantity);});The button shows a check mark when your handler returns (or resolves) and a red state when it throws. product is the stored card data, as in action events. Register the hook before the shopper opens the chat so the first row already shows the bag button.
Under each answer the chat shows thumbs up / down. Ratings are saved on the conversation (visible in Admin → Conversations) and also reach you as the feedback event ({ messageId, rating, text }) or onFeedback.
Security
Section titled “Security”The model cannot create callback buttons; they are stripped from everything it authors. Only templates saved by the store produce them. Still, validate in your handler as you would any click, because a visitor controls their own browser.