Actions & automation
Website actions
Actions that run in the visitor's browser on your own site — add to cart, apply a coupon, open a page, read the cart.
+ Website action (on Build → Actions) creates an action that runs on your own website, in the visitor's browser. Register a handler on your page after the chat script:
AnytimeReply.onAction("add_to_cart", async (args) => {
await cart.add(args.product_id, args.quantity);
return { ok: true, cart_count: cart.count() };
});You can also pass handlers before the script loads:
window.AnytimeReplySettings = {
actions: {
apply_coupon: async ({ code }) => ({ ok: await shop.applyCoupon(code) }),
},
};How it runs
- The agent collects the inputs you defined.
- The safety rules apply (verified customers, confirmation, procedures).
- Your handler runs on the page and returns a result (an object). Return nothing and
{ ok: true }is sent; a thrown error is sent as{ ok: false, error }. - The agent answers with what your handler returned.
If the page has no handler for that name, the agent is told This page has no handler for …. Handlers must answer within 15 seconds.
Website actions run on pages that load the chat bubble script (widget.js) — not on the hosted help page, WhatsApp or other channels. In the Playground they aren't run; the agent gets a test result instead.
See the full JavaScript API.