KODA.AI Docs

KODA.AI Docs

  • Web JS SDK

›

  • Quick Start
  • Config

    • User Profile
    • Locales
    • Advanced Configuration
  • Browser Compatibility
  • SDK Methods
  • Analytics
  • CSS Properties
  • Data Processed by KODA Widget

Analytics

The SDK broadcasts events that will allow you to integrate a web widget with an external analytics tool e.g. Google Analytics

Example

<script>
    window.initKBWebSDK = function (SDK) {
        const bot = SDK.initKBChatbot({
            "token": "TOKEN"
        });
        
        // subscribe to all events
        SDK.on('*', function(event) {
            console.log(event.type);
            console.log(event.properties)
        });

        // subscribe only for a specific event
        SDK.on('web.chatbot.load', function(properties) {
            console.log(properties)
        });
    }
</script>

Callback signature

  • SDK.on('web.chatbot.chat.show', function(properties) { ... }) — callback receives the event properties object directly.
  • SDK.on('*', function(event) { ... }) — callback receives { type, properties }.

Most events include user_locale when the widget locale is set.

Custom Stat Events

You can subscribe to handle stat events set in the dashboard. E.g. when You add action:

Stat Event Action

Subscribe using the event name from the dashboard, prefixed with web.chatbot.chat.custom.:

// event name in dashboard: "Lead Email"
SDK.on('web.chatbot.chat.custom.Lead Email', function(properties) {
    console.log(properties); // {email: "", origin: ""}
});

// event name in dashboard: "RefreshSession"
SDK.on('web.chatbot.chat.custom.RefreshSession', function(properties) {
    console.log(properties);
});

System Events

Widget (SDK layer)

Events emitted by the SDK shell (chat bubble, promo message, mask).

EventPropertiesDescription
web.chatbot.load
  • user_locale
Widget initialized
web.chatbot.button.show
  • user_locale
Chat bubble shown
web.chatbot.chatbotIcon.click
  • user_locale
User clicked the chat bubble (open/close)
web.chatbot.mask.click
  • user_locale
User clicked the background mask
web.chatbot.promoMessage.show
  • user_locale
Promo message shown
web.chatbot.promoMessage.hide
  • user_locale
Promo message hidden
web.chatbot.promoMessage.clickOpen
  • user_locale
User clicked open on promo message
web.chatbot.promoMessage.clickClose
  • user_locale
User clicked close on promo message
web.chatbot.chat.show
  • user_locale
Chat window opened
web.chatbot.chat.hide
  • user_locale
Chat window closed

Chat interactions (widget layer)

Events emitted from inside the chat iframe (buttons, input, menu).

EventPropertiesDescription
web.chatbot.chat.button.click
  • user_locale
  • title (block links only)
User clicked a button inside the chat (postback button, carousel button, or inline block link in message content)
web.chatbot.chat.quickReply.click
  • user_locale
User clicked a quick reply
web.chatbot.chat.persistentMenu.clickIcon
  • user_locale
User clicked the hamburger menu icon (requires persistent_menu enabled)
web.chatbot.chat.persistentMenu.clickItem
  • user_locale
User clicked a persistent menu item
web.chatbot.chat.input-active
  • user_locale
User focused the message input
web.chatbot.chat.input-inactive
  • user_locale
User blurred the message input
web.chatbot.chat.userTyping
  • user_locale
  • text
User is typing in the message input (debounced)
web.chatbot.chat.clickLink
  • user_locale
  • url
User clicked a web_url link in the chat
web.chatbot.chat.clickCustomIcon
  • user_locale
  • callback
User clicked a custom icon in the chat footer
web.chatbot.chat.inquiry.click
  • user_locale
Discrete interaction with a survey form: rating selection, submit, closing the end-session or dislike feedback modal. Does not fire while typing in text fields — use inquiry.typing instead.
web.chatbot.chat.inquiry.typing
  • user_locale
  • text
User is typing in a survey form text field (e.g. “Why?” comment after rating). Emitted on the first keystroke, then debounced (300 ms) while typing continues.
web.chatbot.chat.likeDislike.click
  • user_locale
User clicked like or dislike on a message (including removing a rating)

Survey forms (inquiry.*)

Survey forms share the same events regardless of where they appear:

ContextWhen it shows
Conversation rating blockInline form at the end of a conversation flow
End-session modalWhen the user ends the chat and an exit survey is configured
Dislike feedback modalAfter clicking dislike on a message (when a feedback form is configured)

Use both events to detect activity during a survey (e.g. reset an inactivity timer):

SDK.on('web.chatbot.chat.inquiry.click', function (properties) {
    // rating selected, form submitted, modal closed
});

SDK.on('web.chatbot.chat.inquiry.typing', function (properties) {
    // user typing in a comment / text field
    // properties.text — current field value
});

Messages

EventPropertiesDescription
web.chatbot.chat.message.user
  • user_locale
  • who
  • block
  • meta (optional)
User sent a text message (emitted after bot response). Payload: { who: "user", block: { type: "message", text }, meta }
web.chatbot.chat.message.bot
  • user_locale
  • text
  • file_url
Chatbot sent a message
web.chatbot.chat.message.moderator
  • user_locale
  • text
  • file_url
Moderator sent a message

Note: web.chatbot.chat.message.user is not emitted on button clicks inside the chat. Use web.chatbot.chat.button.click or web.chatbot.chat.quickReply.click instead.

Tracking user activity

To detect any user interaction with the bot (e.g. reset an inactivity timer), subscribe to all events and filter:

var interactionEvents = [
    'web.chatbot.chatbotIcon.click',
    'web.chatbot.chat.button.click',
    'web.chatbot.chat.quickReply.click',
    'web.chatbot.chat.persistentMenu.clickIcon',
    'web.chatbot.chat.persistentMenu.clickItem',
    'web.chatbot.chat.message.user',
    'web.chatbot.chat.userTyping',
    'web.chatbot.chat.inquiry.typing',
    'web.chatbot.chat.input-active',
    'web.chatbot.chat.clickLink',
    'web.chatbot.chat.inquiry.click',
    'web.chatbot.chat.likeDislike.click'
];

SDK.on('*', function(event) {
    if (interactionEvents.indexOf(event.type) !== -1) {
        // user interacted with the bot
    }
});
← SDK MethodsCSS Properties →
  • Example
  • Callback signature
  • Custom Stat Events
  • System Events
    • Widget (SDK layer)
    • Chat interactions (widget layer)
    • Messages
    • Tracking user activity
Copyright © 2026 KODA sp. z o.o . Questions? Sent message to developers@koda.ai