window.chatbase.addEventListener
and window.chatbase.removeEventListener
, you can listen for and handle specific events to create interactive and dynamic user experiences.
This guide explains how to initialize Chatbase, register event listeners, and handle event payloads.
addEventListener
and removeEventListener
methods are available.
eventName
parameter must be one of the following enum values:
Event Name | Description | Payload |
---|---|---|
tool-call | Triggered when a tool is called. | { name, type, args, toolCallId } |
tool-result | Triggered when a tool returns a result. | { name, type, result, toolCallId } |
user-message | Triggered when a user sends a message. | { content } |
assistant-message | Triggered when the assistant sends a message. | { content } |
eventName
(enum) — Must be one of the event names listed in Available Event Types.callback
(function) — Function to be called when the event is fired. The event payload is passed as an argument.eventName
(enum) — Must be one of the event names listed in Available Event Types.callback
(function) — The exact callback function used when adding the event listener.tool-call
tool-result
user-message
assistant-message
removeEventListener
matches the one used in addEventListener
.