Customisation

Script Tag Embed

Full reference for the Bounds widget script tag. The minimal one-liner gets you a working widget; the attributes below let you customise its behaviour and appearance without touching any JavaScript.

Minimal embed

<script
  src="https://cdn.bounds.ai/widget.js"
  data-agent-id="agt_your_key_here"
  defer
></script>

All attributes

AttributeRequiredDescription
data-agent-idYesYour agent's public key (agt_ prefix). Safe to expose in HTML.
data-session-tokenNoA signed session token from your server. Enables user-scoped actions. Omit for anonymous sessions.
data-placeholderNoPlaceholder text in the message input. Defaults to the value set in agent settings.
data-primary-colorNoHex colour for the widget launcher button and accent elements. Example: #0f766e. Overrides the colour set in agent settings.
data-openNoSet to true to start the widget in the open state on page load.

JavaScript API

After the script loads, window.Bounds exposes a small API:

MethodDescription
window.Bounds.open()Programmatically open the chat panel.
window.Bounds.close()Programmatically close the chat panel.
window.Bounds.reset()End the current session and clear local state. Call before a user logs out to prevent session bleed between accounts.

DOM events

The widget dispatches custom events on window so you can integrate with your own analytics or state management:

EventFires when
bounds:openUser opens the chat panel.
bounds:closeUser closes the chat panel.
bounds:escalateUser requests to speak to a human. Event detail includes the session ID.
bounds:messageA message is sent or received. Event detail includes role and content.
window.addEventListener('bounds:escalate', (e) => {
  analytics.track('support_escalated', { sessionId: e.detail.sessionId });
});