{"id":17960,"date":"2016-12-22T20:51:59","date_gmt":"2016-12-22T20:51:59","guid":{"rendered":"https:\/\/developer.kore.com\/?post_type=docs&#038;p=9568"},"modified":"2021-03-31T07:15:57","modified_gmt":"2021-03-31T06:15:57","slug":"using-the-botkit-sdk","status":"publish","type":"post","link":"https:\/\/developer.kore.ai\/v7-1\/docs\/bots\/sdks\/using-the-botkit-sdk\/","title":{"rendered":"Using 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><span style=\"font-weight: 400\">The Kore.ai BotKit SDK is a set of libraries that provide you with precision control for bot interaction with users for the bots you build on Kore.ai Bots Platform. <\/span><\/p>\n<p><span style=\"font-weight: 400\">When you build a dialog task using Dialog Editor in Bot Builder, you can subscribe message and webhook events by adding event handlers and controlling the messages and webhook events using the SDK. <\/span><\/p>\n<p><span style=\"font-weight: 400\">This topic describes how the BotKit SDK is integrated with the Bots Platform, the SDK events you can use, and download and installation instructions for the BotKit SDK.<\/span><\/p>\n<p><span style=\"font-weight: 400\">While bots can be built to help answer user queries and to perform a transaction for a user, in some cases, we may still need to switch from a bot interaction to a human agent to help the user complete the intent. <\/span><\/p>\n<p><span style=\"font-weight: 400\">For example:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">A user asks a question or provides a response that the bot is not designed to answer. <\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">A user directly requests to chat with Live Agent rather than that bot itself.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">As a bot developer, you design a Live Agent transfer based on the dialog flow based on a specific condition. For example, a specific user type, or based on tone analysis of the user, you want the dialog flow to transfer to a Live Agent.<\/span><\/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><span class=\"ez-toc-section\" id=\"How_it_Works\">How it Works<\/span><\/h2>\n<p><span style=\"font-weight: 400\">You can integrate event handling using the BotKit SDK in your Dialog task by capturing the following event types on the Bots Platform.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Messaging\">Messaging<\/span><\/h3>\n<p>On the Kore.ai Bots Platform, a user interacts with your bot on one of the channels defined for the Bot. In the following diagram, you can see the user message flow through the Kore.ai Bots Platform, the BotKit SDK, and our natural language processing engine.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/12\/BotsPlatformBotKitSDKFlow-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22869\" src=\"\/wp-content\/uploads\/sites\/12\/BotsPlatformBotKitSDKFlow-1.png\" alt=\"\" width=\"786\" height=\"446\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/12\/20221201094820\/BotsPlatformBotKitSDKFlow-1.png 786w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/12\/20221201094820\/BotsPlatformBotKitSDKFlow-1-300x170.png 300w\" sizes=\"auto, (max-width: 786px) 100vw, 786px\" \/><\/a><br \/>\nAll messages, both user and Bot responses are sent to the BotKit SDK as message events.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Webhooks\">Webhooks<\/span><\/h3>\n<p>Your BotKit SDK receives webhook events whenever the natural language processor enters the SDKWebhook node in a Bot Builder dialog task flow. In the following sequence diagram, flow for a user sending a message via a bot channel until the user response is shown.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/12\/Seq1-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22870\" src=\"\/wp-content\/uploads\/sites\/12\/Seq1-1.png\" alt=\"\" width=\"1085\" height=\"662\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/12\/20221201094820\/Seq1-1.png 1085w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/12\/20221201094820\/Seq1-1-300x183.png 300w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/12\/20221201094820\/Seq1-1-1024x625.png 1024w\" sizes=\"auto, (max-width: 1085px) 100vw, 1085px\" \/><\/a><br \/>\nFor webhook events, you should add a Webhook node in the dialog task flow whenever there is a need for server-side validation, execution of business logic, or a backend server call is required. Business logic and the response is sent on the same <code>on_webhook<\/code> event. The response is an HTTP status code 202. To send response data to the Bots Platform from the SDK, call the <code>sdk.sendWebhookResponse()<\/code> event.<br \/>\nWebhook events are received by the SDK when the Kore.ai NL Engine processes\u00a0a Webhook node in a dialog task flow. The Kore.ai NLP engine processes each node, and then transitions to the next node based on the conditions defined. When a Webhook node is processed, a webhook call is executed and the Bots Platform sends the <code>on_webhook<\/code> event to the SDK. The following sequence diagram shows the message flow with a webhook.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/12\/Seq2-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22872\" src=\"\/wp-content\/uploads\/sites\/12\/Seq2-1.png\" alt=\"\" width=\"1220\" height=\"643\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/12\/20221201094820\/Seq2-1.png 1220w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/12\/20221201094820\/Seq2-1-300x158.png 300w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/12\/20221201094820\/Seq2-1-1024x540.png 1024w\" sizes=\"auto, (max-width: 1220px) 100vw, 1220px\" \/><\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Agent_Transfer\">Agent Transfer<\/span><\/h3>\n<p>In the following sequence diagram, the Bots Platform responds to user input directly, until the Agent Transfer condition is matched. When matched, the Bots Platform connects to your BotKit SDK implementation, and then initializes the chat, for example, getting the current conversation. The BotKit SDK integrates the user and agent conversation until the Live Agent session is closed. When switching to a Live Agent, the current dialog task ends.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/12\/DIYBotTasksDialogAgentTransferDialogram.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-11692 alignnone\" src=\"\/wp-content\/uploads\/sites\/12\/DIYBotTasksDialogAgentTransferDialogram.png\" alt=\"\" width=\"1266\" height=\"752\" \/><\/a><br \/>\nTo set up an Agent Transfer in your dialog conversation flow, you will need to:<\/p>\n<ol>\n<li>Create an app in Kore.ai Bot Builder on the <strong>Settings<\/strong> tab &gt; <strong>SDK Configurations<\/strong> section, define the Callback URL and generate <strong>Client ID<\/strong> and <strong>Client Secret<\/strong>, and enable <strong>OnAgentTransferNode<\/strong>.<\/li>\n<li>Identify the steps and define the transition conditions to meet to transfer to an agent.<\/li>\n<li>Add the Agent Transfer node in the dialog flow as shown in the following illustration<\/li>\n<\/ol>\n<p>For more information, see <a href=\"\/v7-1\/docs\/bots\/advanced-topics\/sdks\/botkit-sdk-tutorial-agent-transfer\/\">BotKit SDK Tutorial &#8211; Agent Transfer<\/a>.<\/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><\/div><\/div><\/div><\/div><\/div><\/section>\n","protected":false},"excerpt":{"rendered":"The Kore.ai BotKit SDK is a set of libraries that provide you with precision control for bot interaction with users for the bots you build on Kore.ai Bots Platform. When you build a dialog task using Dialog Editor in Bot Builder, you can subscribe message and webhook events by adding event handlers and controlling the...","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-17960","post","type-post","status-publish","format-standard","hentry","category-sdks"],"_links":{"self":[{"href":"https:\/\/developer.kore.ai\/v7-1\/wp-json\/wp\/v2\/posts\/17960","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developer.kore.ai\/v7-1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developer.kore.ai\/v7-1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-1\/wp-json\/wp\/v2\/comments?post=17960"}],"version-history":[{"count":4,"href":"https:\/\/developer.kore.ai\/v7-1\/wp-json\/wp\/v2\/posts\/17960\/revisions"}],"predecessor-version":[{"id":22873,"href":"https:\/\/developer.kore.ai\/v7-1\/wp-json\/wp\/v2\/posts\/17960\/revisions\/22873"}],"wp:attachment":[{"href":"https:\/\/developer.kore.ai\/v7-1\/wp-json\/wp\/v2\/media?parent=17960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-1\/wp-json\/wp\/v2\/categories?post=17960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-1\/wp-json\/wp\/v2\/tags?post=17960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}