Custom integrations are set up by Totebot support. They are not self-service. Contact support with your API documentation to get started. Once your integration is live, the only thing your site needs to do is tell the widget which cart the visitor has, as described below.
How it works
- Your site loads the Totebot widget as usual (see Web SDK).
- Your site calls
window.totebot.setCart()with the visitor’s cart id and the cart fields your shop API needs. - When the visitor asks the agent to add a product or change their cart, Totebot calls your shop API with that cart id and those fields.
- If the agent creates a new cart, the widget tells your page, so your site can show the updated cart.
When to call setCart
Callwindow.totebot.setCart():
- On page load, once you know the visitor’s cart.
- Every time the cart changes on your site, for example after the visitor adds a product with your own buttons.
- After checkout or logout, with
null, so the agent stops using the old cart.
Examples
Page load
Cart change
Checkout or logout
When the agent changes the cart
When the agent creates a cart for the visitor, the widget fires atotebot:cart-updated event on window. Use it to refresh your mini-cart, then call setCart again with the new cart:
What to put in metadata
metadata is for the cart fields your shop API needs to handle the cart, such as a store id, a price list or a sales channel.
- Send only the fields your integration needs. Totebot support agrees the list with you, and any other field is dropped.
- Never send secrets: no API keys, tokens or passwords. Your API credentials are stored encrypted on our side and are never sent from the browser.
- Never send personal data such as names, emails, phone numbers or addresses. To tell the agent who the visitor is, use
identifyUser. - Keep it small. The cart id plus metadata may be up to 4 KB.
setCart only from your own site, so make sure your shop’s domain is listed under the widget’s allowed domains.
The agent never sees these values in its instructions. They are only forwarded to your shop API.
setCart and identifyUser
identifyUser tells the widget who the visitor is. setCart tells it what is in their cart. Keep cart fields out of identifyUser, and keep personal data out of setCart.
What support needs from you
To build your integration, Totebot support needs:- API documentation for the product details, create cart and update cart endpoints.
- How the API authenticates (API key, bearer token, basic auth or signed requests).
- Test credentials and a test store or sandbox.
- The list of cart fields your site will send in
metadata.