{"id":17998,"date":"2017-08-08T16:26:20","date_gmt":"2017-08-08T16:26:20","guid":{"rendered":"http:\/\/developer.kore.ai\/v9-1\/?post_type=docs&#038;p=11750"},"modified":"2021-03-17T10:40:02","modified_gmt":"2021-03-17T10:40:02","slug":"sdk-events","status":"publish","type":"post","link":"https:\/\/developer.kore.ai\/v9-1\/docs\/bots\/sdks\/sdk-events\/","title":{"rendered":"Events for the BotKit SDK"},"content":{"rendered":"<section class=\"l-section wpb_row height_auto\"><div class=\"l-section-h i-cf\"><div class=\"g-cols vc_row type_default valign_top\"><div class=\"vc_col-sm-12 wpb_column vc_column_container\"><div class=\"vc_column-inner\"><div class=\"wpb_wrapper\">\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<p>You can use the Kore.ai BotKit SDK to capture and handle events in the Bots Platform for better control and customization of the bot experience for users. The following events are supported by the BotKit SDK:<\/p>\n<ul>\n<li><a href=\"#message\">onMessage<\/a><\/li>\n<li><a href=\"#web\">onWebhook<\/a><\/li>\n<li><a href=\"#agent\">onAgentTransfer<\/a><\/li>\n<li><a href=\"#onevent\">onEventNode<\/a><\/li>\n<li><a href=\"#onalert\">onAlertNode<\/a><\/li>\n<li><a href=\"#onvariable\">onVariableUpdate<\/a><\/li>\n<li><a href=\"#OnClientEvent\">onClientEvent<\/a><\/li>\n<\/ul>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2 id=\"message\"><span class=\"ez-toc-section\" id=\"onMessage\">onMessage<\/span><\/h2>\n<p>This event consists of the following two components:<\/p>\n<ul>\n<li><span style=\"text-decoration: underline\">onUserMessage:<\/span> This event is triggered when a user sends a message to Bot and it is received by the channel adapter. The user message is wrapped in this event and sent to the SDK.<\/li>\n<li><span style=\"text-decoration: underline\">onBotMessage<\/span>: This event is triggered when any messages need to be sent to the user. These messages are sent to the SDK along with <code>context<\/code> object.<\/li>\n<\/ul>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h3 id=\"bot\"><span class=\"ez-toc-section\" id=\"onUserMessage\"><strong>onUserMessage<\/strong><\/span><\/h3>\n<p>Syntax:<\/p>\n<pre class=\"lang:default decode:true\">on_user_message : function(requestId, data, callback)<\/pre>\n<p>Parameters:<\/p>\n<ul>\n<li><code>requestId<\/code> &#8211; A unique ID for each message event.<\/li>\n<li><code>payload<\/code> &#8211; A JSON response payload as follows:\n<pre class=\"lang:default decode:true\">{\r\n   \"message\":\"message sent by bot to the user\",\r\n   \"taskId\":\"Dialog task Id\",\r\n   \"nodeId\":\"current node id in the dialog flow\",\r\n   \"channel\":\"channel name\",\r\n   \"context\":\"context object\"\r\n}<\/pre>\n<\/li>\n<li><code>callback<\/code> &#8211; The function to call at event completion used to send the updated message and context back to the Bots Platform.<\/li>\n<\/ul>\n<p>Example:<br \/>\nIn the following code example for the onUserMessage event, the user message is evaluated for transfer to a live agent and transferred, otherwise, the message is passed on to the BotKit SDK for processing.<\/p>\n<pre class=\"lang:default decode:true\">\/*\r\n * OnUserMessage event handler\r\n *\/\r\nfunction onUserMessage(requestId, payload, callback){\r\n    debug(\"user message\", payload);\r\n    var visitorId = _.get(payload, 'channel.from');\r\n\tvisitorId = payload.context.session.UserContext._id;\r\n\tvar entry = _map[visitorId];\r\n\tif (payload.message === \"clearagent\") \/\/ disconnect from LiveChat on user utterance\r\n\t{\r\n\t\tsdk.clearAgentSession(payload);\r\n\t}\r\n    if(entry){\/\/check for live agent\r\n        \/\/route to live agent\r\n        var formdata = {};\r\n        formdata.secured_session_id = entry.secured_session_id;\r\n        formdata.licence_id = config.liveagentlicense;\r\n        formdata.message = payload.message;\r\n        return api.sendMsg(visitorId, formdata)\r\n            .catch(function(e){\r\n                console.error(e);\r\n                delete userDataMap[visitorId];\r\n                delete _map[visitorId];\r\n                return sdk.sendBotMessage(payload, callback);\r\n            });\r\n    }\r\n    else {\r\n        return sdk.sendBotMessage(payload, callback);\r\n    }\r\n}<\/pre>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h3><span class=\"ez-toc-section\" id=\"onBotMessage\"><strong>onBotMessage<\/strong><\/span><\/h3>\n<p>Syntax:<\/p>\n<pre class=\"lang:default decode:true\">\u00a0on_bot_message : function(requestId, data, callback)<\/pre>\n<p>Parameters:<\/p>\n<ul>\n<li><code>requestId<\/code> &#8211; A unique ID for each message event.<\/li>\n<li><code>payload<\/code> &#8211; A JSON response payload as follows:\n<pre class=\"lang:default decode:true\">{\r\n   \"message\":\"message sent to the user\",\r\n   \"channel\":\"channel name\",\r\n   \"context\":\"context object\"\r\n}<\/pre>\n<\/li>\n<li><code>callback<\/code> &#8211; The function to call at event completion used to send the updated message and context back to the user.<\/li>\n<\/ul>\n<p>Example:<br \/>\nThe following code snippet onBotMessage event evaluates the user message for content and then for message tone. If the message tone is greater than or equal to 2 for the angry tone, then the bot communication between the user and the bot is switched to a live agent.<\/p>\n<pre class=\"lang:default decode:true\">\/*\r\n * onBotMessage event handler\r\n *\/\r\nfunction onBotMessage(requestId, payload, callback){\r\n    debug(\"Bot Message Data\",payload);\r\n\tconsole.log(\"in bot message\");\r\n    var visitorId = _.get(paylod, 'channel.from');\r\n    var entry = _map[visitorId];\r\n    if(data.message.length === 0 || payload.message === '') {\r\n        return;\r\n    }\r\n    var message_tone = _.get(payload, 'context.message_tone');console.log(\"message tone -----\",message_tone);\r\n    if(message_tone &amp;&amp; message_tone.length&gt; 0){\r\n        var angry = _.filter(message_tone, {tone_name: 'angry'});\r\n        if(angry.length){\r\n            angry = angry[0];\r\n            if(angry.level &gt;=2){\r\n              return  connectToAgent(requestId, data);\r\n            }\r\n        }\r\n    }\r\n    if(!entry)\r\n    {\r\n        sdk.sendUserMessage(payload, callback);\r\n    }\r\n}<\/pre>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2 id=\"web\"><span class=\"ez-toc-section\" id=\"onWebHook\">onWebHook<\/span><\/h2>\n<p>This event is triggered when the Kore NL Engine processes the Webhook node in the dialog flow. This event is sent to the SDK with <code>componentId<\/code> and context. The SDK can execute business logic and send the updated context back to the platform.<br \/>\nSyntax:<\/p>\n<pre class=\"lang:default decode:true\">on_webhook = function(requestId, componentId, payload, callback)<\/pre>\n<p>Parameters:<\/p>\n<ul>\n<li><code>requestId<\/code> &#8211; A unique ID for each webhook event.<\/li>\n<li><code>componentId<\/code> &#8211; The unique ID for the SDKWebhook node.<\/li>\n<li><code>payload<\/code> &#8211; A JSON response payload as follows:\n<pre class=\"lang:default decode:true\">{\r\n   \"message\":\"message sent by bot to the Bots platform\",\r\n   \"taskId\":\"Dialog task Id\",\r\n   \"nodeId\":\"current node id in the dialog flow\",\r\n   \"channel\":\"channel name\",\r\n   \"context\":\"context object\"\r\n}<\/pre>\n<\/li>\n<li><code>callback<\/code> &#8211; The function to call at event completion used to send the updated message and context back to the Bots Platform.<\/li>\n<\/ul>\n<p>Examples<br \/>\nIn the following example for the <code>on_webhook<\/code> event, two hotel names are returned as results as a response to user input.<\/p>\n<pre class=\"lang:default decode:true \">    \/\/on_webhook handler\r\n    on_webhook  : function(requestId, payload, componentId, callback) {\r\n        if (componentId === 'sendResponse') {\r\n          var hotels = {\r\n            \"hotels\":[\r\n                  \"Taj Banjara\",\r\n                  \"Novotel\"\r\n            ]\r\n          };\r\n          payload.context.hotelResults = hotels;\r\n          callback(null,data);\r\n        }\r\n    }<\/pre>\n<p>In this example for the <code>on_webhook<\/code> event, for the <em>Flights Info<\/em> node in a dialog task, either a list of departure or destination airports based on the requested date is returned based on the flow of the dialog, as a list of results displayed to the end user.<\/p>\n<pre class=\"lang:default decode:true \">    on_webhook : function(requestId, payload, componentId, callback) {\r\n        var context = payload.context;\r\n\t    if (componentName === 'FlightsInfo') {\r\n\t\t  var origin = context.entities.Source;\r\n          var destination = context.entities.Dest;\r\n          var departureDate = context.entities.Date;\r\n          findFlights(origin,destination,departureDate)\r\n\t\t\t.then(function(flightResults) {\r\n                payload.context.flightResults = flightResults;\r\n\t\t\t\tcallback(null, data);\r\n\t\t\t});\r\n\t    } else if(componentId === 'GetSourceAirports'){\r\n             var searchTerm = context.entities.SourceName;\r\n             findAirports(searchTerm)\r\n            .then(function(airportResults) {\r\n                payload.context.sourceAirports = airportResults;\r\n                callback(null, data);\r\n            });\r\n        } else if(componentId === 'GetDestAirports'){\r\n           var searchTerm = context.entities.DestName;\r\n             findAirports(searchTerm)\r\n            .then(function(airportResults) {\r\n                payload.context.destAirports = airportResults;\r\n                callback(null, data);\r\n            });\r\n        }<\/pre>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2 id=\"agent\"><span class=\"ez-toc-section\" id=\"onAgentTransfer\">onAgentTransfer<\/span><\/h2>\n<p>This event is triggered when the Kore NL Engine processes an Agent Transfer node in the dialog flow. This event is sent to the SDK with <code>requestId<\/code> and context. The SDK can execute a business logic to switch the user seamlessly to a Live Agent.<br \/>\nSyntax:<\/p>\n<pre class=\"lang:default decode:true\">function onAgentTransfer(requestId, data, callback){\r\nconnectToAgent(requestId, data, callback);\r\n}<\/pre>\n<p>Parameters:<\/p>\n<ul>\n<li><code>requestId<\/code> &#8211; A unique ID for each message event.<\/li>\n<li><code>payload<\/code> &#8211; A JSON response payload as follows:\n<pre class=\"lang:default decode:true\">{\r\n   OnAgentTransferPayload \",\"\r\n      requestId \":1501244156289,\"\r\n      botId \":\"st - b4a22e86 - e95b - 575 c - b888 - e106d083a251 \",\"\r\n      callbackUrl \":\"https: \/\/bots.kore.ai\/api\/botsdk\/stream\/st-b4a22e86-e95b-575c-b888-e106d083a251\/serviceCallback\/1501244156289\",\"context\": ...\r\n}<\/pre>\n<\/li>\n<li><code>callback<\/code> &#8211; The function to call at event completion used to send the updated message and context back to the Bots Platform.<\/li>\n<\/ul>\n<p>Example:<br \/>\nThe following code snippet onAgentTransfer event connects the user to a Live Agent and passing the user message, bot message, and historical chat messages of the session.<\/p>\n<pre class=\"lang:default decode:true\">function connectToAgent(requestId, data, cb){\r\nvar formdata = {}; console.log(\"userlog\",JSON.stringify(data.context.session.UserContext._id));\r\nformdata.licence_id = config.liveagentlicense;\r\nformdata.welcome_message = \"\";\r\nvar visitorId = _.get(data, 'channel.channelInfos.from');\r\nif(!visitorId){\r\nvisitorId = _.get(data, 'channel.from');\r\n}\r\nvisitorId = data.context.session.UserContext._id;\r\nuserDataMap[visitorId] = data;\r\ndata.message=\"An Agent will be assigned to you shortly!!!\";\r\nvar d = new Date();\r\ndata.context.session.BotUserSession.startTime = new Date().toLocaleString();\r\nconsole.log(\"userlog\",JSON.stringify(data.context.session));\r\nsdk.sendUserMessage(data, cb);\r\nformdata.welcome_message = \"Link for user Chat history with bot: \"+ config.app.url +\"\/history\/index.html?visitorId=\" + visitorId;\r\nreturn api.initChat(visitorId, formdata)\r\n.then(function(res){\r\n_map[visitorId] = {\r\nsecured_session_id: res.secured_session_id,\r\nvisitorId: visitorId,\r\nlast_message_id: 0\r\n};\r\n});\r\n}<\/pre>\n<pre><\/pre>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2 id=\"onevent\"><span class=\"ez-toc-section\" id=\"OnEvent\">OnEvent<\/span><\/h2>\n<p>This event is triggered when Dialog Task or FAQ ends in the bot and sends request ID and context to the SDK.<br \/>\nSyntax:<br \/>\non_event : function (requestId, data, callback)<br \/>\nParameters:<\/p>\n<ul>\n<li>requestId \u2013 A unique ID for each message event.<\/li>\n<li>data\u2013 A JSON response payload as shown in the example below:<\/li>\n<li>callback \u2013 The function to call after event completion; it is used to send the updated message and context back to the Bots Platform.<\/li>\n<\/ul>\n<p>Example:<\/p>\n<pre>on_event : function (requestId, data, callback)\r\n{\r\nreturn sdk.sendAlertMessage(data, callback);\r\n}<\/pre>\n<p>The event adds the following code in the Data object sent to kit:<\/p>\n<pre class=\"\">\"event\":\r\n{\r\n\"event Type\": \"endDialog\"\/ \u201cendFAQ\u201d\r\n}<\/pre>\n<pre><\/pre>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2 id=\"onalert\"><span class=\"ez-toc-section\" id=\"OnAlert\">OnAlert<\/span><\/h2>\n<p>This event is triggered when a bot user receives an alert.<br \/>\nSyntax:<br \/>\non_alert : function (requestId, data, callback)<br \/>\nParameters:<\/p>\n<ul>\n<li><code>requestId<\/code> \u2013 A unique ID for each message event.<\/li>\n<li><code>data<\/code>\u2013 A JSON response payload.<\/li>\n<li><code>callback<\/code> \u2013 The function to call at event completion; it is used to send the updated message and context back to the Bots Platform.<\/li>\n<\/ul>\n<p>Example:<\/p>\n<pre class=\"\">on_alert: function(requestId, data, callback)\r\n{\r\n return sdk.sendAlertMessage(data, callback);\r\n}<\/pre>\n<p>The alert response data is found in the data object sent to the kit.<\/p>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2 id=\"onvariable\"><span class=\"ez-toc-section\" id=\"OnVariableUpdate\">OnVariableUpdate<\/span><\/h2>\n<p>This event is triggered on <strong>variable_update<\/strong> when Bot is published.<\/p>\n<p>Syntax:<br \/>\nvariable_update : function (requestId, data, callback)<br \/>\nParameters:<\/p>\n<ul>\n<li><code>requestId<\/code> \u2013 A unique ID for each message event.<\/li>\n<li><code>data<\/code>\u2013 A JSON response payload<\/li>\n<li><code>callback<\/code> \u2013 The function to call after event completion; it is used to send the updated message and context back to the Bots Platform.<\/li>\n<\/ul>\n<pre>var event = data.eventType;\r\nconsole.log(\"event-----------&gt;\", event);\r\nif (first || event == \"variable_update\") {\r\n\/\/ fetch BotVariables List for published Bots\r\nsdk.fetchBotVariable(data, langArr, function(err, response) {\r\ndataStore.saveAllVariables(response, langArr);\r\nfirst = false;\r\n});\r\n} else {\r\nvar lang = data.language;\r\n\/\/update Existing BotVariables in Storage\r\nupdateBotVariableInDataStore(botVariables, data, event, lang);\r\n}\r\nconsole.log(dataStore);<\/pre>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2 id=\"onvariable\"><span class=\"ez-toc-section\" id=\"OnClientEvent\">OnClientEvent<\/span><\/h2>\n<p>This event is triggered on <strong>client_event<\/strong> when Bot receives client events sent by the third party application.<\/p>\n<p>Syntax:<br \/>\non_client_event : function (requestId, data, callback)<br \/>\nParameters:<\/p>\n<ul>\n<li><code>requestId<\/code> \u2013 A unique ID for each message event.<\/li>\n<li><code>data<\/code>\u2013 A JSON response payload<\/li>\n<li><code>callback<\/code> \u2013 The function to call after event completion; it is used to send the updated message and context back to the Bots Platform.<\/li>\n<\/ul>\n<pre>on_client_event : function (requestId, data, callback) {\r\n    console.log(\"on_client_event --&gt;  : \", data.preDefinedEvent, data.customEvent);\r\n    return sdk.sendBotEvent(data, callback);\r\n    }<\/pre>\n<p>These events are associated with the application subscribing to botkit event type &#8211; <strong>onMessage<\/strong> and <strong>onagenttransfer<\/strong>. These event can be used to track the events like user is typing, user has stopped typing or user has read the message.<\/p>\n<p>Examples:<\/p>\n<ul>\n<li><strong>User started typing:<br \/>\n<\/strong><em>Request<\/em>:<br \/>\n{ &#8220;resourceid&#8221;: &#8220;\/bot.clientEvent&#8221;,<br \/>\n&#8220;preDefinedEvent&#8221; : { &#8220;type&#8221;: &#8220;TYPING_STARTED&#8221; },<br \/>\n&#8220;customEvent&#8221;: {&#8220;test&#8221;:&#8221;test&#8221;},<br \/>\n&#8220;botInfo&#8221;: {&#8220;chatBot&#8221;:&#8221;&lt;bot-name&gt;&#8221;,<br \/>\n&#8220;taskBotId&#8221;:&#8221;&lt;bot-id&gt;&#8221;} }<br \/>\n<em>Response1<\/em>:<br \/>\n{&#8220;ok&#8221;:true,&#8221;type&#8221;:&#8221;ack&#8221;}<br \/>\n<em>Response2<\/em>:<br \/>\n{&#8220;type&#8221;:&#8221;events&#8221;,<br \/>\n&#8220;from&#8221;:&#8221;bot&#8221;,<br \/>\n&#8220;botInfo&#8221;: {&#8220;chatBot&#8221;:&#8221;&lt;bot-name&gt;&#8221;, &#8220;taskBotId&#8221;:&#8221;&lt;bot-id&gt;&#8221;} },<br \/>\n&#8220;preDefinedEvent&#8221;:{&#8220;type&#8221;:&#8221;TYPING_STARTED&#8221;},<br \/>\n&#8220;customEvent&#8221;:{&#8220;test&#8221;:&#8221;test&#8221;},&#8221;traceId&#8221;:&#8221;6b12f4cc73c806dd&#8221;}<\/li>\n<li><strong>User stopped typing:<br \/>\n<\/strong><em>Request<\/em>:<br \/>\n{ &#8220;resourceid&#8221;: &#8220;\/bot.clientEvent&#8221;,<br \/>\n&#8220;preDefinedEvent&#8221; : { &#8220;type&#8221;: &#8220;TYPING_STOPPED&#8221; },<br \/>\n&#8220;customEvent&#8221;: {&#8220;test&#8221;:&#8221;test&#8221;},<br \/>\n&#8220;botInfo&#8221;: {&#8220;chatBot&#8221;:&#8221;&lt;bot-name&gt;&#8221;,<br \/>\n&#8220;taskBotId&#8221;:&#8221;&lt;bot-id&gt;&#8221;} }<br \/>\n<em>Response1<\/em>:<br \/>\n{&#8220;ok&#8221;:true,&#8221;type&#8221;:&#8221;ack&#8221;}<br \/>\n<em>Response2<\/em>:<br \/>\n{&#8220;type&#8221;:&#8221;events&#8221;,<br \/>\n&#8220;from&#8221;:&#8221;bot&#8221;,<br \/>\n&#8220;botInfo&#8221;: {&#8220;chatBot&#8221;:&#8221;&lt;bot-name&gt;&#8221;, &#8220;taskBotId&#8221;:&#8221;&lt;bot-id&gt;&#8221;} },<br \/>\n&#8220;preDefinedEvent&#8221;:{&#8220;type&#8221;:&#8221;TYPING_STOPPED&#8221;},<br \/>\n&#8220;customEvent&#8221;:{&#8220;test&#8221;:&#8221;test&#8221;},&#8221;traceId&#8221;:&#8221;6b12f4cc73c806dd&#8221;}<\/li>\n<li><strong>User read the message:<br \/>\n<\/strong><em>Request<\/em>:<br \/>\n{ &#8220;resourceid&#8221;: &#8220;\/bot.clientEvent&#8221;,<br \/>\n&#8220;preDefinedEvent&#8221; : { &#8220;type&#8221;: &#8220;MESSAGE_READ&#8221;, &#8220;id&#8221;: &#8220;&lt;msg-id&gt;&#8221; },<br \/>\n&#8220;customEvent&#8221;: {&#8220;string&#8221;},<br \/>\n&#8220;botInfo&#8221;: {&#8220;chatBot&#8221;:&#8221;&lt;bot-name&gt;&#8221;,<br \/>\n&#8220;taskBotId&#8221;:&#8221;&lt;bot-id&gt;&#8221;} }<br \/>\n<em>Response1<\/em>:<br \/>\n{&#8220;ok&#8221;:true,&#8221;type&#8221;:&#8221;ack&#8221;}<br \/>\n<em>Response2<\/em>:<br \/>\n{&#8220;type&#8221;:&#8221;events&#8221;,<br \/>\n&#8220;from&#8221;:&#8221;bot&#8221;,<br \/>\n&#8220;botInfo&#8221;: {&#8220;chatBot&#8221;:&#8221;&lt;bot-name&gt;&#8221;, &#8220;taskBotId&#8221;:&#8221;&lt;bot-id&gt;&#8221;} },<br \/>\n&#8220;preDefinedEvent&#8221;:{&#8220;type&#8221;:&#8221;MESSAGE_READ&#8221;, &#8220;id&#8221;:&#8221;&lt;msg-id&gt;&#8221;},<br \/>\n&#8220;customEvent&#8221;:{&#8220;string&#8221;},&#8221;traceId&#8221;:&#8221;6b12f4cc73c806dd&#8221;}<\/li>\n<\/ul>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div><\/div><\/div><\/div><\/div><\/div><\/section>\n","protected":false},"excerpt":{"rendered":"You can use the Kore.ai BotKit SDK to capture and handle events in the Bots Platform for better control and customization of the bot experience for users. The following events are supported by the BotKit SDK: onMessage onWebhook onAgentTransfer onEventNode onAlertNode onVariableUpdate onClientEvent onMessage This event consists of the following two components: onUserMessage: This event...","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-17998","post","type-post","status-publish","format-standard","hentry","category-sdks"],"_links":{"self":[{"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/posts\/17998","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/comments?post=17998"}],"version-history":[{"count":9,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/posts\/17998\/revisions"}],"predecessor-version":[{"id":24151,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/posts\/17998\/revisions\/24151"}],"wp:attachment":[{"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/media?parent=17998"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/categories?post=17998"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/tags?post=17998"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}