Overview
The AI Chat SDK provides a comprehensive event system that notifies your application about user interactions and UI state changes. Events enable you to track user behavior, trigger analytics, and respond to interactions across the chat panel, badge, and inline input.Registering event listeners
Pass event listeners toinitializeAiChatSdk as the third parameter:
Event structure
All events follow this structure:- type: The event type (see available events below)
- data: Event-specific data
- chatSessionId: Unique identifier for the current chat session (present in all events)
Badge events
Events emitted by the floating badge entry point.BADGE_SHOWN
Emitted when the badge becomes visible. Event type:AiChatSdkEventType.BADGE_SHOWN
Payload:
BADGE_CLICKED
Emitted when the user clicks the badge. Event type:AiChatSdkEventType.BADGE_CLICKED
Payload:
BADGE_CLOSED
Emitted when the badge is closed or hidden. Event type:AiChatSdkEventType.BADGE_CLOSED
Payload:
BADGE_PROMPT_CLICKED
Emitted when the user clicks a prompt on the badge. Event type:AiChatSdkEventType.BADGE_PROMPT_CLICKED
Payload:
Inline events
Events emitted by the inline input entry point.INLINE_SHOWN
Emitted when the inline input becomes visible. Event type:AiChatSdkEventType.INLINE_SHOWN
Payload:
INLINE_CLICKED
Emitted when the user clicks the inline input. Event type:AiChatSdkEventType.INLINE_CLICKED
Payload:
INLINE_PROMPT_CLICKED
Emitted when the user clicks a prompt in the inline input. Event type:AiChatSdkEventType.INLINE_PROMPT_CLICKED
Payload:
Chat events
Events emitted by the chat panel.CHAT_SHOWN
Emitted when the chat panel becomes visible. Event type:AiChatSdkEventType.CHAT_SHOWN
Payload:
CHAT_CLOSED
Emitted when the user closes the chat panel. Event type:AiChatSdkEventType.CHAT_CLOSED
Payload:
CHAT_MESSAGE_SENT
Emitted when the user sends a message in the chat. Event type:AiChatSdkEventType.CHAT_MESSAGE_SENT
Payload:
For privacy reasons, the message content is not included in the event payload. Use this event to track engagement metrics like message frequency.
CHAT_PROMPTS_SHOWN
Emitted when suggested prompts are displayed to the user. Event type:AiChatSdkEventType.CHAT_PROMPTS_SHOWN
Payload:
CHAT_PROMPT_CLICKED
Emitted when a user clicks a suggested prompt. Event type:AiChatSdkEventType.CHAT_PROMPT_CLICKED
Payload:
CHAT_LINK_CLICKED
Emitted when a user clicks a link within the chat interface. Event type:AiChatSdkEventType.CHAT_LINK_CLICKED
Payload:
CHAT_ERROR_SHOWN
Emitted when an error is displayed to the user in the chat interface. Event type:AiChatSdkEventType.CHAT_ERROR_SHOWN
Payload:
CHAT_TOP_MERCHANTS_SHOWN
Emitted when a list of top merchants is displayed in the chat. Event type:AiChatSdkEventType.CHAT_TOP_MERCHANTS_SHOWN
Payload:
CHAT_TOP_MERCHANTS_CLICKED
Emitted when a user clicks on a merchant in the top merchants list. Event type:AiChatSdkEventType.CHAT_TOP_MERCHANTS_CLICKED
Payload:
CHAT_PRODUCTS_SHOWN
Emitted when products are displayed in the chat. Event type:AiChatSdkEventType.CHAT_PRODUCTS_SHOWN
Payload:
CHAT_PRODUCTS_CLICKED
Emitted when a user clicks on a product. Event type:AiChatSdkEventType.CHAT_PRODUCTS_CLICKED
Payload:
CHAT_PRODUCTS_PAGE_NEXT_CLICKED
Emitted when the user clicks to view the next page of products. Event type:AiChatSdkEventType.CHAT_PRODUCTS_PAGE_NEXT_CLICKED
Payload:
CHAT_PRODUCTS_PAGE_PREVIOUS_CLICKED
Emitted when the user clicks to view the previous page of products. Event type:AiChatSdkEventType.CHAT_PRODUCTS_PAGE_PREVIOUS_CLICKED
Payload:
Event types reference
All available event types:Event flow examples
Badge to chat flow
Product browsing flow
Analytics integration example
Here’s a complete example of integrating SDK events with an analytics service:Debugging events
Enable debug mode to see all events logged to the console:Best practices
1. Track meaningful metrics
Focus on events that provide business value:- Entry point engagement:
BADGE_SHOWN→BADGE_CLICKED→CHAT_SHOWN - Conversion funnel:
CHAT_PROMPTS_SHOWN→CHAT_PROMPT_CLICKED→CHAT_PRODUCTS_CLICKED - Session duration: Time between
CHAT_SHOWNandCHAT_CLOSED - Error monitoring:
CHAT_ERROR_SHOWNfrequency

