Contents
Event categories
The following tables list all supported events, grouped by category.- Lifecycle events
- Message events
- Conversation events
- View events
- Customization events
- Feedback events
- Security events
Lifecycle events
Lifecycle events track the initialization and readiness state of the chat widget.| Event name | Description |
|---|---|
chat:ready | Triggered when the web chat is fully loaded and ready to receive user input. |
Message events
Message events allow you to intercept and modify messages as they flow between the user and the agent.| Event name | Description |
|---|---|
pre:send | Triggered before the web chat sends a message to the agent. |
send | Triggered after the web chat sends a message to the agent. |
pre:stream:delta | Triggered before each streaming delta chunk is processed and rendered in the chat. |
pre:receive | Triggered before the web chat receives a response from the agent. |
receive | Triggered after the web chat receives a response from the agent. |
Conversation events
Conversation events track conversation lifecycle operations such as restarts and thread loading.| Event name | Description |
|---|---|
pre:restartConversation | Triggered before the conversation restarts. |
restartConversation | Triggered after the conversation restarts, before a new session begins. |
pre:threadLoaded | Triggered before a conversation thread is loaded from history. |
View events
View events track changes to the chat widget’s visual state and layout.| Event name | Description |
|---|---|
view:pre:change | Triggered before the view state changes. |
view:change | Triggered after the view state changes. |
view:properties:pre:change | Triggered before view properties (like maximized state) change. |
view:properties:change | Triggered after view properties (like maximized state) change. |
Customization events
Customization events enable you to handle custom response types and render custom UI elements.| Event name | Description |
|---|---|
userDefinedResponse | Triggered when a response contains an unrecognized or user_defined response type. |
customEvent | Triggered for custom events like button clicks. |
Feedback events
Feedback events track user interactions with feedback controls on messages. For a complete guide on implementing thumbs-up and thumbs-down feedback, see Thumbs-up and thumbs-down feedback.| Event name | Description |
|---|---|
feedback | Triggered when the user interacts with feedback controls on a message. |
Security events
Security events help manage authentication and token lifecycle.| Event name | Description |
|---|---|
authTokenNeeded | Triggered when the JWT authentication token expires and needs to be refreshed. |
Event details
The following sections provide detailed information about each event, including event properties, usage examples, and common patterns.chat:readypre:sendsendpre:stream:deltapre:receivereceivepre:restartConversationrestartConversationpre:threadLoadedview:pre:changeview:changeview:properties:pre:changeview:properties:changeuserDefinedResponsecustomEventfeedbackauthTokenNeeded
chat:ready
Triggered when the web chat is fully loaded and ready to receive user input. This is the ideal place to perform initialization tasks such as displaying a welcome message, configuring custom header items, or setting up other UI components. Event Properties| Property | Type | Description |
|---|---|---|
| type | string | Always 'chat:ready'. |
pre:send
Triggered before the web chat sends a message to the agent. Use this event to inspect or modify the message content before it is dispatched to the backend. Event Properties| Property | Type | Description |
|---|---|---|
| type | string | Always 'pre:send'. |
| message | object | The message payload to send to the agent. Contains the user’s input and metadata. |
| message.message | object | The message object containing the content. |
| message.message.content | string | The text content of the user’s message. |
send
Triggered after the web chat sends a message to the agent. This event is useful for analytics, logging, or triggering side effects after a message is dispatched. Event Properties| Property | Type | Description |
|---|---|---|
| type | string | Always 'send'. |
| message | object | The message payload that was sent to the agent. |
pre:stream:delta
Triggered before each streaming delta chunk is processed and rendered in the chat. This event is fired during streaming responses when the agent sends partial content incrementally. Use this event to inspect, modify, or suppress streaming content before it appears in the chat UI. Event Properties| Property | Type | Description |
|---|---|---|
| type | string | Always 'pre:stream:delta'. |
| messageId | string | Unique identifier for the message being streamed. |
| threadId | string | Unique identifier for the conversation thread. |
| runId | string | Unique identifier for the current run. |
| delta | object | The streaming delta chunk containing partial response content. |
| delta.role | string | Role of the message sender, for example, 'assistant'. |
| delta.content | array | Array of content items in the delta chunk. |
| delta.content[].id | string | Unique identifier for the content item. |
| delta.content[].response_type | string | Type of the response item, for example, 'text'. |
| delta.content[].text | string | Text content of the delta item. |
- Content filtering: Remove or redact sensitive information in real-time as it streams.
- Text transformation: Apply formatting or transformations to streaming content.
- Suppress streaming: Disable character-by-character streaming and show only the final message.
- Translation workflows: Suppress deltas and translate the complete message in
pre:receive. - Progress tracking: Monitor streaming progress and display custom loading indicators.
- Analytics: Track streaming performance metrics like chunk size and frequency.
- This event is only triggered when you use streaming responses. Non-streaming responses do not fire this event.
- The
delta.contentarray contains only the incremental content for the current chunk, not the complete message. - To suppress delta rendering, set
event.delta.content = []. The complete message is still rendered withpre:receiveandreceiveevents. - The
messageobject accumulates all previous deltas and represents the message state so far. - Multiple handlers can be registered and run in registration order.
pre:receive
Triggered before the web chat receives a response from the agent. Use this event to inspect or modify the agent’s response before it is rendered in the UI. Event Properties| Property | Type | Description |
|---|---|---|
| type | string | Always 'pre:receive'. |
| message | object | The agent’s response payload. |
| message.content | array | Array of content items in the response. |
| message.content[].text | string | Text content of the response item. |
| message.content[].type | string | Type of the response item (e.g., 'text', 'user_defined'). |
receive
Triggered after the web chat receives a response from the agent and the response is rendered in the UI. This event is useful for post-processing, analytics, or triggering follow-up actions. Event Properties| Property | Type | Description |
|---|---|---|
| type | string | Always 'receive'. |
| message | object | The agent’s response that was rendered. |
pre:restartConversation
Triggered before the conversation restarts. This event is useful for alerting the user that the chat will reset, allowing them to complete any ongoing actions or save state before the restart occurs. Event Properties| Property | Type | Description |
|---|---|---|
| type | string | Always 'pre:restartConversation'. |
restartConversation
Triggered after the conversation restarts, before a new session begins. This event is useful for displaying specific UI elements, sending an initial message, or resetting application state when a new session starts. Event Properties| Property | Type | Description |
|---|---|---|
| type | string | Always 'restartConversation'. |
pre:threadLoaded
Triggered before a conversation thread is loaded from history. This event allows you to inspect or modify the messages before they are displayed in the chat UI. Event Properties| Property | Type | Description |
|---|---|---|
| type | string | Always 'pre:threadLoaded'. |
| messages | array | Array of messages that will be loaded into the chat. |
| messages[].id | string | Unique identifier for the message. |
| messages[].sender | string | Sender type ('user' or 'response'). |
| messages[].content | array | Array of content items in the message. |
| messages[].message_state | object | State information for the message. |
view:pre:change
Triggered before the view state changes (e.g., showing or hiding the launcher, or main window). Use this event to react to or preprocess the upcoming view transition. Event Properties| Property | Type | Description |
|---|---|---|
| type | string | Always 'view:pre:change'. |
| reason | string | The reason for the view change (e.g., 'launcherClicked', 'chatLoaded', 'calledChangeView', 'mainWindowMinimized'). |
| oldViewState | object | The previous view state. |
| oldViewState.launcher | boolean | Whether the launcher was visible. |
| oldViewState.mainWindow | boolean | Whether the main window was visible. |
| newViewState | object | The new view state that will be applied. Can be modified by the handler. |
| newViewState.launcher | boolean | Whether the launcher will be visible. |
| newViewState.mainWindow | boolean | Whether the main window will be visible. |
-
launcherClicked
User clicked the launcher button. -
chatLoaded
Chat loaded for the first time. -
calledChangeView
View changed programmatically through thechangeView()method. -
mainWindowMinimized
User clicked the minimize button.
view:change
Triggered after the view state changes. This event enables post-change logic such as analytics, UI updates, or side effects. Event Properties| Property | Type | Description |
|---|---|---|
| type | string | Always 'view:change'. |
| reason | string | The reason for the view change. |
| oldViewState | object | The previous view state. |
| oldViewState.launcher | boolean | Whether the launcher was visible. |
| oldViewState.mainWindow | boolean | Whether the main window was visible. |
| newViewState | object | The new view state. |
| newViewState.launcher | boolean | Whether the launcher is now visible. |
| newViewState.mainWindow | boolean | Whether the main window is now visible. |
view:properties:pre:change
Triggered before one or more properties of a view are changed (e.g., maximized state). Use this event to react before the property change takes effect. Event Properties| Property | Type | Description |
|---|---|---|
| type | string | Always 'view:properties:pre:change'. |
| newViewState | object | Object containing only the properties that are about to change. |
| newViewState.maximized | boolean | Whether the view will be maximized. |
view:properties:change
Triggered after one or more properties of a view have changed. This event enables post-change logic for property updates. Event Properties| Property | Type | Description |
|---|---|---|
| type | string | Always 'view:properties:change'. |
| newViewState | object | Object containing only the properties that changed. |
| newViewState.maximized | boolean | Whether the view is now maximized. |
userDefinedResponse
Triggered when a response contains an unrecognized oruser_defined response type. Use this event to render custom UI elements for specialized content types that are not natively supported by the chat widget.
Event Properties
| Property | Type | Description |
|---|---|---|
| type | string | Always 'userDefinedResponse'. |
| contentItem | object | The individual message item with the user_defined response type. |
| contentItem.text | string | Text content of the item (if any). |
| message | object | The complete message containing the user-defined response item. |
| hostElement | HTMLElement | The DOM element where you can insert custom content. |
customEvent
Triggered for custom events such as button clicks within the chat. This event provides a generic pattern for handling custom interactions. Event Properties| Property | Type | Description |
|---|---|---|
| type | string | Always 'customEvent'. |
| customEventName | string | The name of the custom event (e.g., 'buttonItemClicked'). |
| contentItem | object | The message item that triggered the event. |
| message | object | The complete message containing the item. |
buttonItemClicked
Triggered when a button in a response is clicked.
feedback
Triggered when the user interacts with feedback controls on a message. This includes both the feedback buttons (thumbs up and down) and the details popup where the user can submit additional information. Event Properties| Property | Type | Description |
|---|---|---|
| type | string | Always 'feedback'. |
| messageItem | object | The message content item for which feedback was provided. |
| message | object | The complete message for which feedback was provided. |
| isPositive | boolean | Whether the feedback is positive (true) or negative (false). |
| interactionType | string | The type of interaction ('button' or 'details'). |
| text | string | The text entered by the user (when submitting feedback details). |
| categories | array | Array of category strings selected by the user (when submitting feedback details). |
-
button
User clicked thumbs up or down button. -
details
User submitted detailed feedback.
authTokenNeeded
Triggered when the JWT authentication token expires and needs to be refreshed. Use this event to provide a new token to maintain secure communication with the backend. Event Properties| Property | Type | Description |
|---|---|---|
| type | string | Always 'authTokenNeeded'. |
| authToken | string | null | The expired token, or null if unavailable. You must set this property to the new token. |
Complete example
The following example demonstrates how to configure multiple events in the embedded web chat:Best practices
Event handler patterns
-
Use
once()for one-time operations
If you only need to handle an event once, useinstance.once()instead ofinstance.on()to automatically remove the handler after execution. -
Clean up event handlers
Useinstance.off()to remove event handlers when they’re no longer needed to prevent memory leaks. -
Handle errors gracefully
Wrap event handler logic in try-catch blocks to prevent errors from breaking the chat experience. -
Avoid blocking operations
Keep event handlers lightweight and non-blocking. Use async operations for heavy processing.
Modifying event data
-
pre:send
Modify
event.message.message.contentto change the user’s message before sending. -
pre:receive
Modify
event.message.contentto change the agent’s response before rendering. -
pre:stream:delta
Modify
event.delta.textto transform streaming content in real-time before it’s rendered. -
pre:threadLoaded
Modify
event.messagesto customize historical messages before display. -
view:pre:change
Modify
event.newViewStateto control the upcoming view state.
Common use cases
-
Analytics tracking
Use
send,receive, andview:changeevents to track user interactions. -
Custom rendering
Use
userDefinedResponseto render custom UI for specialized content types. -
Token management
Use
authTokenNeededto implement automatic token refresh. -
Message transformation
Use
pre:sendandpre:receiveto transform messages in transit. -
Streaming content processing
Use
pre:stream:deltato filter, transform, or monitor streaming responses in real-time. -
Feedback collection
Use
feedbackevent to capture and process user feedback.

