{"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":"2023-10-16T16:44:17","modified_gmt":"2023-10-16T15:44:17","slug":"using-the-botkit-sdk","status":"publish","type":"post","link":"https:\/\/developer.kore.ai\/v10-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 enable interaction control between users and the assistants you build on Kore.ai XO Platform.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">When you build a dialog task using Dialog Editor in XO Platform, you can subscribe to 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 XO 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 Virtual Assistants 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 an interaction with the assistant 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 assistant 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 a Live Agent rather than that assistant itself.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">As a 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<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>\n<h2><span class=\"ez-toc-section\" id=\"How_it_Works\"><span style=\"font-weight: 400;\">How it Works<\/span><\/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 XO Platform.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Messaging\"><span style=\"font-weight: 400;\">Messaging<\/span><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">On the Kore.ai XO Platform, a user interacts with your assistant on one of the defined channels . In the following diagram, you can see the user message flow through the Kore.ai XO Platform, the BotKit SDK, and our natural language processing engine.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><a ref=\"magnificPopup\" href=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221201094300\/BotsPlatformBotKitSDKFlow-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22869\" src=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221201094300\/BotsPlatformBotKitSDKFlow-1.png\" alt=\"\" width=\"786\" height=\"446\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221201094300\/BotsPlatformBotKitSDKFlow-1.png 786w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221201094300\/BotsPlatformBotKitSDKFlow-1-300x170.png 300w\" sizes=\"auto, (max-width: 786px) 100vw, 786px\" \/><\/a><\/span><\/p>\n<p><span style=\"font-weight: 400;\">All messages, both user and assistant responses are sent to the BotKit SDK as message events.<\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Feedback_Survey\">Feedback Survey<\/span><\/h3>\n<p>When a feedback survey is created for a conversation over a specific channel, a user responds to the virtual assistant for a survey question based on the configured survey type (NPS, CSAT, or Thumbs-up\/down). The feedback survey score sent by the user is captured in the system.<\/p>\n<p>All the feedback survey messages exchanged between the user and the assistant are sent to the BotKit SDK as message events.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Webhooks\"><span style=\"font-weight: 400;\">Webhooks<\/span><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Your BotKit SDK receives webhook events whenever the natural language processor enters the SDK <a href=\"https:\/\/developer.kore.ai\/v10-1\/docs\/bots\/bot-builder-tool\/dialog-task\/working-with-the-web-hook-node\/\" target=\"_blank\" rel=\"noopener noreferrer\">Webhook node<\/a> in an XO Platform dialog task flow. In the following sequence diagram, flow for a user sending a message via a channel until the user response is shown.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><a ref=\"magnificPopup\" href=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221201094259\/Seq1-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22870\" src=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221201094259\/Seq1-1.png\" alt=\"\" width=\"779\" height=\"476\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221201094259\/Seq1-1.png 1085w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221201094259\/Seq1-1-300x183.png 300w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221201094259\/Seq1-1-1024x625.png 1024w\" sizes=\"auto, (max-width: 779px) 100vw, 779px\" \/><\/a><\/span><\/p>\n<p><span style=\"font-weight: 400;\">For webhook events, you should add a <a href=\"https:\/\/developer.kore.ai\/v10-1\/docs\/bots\/bot-builder-tool\/dialog-task\/working-with-the-web-hook-node\/\" target=\"_blank\" rel=\"noopener noreferrer\">Webhook node<\/a> 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 <\/span><span style=\"font-weight: 400;\">on_webhook<\/span><span style=\"font-weight: 400;\"> event. The response is an HTTP status code 202. To send response data to the XO Platform from the SDK, call the <\/span><span style=\"font-weight: 400;\">sdk.sendWebhookResponse()<\/span><span style=\"font-weight: 400;\"> event.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Webhook events are received by the SDK when the Kore.ai NL Engine processes a 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 XO Platform sends the <\/span><span style=\"font-weight: 400;\">on_webhook<\/span><span style=\"font-weight: 400;\"> event to the SDK. The following sequence diagram shows the message flow with a webhook.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><a ref=\"magnificPopup\" href=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221201094259\/Seq2-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22872\" src=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221201094259\/Seq2-1.png\" alt=\"\" width=\"793\" height=\"418\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221201094259\/Seq2-1.png 1220w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221201094259\/Seq2-1-300x158.png 300w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221201094259\/Seq2-1-1024x540.png 1024w\" sizes=\"auto, (max-width: 793px) 100vw, 793px\" \/><\/a><\/span><\/p>\n<h3><span class=\"ez-toc-section\" id=\"Agent_Transfer\"><span style=\"font-weight: 400;\">Agent Transfer<\/span><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">In the following sequence diagram, the XO Platform responds to user input directly, until the Agent Transfer condition is matched. When matched, the XO 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.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><a ref=\"magnificPopup\" href=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221005052916\/Botkit-flow4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-48102\" src=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221005052916\/Botkit-flow4.png\" alt=\"\" width=\"800\" height=\"475\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221005052916\/Botkit-flow4.png 1266w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221005052916\/Botkit-flow4-300x178.png 300w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221005052916\/Botkit-flow4-1024x608.png 1024w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><\/span><\/p>\n<p><span style=\"font-weight: 400;\">To set up an Agent Transfer in your dialog conversation flow, you will need to:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Create an app on the XO Platform under <\/span><strong>Build &gt; Integrations &gt; BotKit<\/strong><span style=\"font-weight: 400;\"> section.<br \/>\n<strong>Note: <\/strong>RS256 and RS512 JWT signing algorithms are not supported for Custom BotKit or Botkit.<br \/>\n<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Define the <\/span><strong>Callback URL<\/strong><span style=\"font-weight: 400;\"> and generate <\/span><strong>Client ID<\/strong><span style=\"font-weight: 400;\"> and <\/span><strong>Client Secret<\/strong><span style=\"font-weight: 400;\">, and enable <\/span><strong>OnAgentTransferNode<\/strong><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Identify the steps and define the transition conditions to meet to transfer to an agent.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Add the Agent Transfer node in the dialog flow as shown in the following illustration<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">For more information, see <\/span><a href=\"https:\/\/developer.kore.ai\/v10-1\/docs\/bots\/sdks\/botkit-sdk-tutorial-agent-transfer\/\"><span style=\"font-weight: 400;\">BotKit SDK Tutorial \u2013 Agent Transfer<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\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>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<\/div><\/div><\/div><\/div><\/div><\/section>\n","protected":false},"excerpt":{"rendered":"The Kore.ai BotKit SDK is a set of libraries that enable interaction control between users and the assistants you build on Kore.ai XO Platform. When you build a dialog task using Dialog Editor in XO Platform, you can subscribe to message and webhook events by adding event handlers and controlling the messages and webhook events...","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\/v10-1\/wp-json\/wp\/v2\/posts\/17960","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/comments?post=17960"}],"version-history":[{"count":18,"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/posts\/17960\/revisions"}],"predecessor-version":[{"id":59892,"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/posts\/17960\/revisions\/59892"}],"wp:attachment":[{"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/media?parent=17960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/categories?post=17960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/tags?post=17960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}