Skip to main content
Some shops run their own e-commerce backend instead of Shopify, WooCommerce or Medusa. For these shops, Totebot can connect the agent directly to your shop API, so it can read live product details, add products to the cart and change quantities.
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

  1. Your site loads the Totebot widget as usual (see Web SDK).
  2. Your site calls window.totebot.setCart() with the visitor’s cart id and the cart fields your shop API needs.
  3. 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.
  4. If the agent creates a new cart, the widget tells your page, so your site can show the updated cart.

When to call setCart

Call window.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.
You can call it at any time, also before the widget has loaded. Only the most recent call is used.

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 a totebot: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.
The widget accepts 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.