{"id":48011,"date":"2022-10-04T17:06:03","date_gmt":"2022-10-04T16:06:03","guid":{"rendered":"https:\/\/developer.kore.ai\/v10-1\/?p=48011"},"modified":"2022-10-04T19:13:52","modified_gmt":"2022-10-04T18:13:52","slug":"travel-va-managing-context-switching","status":"publish","type":"post","link":"https:\/\/developer.kore.ai\/v10-1\/docs\/bots\/how-tos\/travel-planing-assistant\/travel-va-managing-context-switching\/","title":{"rendered":"Travel VA: Managing Context Switching"},"content":{"rendered":"<p><span style=\"font-weight: 400\">In this Use Case, we will explore a scenario in a Travel Planning Assistant, where, sharing the context across intents, FAQs help in improving the user experience and the assistant\u2019s efficiency. Also, we will be looking at how the context can be used within a dialog flow to determine the sequence of events.<\/span><\/p>\n<p><span style=\"font-weight: 400\">For details on what Context Management is and how it is implemented in the Kore.ai XO Platform, <\/span><a href=\"https:\/\/developer.kore.ai\/v10-1\/docs\/bots\/bot-intelligence\/context-management\/\"><span style=\"font-weight: 400\">refer here<\/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<h1><span class=\"ez-toc-section\" id=\"Problem_Statement\"><span style=\"font-weight: 400\">Problem Statement<\/span><\/span><\/h1>\n<p><span style=\"font-weight: 400\">Consider a Travel Planning VA trying to address the following scenarios:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400\"><strong>Sharing content across intents<\/strong><span style=\"font-weight: 400\"> \u2013 Once the user has entered his\/her booking number, they should not be prompted for it again in the course of the conversation.<\/span><span style=\"font-weight: 400\"><br \/><\/span><code><em><span style=\"font-weight: 400\">User: I want to change my seat.<\/span><\/em><em><span style=\"font-weight: 400\"><br \/><\/span><\/em><em><span style=\"font-weight: 400\">VA: Sure, may I have your booking number?<\/span><\/em><em><span style=\"font-weight: 400\"><br \/><\/span><\/em><em><span style=\"font-weight: 400\">\/\/ (initiating Change Seat Task)<\/span><\/em><em><span style=\"font-weight: 400\"><br \/><\/span><\/em><em><span style=\"font-weight: 400\">User: It\u2019s 2343544<\/span><\/em><em><span style=\"font-weight: 400\"><br \/><\/span><\/em><em><span style=\"font-weight: 400\">VA: What is the new seat you would prefer?<\/span><\/em><em><span style=\"font-weight: 400\"><br \/><\/span><\/em><em><span style=\"font-weight: 400\">User: I want extra legroom. What options do I have?<\/span><\/em><em><span style=\"font-weight: 400\"><br \/><\/span><\/em><em><span style=\"font-weight: 400\">\/\/ (transferring to Get seat task)<\/span><\/em><em><span style=\"font-weight: 400\"><br \/><\/span><\/em><em><span style=\"font-weight: 400\">VA: <\/span><\/em><span style=\"text-decoration: underline\"><em><span style=\"font-weight: 400\">What is your booking number?<\/span><\/em><\/span><em><span style=\"font-weight: 400\"><br \/><\/span><\/em><\/code><code><\/code><span style=\"font-weight: 400\"><br \/>Ideally, Get Seat should not be asking for the flight number again.<\/span><\/li>\n<li style=\"font-weight: 400\"><strong>Context-based dialog flow<\/strong><span style=\"font-weight: 400\"> \u2013 Based upon the context, the flow of a given task might change with the assistant making an explicit call to another task as a sub-dialog.<\/span><span style=\"font-weight: 400\"><br \/><\/span><span style=\"font-weight: 400\">Extending the above example:<\/span><\/li>\n<\/ul>\n<p style=\"padding-left: 40px\"><em><span style=\"font-weight: 400\">User: I want to change my seat.<\/span><\/em><em><span style=\"font-weight: 400\"><br \/><\/span><\/em><em><span style=\"font-weight: 400\">VA: Sure, may I have your booking number?<\/span><\/em><em><span style=\"font-weight: 400\"><br \/><\/span><\/em><em><span style=\"font-weight: 400\">\/\/ (initiating Change Seat Task)<\/span><\/em><em><span style=\"font-weight: 400\"><br \/><\/span><\/em><em><span style=\"font-weight: 400\">User: It\u2019s 2343544<\/span><\/em><em><span style=\"font-weight: 400\"><br \/><\/span><\/em><em><span style=\"font-weight: 400\">VA: <span style=\"text-decoration: underline\">What is the new seat you would prefer?<\/span><\/span><\/em><span style=\"text-decoration: underline\"><em><span style=\"font-weight: 400\"><br \/><\/span><\/em><\/span><em><span style=\"font-weight: 400\">User: Seat 12A, please.<\/span><\/em><em><span style=\"font-weight: 400\"><br \/><\/span><\/em><em><span style=\"font-weight: 400\">\/\/ (transferring to Get seat task)<br \/><\/span><\/em><em><span style=\"font-weight: 400\">VA: <span style=\"text-decoration: underline\">Your current seat is 25B.<\/span><\/span><\/em><em><span style=\"font-weight: 400\"><br \/><\/span><\/em><em><span style=\"font-weight: 400\">VA: I have changed your seat to Seat 12A.<\/span><\/em><span style=\"font-weight: 400\"><br \/><\/span><em><span style=\"font-weight: 400\"><br \/><\/span><\/em><span style=\"font-weight: 400\">Ideally, Get Seat\u00a0 should not ask for the flight number and should not display the current seat message. It should happen in the background between the two tasks, without user knowledge.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400\"><strong>Follow-up Intents<\/strong><span style=\"font-weight: 400\"> \u2013 Access to certain tasks could be restricted due to security reasons or business requirements. Additionally, other tasks could be made inaccessible to the user; or even to the assistant.<\/span><span style=\"font-weight: 400\"><br \/><\/span><span style=\"font-weight: 400\">For example, updating seats should be restricted to the Change Seat flow. An <\/span><em><span style=\"font-weight: 400\">Update Booking<\/span><\/em><span style=\"font-weight: 400\"> task should not be available directly to the User nor any other task in the assistant.<\/span><\/li>\n<li style=\"font-weight: 400\"><strong>Sharing context between intent and FAQs<\/strong><span style=\"font-weight: 400\"> \u2013 During a task, the user might ask a generic question but within the context.<\/span><span style=\"font-weight: 400\"><br \/><\/span><span style=\"font-weight: 400\">For example, while changing seats, the user might ask if there is a fee; and the assistant needs to respond with the FAQ related to seat change\u00a0 rates.<\/span><\/li>\n<li style=\"font-weight: 400\"><strong>Sharing content across FAQs<\/strong><span style=\"font-weight: 400\"> \u2013 A specific question might be a follow up of a previous query. <\/span><span style=\"font-weight: 400\"><br \/><\/span><span style=\"font-weight: 400\">For example, \u201c<\/span><em><span style=\"font-weight: 400\">Are there any charges for a flight change? ?<\/span><\/em><span style=\"font-weight: 400\">\u201d followed by \u201c<\/span><em><span style=\"font-weight: 400\">What are the charges?<\/span><\/em><span style=\"font-weight: 400\">\u201dThe charges reference is to the flight change.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400\">Having this problem statement in view, this document provides a detailed step-by-step approach to achieving all the above-mentioned scenarios using \u2013 context tags and variables, input pre-conditions and output context, and emit entity value features of the Platform.<\/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<h1><span class=\"ez-toc-section\" id=\"Prerequisites\"><span style=\"font-weight: 400\">Prerequisites<\/span><\/span><\/h1>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Knowledge on <\/span><span style=\"font-weight: 400\">how to <a href=\"https:\/\/developer.kore.ai\/v10-1\/docs\/bots\/how-tos\/travel-planing-assistant\/create-a-travel-virtual-assistant\/\" target=\"_blank\" rel=\"noopener noreferrer\">build a virtual assistant<\/a><\/span><span style=\"font-weight: 400\">.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">A <\/span><span style=\"font-weight: 400\">Virtual Assistant<\/span><span style=\"font-weight: 400\"> with the Dialog Tasks mentioned below &#8211; <a href=\"https:\/\/developer.kore.ai\/v10-1\/docs\/bots\/how-tos\/travel-assistant-overview\/\" target=\"_blank\" rel=\"noopener noreferrer\">see an overview here<\/a>.<\/span><\/li>\n<li style=\"font-weight: 400\"><strong>Check Flight Status <\/strong><span style=\"font-weight: 400\">&#8211; This task prompts the user to enter their flight number and displays its status.<br \/><\/span><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\/20221004154144\/flightstatus-task.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-47889\" src=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154144\/flightstatus-task.png\" alt=\"\" width=\"304\" height=\"594\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154144\/flightstatus-task.png 349w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154144\/flightstatus-task-154x300.png 154w\" sizes=\"auto, (max-width: 304px) 100vw, 304px\" \/><\/a><\/span><\/li>\n<li style=\"font-weight: 400\"><strong>Change Flight<\/strong><span style=\"font-weight: 400\"> &#8211; This task prompts the user for their Current Flight and New Flight, then performs the flight change.<br \/><a ref=\"magnificPopup\" href=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154139\/changeflight-task.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-47886\" src=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154139\/changeflight-task.png\" alt=\"\" width=\"299\" height=\"939\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154139\/changeflight-task.png 299w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154139\/changeflight-task-96x300.png 96w\" sizes=\"auto, (max-width: 299px) 100vw, 299px\" \/><\/a> <\/span><span style=\"font-weight: 400\"><br \/><\/span><\/li>\n<li style=\"font-weight: 400\"><strong>Update Booking<\/strong><span style=\"font-weight: 400\"> &#8211; A Dialog Task that asks the user for the number of the booking to update and the update that needs to be made, then performs the update.<br \/><a ref=\"magnificPopup\" href=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154139\/changeflight-task.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-47910\" src=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154215\/updatebooking-task.png\" alt=\"\" width=\"289\" height=\"588\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154215\/updatebooking-task.png 367w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154215\/updatebooking-task-147x300.png 147w\" sizes=\"auto, (max-width: 289px) 100vw, 289px\" \/><\/a><\/span><span style=\"font-weight: 400\"><br \/><\/span><\/li>\n<li style=\"font-weight: 400\"><strong>Knowledge Graph <\/strong><span style=\"font-weight: 400\">&#8211; Frequently asked questions that the assistant handles.<br \/><a ref=\"magnificPopup\" href=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154157\/kg-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-47898\" src=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154157\/kg-3-1024x540.png\" alt=\"\" width=\"640\" height=\"338\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154157\/kg-3-1024x540.png 1024w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154157\/kg-3-300x158.png 300w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154157\/kg-3.png 1622w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><br \/><\/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<h1><span class=\"ez-toc-section\" id=\"Implementation\"><span style=\"font-weight: 400\">Implementation<\/span><\/span><\/h1>\n<p><span style=\"font-weight: 400\">Let us consider each of the above scenarios one by one.<\/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<h2><span class=\"ez-toc-section\" id=\"Sharing_content_across_intents\"><span style=\"font-weight: 400\">Sharing content across intents<\/span><\/span><\/h2>\n<p><span style=\"font-weight: 400\">Sharing content needs to be handled differently in the two cases mentioned:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400\"><strong>Task-driven transition<\/strong><span style=\"font-weight: 400\"> \u2013 This can be handled at the time of development by invoking the corresponding intent and passing the data through entity pre-assignment<\/span><\/li>\n<li style=\"font-weight: 400\"><strong>User-driven transition<\/strong><span style=\"font-weight: 400\"> \u2013 This is a bit complex since we have no way of knowing when, during the current task flow, the user would make such a request and it requires a combination of tags, entity emission, and extraction.<\/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=\"Task-driven_Context_switching\"><span style=\"font-weight: 400\">Task-driven Context switching<\/span><\/span><\/h2>\n<p><span style=\"font-weight: 400\">The following is the scenario where the Change Flight dialog invokes the Check Flight Status task to ensure that the flight is available to book.\u00a0<\/span><\/p>\n<p><a ref=\"magnificPopup\" href=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154211\/task-driven-context-switching.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-47907\" src=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154211\/task-driven-context-switching.png\" alt=\"\" width=\"418\" height=\"499\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154211\/task-driven-context-switching.png 453w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154211\/task-driven-context-switching-251x300.png 251w\" sizes=\"auto, (max-width: 418px) 100vw, 418px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400\">We will be using the Context Variables and Entity Pre-Assignments to achieve this.<\/span><\/p>\n<p><strong>Steps:<\/strong><\/p>\n<p><span style=\"font-weight: 400\">We need to invoke Check Flight Status\u00a0 from Change Flight, check flight availability\u00a0 and proceed accordingly<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Open the <\/span><strong>Change Flight <\/strong><span style=\"font-weight: 400\">dialog task,<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Add a <\/span><em><span style=\"font-weight: 400\">Dialog Node<\/span><\/em><span style=\"font-weight: 400\">, <\/span><em><span style=\"font-weight: 400\">Bot Action Node<\/span><\/em><span style=\"font-weight: 400\"> with a <\/span><em><span style=\"font-weight: 400\">Script Node<\/span><\/em><span style=\"font-weight: 400\">, and a <\/span><em><span style=\"font-weight: 400\">Message Node<\/span><\/em><span style=\"font-weight: 400\"> as follows:<\/span>\n<ol>\n<li style=\"font-weight: 400\"><strong>Dialog Node<\/strong><span style=\"font-weight: 400\"> will invoke the Check Flight Status\u00a0 using the Entity Pre-Assignments to populate:<\/span>\n<ol>\n<li style=\"font-weight: 400\"><strong>Flight Number<\/strong><span style=\"font-weight: 400\"> \u2013 entity required in the Check Flight Status\u00a0 dialog set to <\/span><code><span style=\"font-weight: 400\">context.entities.currentflight<\/span><\/code><\/li>\n<li style=\"font-weight: 400\"><strong>Add Key\/Value<\/strong><span style=\"font-weight: 400\"> \u2013 pair <\/span><code><span style=\"font-weight: 400\">context.type<\/span><\/code><span style=\"font-weight: 400\"> and <\/span><em><span style=\"font-weight: 400\">change <\/span><\/em><span style=\"font-weight: 400\">identifying the Change Flight\u00a0 intent. This will be checked in the Check Flight Status\u00a0 dialog as shown in the next step to modify the flow.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Ensure that the <\/span><strong>Transition Option<\/strong><span style=\"font-weight: 400\"> is set to Initiate Check_Flight_Status,., once complete return to this node.<\/span><span style=\"font-weight: 400\"><br \/><\/span><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\/20221004154152\/invoke-flightstatus-from-changeflight.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-47895\" src=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154152\/invoke-flightstatus-from-changeflight.png\" alt=\"\" width=\"332\" height=\"738\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154152\/invoke-flightstatus-from-changeflight.png 458w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154152\/invoke-flightstatus-from-changeflight-135x300.png 135w\" sizes=\"auto, (max-width: 332px) 100vw, 332px\" \/><\/a><\/span><\/li>\n<\/ol>\n<\/li>\n<li style=\"font-weight: 400\"><strong>Message Node<\/strong><span style=\"font-weight: 400\"> to display a message that the new flight is not available to book. Connect this message back to the <\/span><strong>New Flight<\/strong><span style=\"font-weight: 400\"> Entity node, so that the user be prompted to select a different flight.<\/span><\/li>\n<li style=\"font-weight: 400\"><strong>Script Node<\/strong><span style=\"font-weight: 400\"> \u2013 <\/span><em><span style=\"font-weight: 400\">CheckStatus to check the status of the new flight to change to, <\/span><\/em><span style=\"font-weight: 400\">and proceed accordingly. The Status of the new flight is obtained from a BotContext variable that will be populated by the Check Flight Status dialog task.\u00a0<\/span><\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p style=\"padding-left: 80px\"><strong>JavaScript:<br \/><\/strong><strong><br \/><\/strong><code><span style=\"font-weight: 400\">var nextStep = \u201c\u201d;<br \/><\/span><span style=\"font-weight: 400\">if (context.session.BotUserSession.Status &gt;= context.entities.seat)<br \/><\/span><span style=\"font-weight: 400\">\u00a0\u00a0\u00a0nextStep = \u201cupdate\u201d;<br \/><\/span><span style=\"font-weight: 400\">context.nextStep = nextStep;<br \/><a ref=\"magnificPopup\" href=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154148\/getstatus-scriptnode.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-47892\" src=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154148\/getstatus-scriptnode.png\" alt=\"\" width=\"528\" height=\"292\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154148\/getstatus-scriptnode.png 1009w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154148\/getstatus-scriptnode-300x166.png 300w\" sizes=\"auto, (max-width: 528px) 100vw, 528px\" \/><\/a><\/span><\/code><\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li style=\"font-weight: 400\"><strong>Connection Settings<\/strong><span style=\"font-weight: 400\"> Bot Action Connections should indicate to proceed to UpdateBooking in case the new flight is available (if the <\/span><code><span style=\"font-weight: 400\">context.nextStep<\/span><\/code><span style=\"font-weight: 400\"> is <\/span><em><span style=\"font-weight: 400\">updated<\/span><\/em><span style=\"font-weight: 400\"> from the above script) else go to the message node.<br \/><a ref=\"magnificPopup\" href=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154208\/status-actionnode-connections.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-47904\" src=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154208\/status-actionnode-connections.png\" alt=\"\" width=\"514\" height=\"496\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154208\/status-actionnode-connections.png 788w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154208\/status-actionnode-connections-300x289.png 300w\" sizes=\"auto, (max-width: 514px) 100vw, 514px\" \/><\/a><\/span><span style=\"font-weight: 400\"><br \/><\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><span style=\"font-weight: 400\">Next, let us modify the <\/span><strong>Check Flight Status <\/strong><span style=\"font-weight: 400\">\u00a0dialog to check for the <\/span><em><span style=\"font-weight: 400\">change <\/span><\/em><span style=\"font-weight: 400\">tag and populate the Bot Context variable if needed.<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Open the <\/span><strong>Check Flight Status <\/strong><span style=\"font-weight: 400\">dialog<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Open the <\/span><strong>Flight Status Confirmation <\/strong><span style=\"font-weight: 400\">(the final message node) node<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Under <\/span><strong>Bot Responses<\/strong><span style=\"font-weight: 400\"> section open the <\/span><strong>Manage Responses<\/strong><span style=\"font-weight: 400\"> dialog<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400\">Add the following <\/span><strong>JavaScript<\/strong><span style=\"font-weight: 400\">. This script populates the Bot Context variable and updates the seat\u00a0 if the request comes from the Change Flight task, else displays the usual flight status message.<\/span><\/p>\n<p><code><span style=\"font-weight: 400\">if (context.type == \"change\")<br \/><\/span><span style=\"font-weight: 400\">\u00a0\u00a0BotUserSession.put('Sear', context.CheckFlightStatus.response.body.Seat);<br \/><\/span><span style=\"font-weight: 400\">else<br \/><\/span><span style=\"font-weight: 400\">\u00a0\u00a0print ('The status of your flight is<\/span> <span style=\"font-weight: 400\">\u00a0' + context.CheckFlightStatus.response.body.Status);<\/span><\/code><\/p>\n<p><span style=\"font-weight: 400\">Talk to the Bot to see the changes in action.<\/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<h2><span class=\"ez-toc-section\" id=\"User_triggered_context_switching\"><span style=\"font-weight: 400\">User triggered context switching<\/span><\/span><\/h2>\n<p><span style=\"font-weight: 400\">While asking to change their flight, users might ask for the status of the flight that they want to switch to.\u00a0<\/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\/20221004154219\/user-context-switch.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-47914\" src=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154219\/user-context-switch.png\" alt=\"\" width=\"510\" height=\"482\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154219\/user-context-switch.png 680w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154219\/user-context-switch-300x284.png 300w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/a><\/span><\/p>\n<p><span style=\"font-weight: 400\">Let us see how this can be achieved. We will be using historic tags \u2013 system generated and custom tags. The historic tags get transmitted from one intent to another automatically.<\/span><\/p>\n<p><strong>Steps<\/strong><span style=\"font-weight: 400\">:<\/span><\/p>\n<p><span style=\"font-weight: 400\">First, modify the Change Flight task\u00a0 to populate the appropriate tags and configure the Hold and Resume settings:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Open the <\/span><strong>Change Flight <\/strong><span style=\"font-weight: 400\">\u00a0dialog<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Open the properties panel of <\/span><strong>CurrentFlight<\/strong><span style=\"font-weight: 400\">entity<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">From the <\/span><strong>NLP<\/strong><span style=\"font-weight: 400\"> tab, set the <\/span><em><span style=\"font-weight: 400\">Auto emit the entity values captured<\/span><\/em><span style=\"font-weight: 400\"> flag. This will ensure that the Current Flight\u00a0 number is saved in the context. Since it is the first value being emitted by this intent, it would be positioned next to the intent name in the tags array<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Next, open the <\/span><strong>Manage Interruptions<\/strong><span style=\"font-weight: 400\"> dialog from the <\/span><strong>more<\/strong><span style=\"font-weight: 400\"> (vertical ellipses) option<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Customize the settings for this task as <\/span><strong>Allow hold and resume<\/strong><span style=\"font-weight: 400\"> and set the <\/span><strong>Hold Options<\/strong><span style=\"font-weight: 400\"> to <\/span><em><span style=\"font-weight: 400\">Hold the current task and resume back once the new task is completed<\/span><\/em><span style=\"font-weight: 400\"> and the <\/span><strong>Resume Options<\/strong><span style=\"font-weight: 400\"> to <\/span><em><span style=\"font-weight: 400\">Resume the on hold task without any specific message to the user<\/span><\/em><span style=\"font-weight: 400\">.<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400\">Next, modify the Check Flight Status dialog to capture the data sent by the Change Flight task<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Open the <\/span><strong>Check Flight Status <\/strong><span style=\"font-weight: 400\">\u00a0dialog<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Add a <\/span><strong>Script node<\/strong><span style=\"font-weight: 400\"> \u2013 <\/span><em><span style=\"font-weight: 400\">CheckFlightNumber<\/span><\/em><span style=\"font-weight: 400\">to check if the Flight Number is available in the context, after the Intent node<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400\">Add the following <\/span><strong>script<\/strong><span style=\"font-weight: 400\">. This script checks for the Intent \u201cChange Flight\u201d, captures the flight number and populates the FlightNumber entity with that value.<\/span><span style=\"font-weight: 400\"><br \/><\/span><code><span style=\"font-weight: 400\">var i = koreUtil._.indexOf(context.historicTags[0].tags, 'Change Flight'); <\/span><\/code><span style=\"font-weight: 400\"><code>context.entities.FlightNumber = context.historicTags[0].tags[i+1]<\/code><br \/><\/span><\/p>\n<p><span style=\"font-weight: 400\">Run the VA and see the changes taking effect.<\/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<h2><span class=\"ez-toc-section\" id=\"Follow_up_Intents\"><span style=\"font-weight: 400\">Follow up Intents<\/span><\/span><\/h2>\n<p><span style=\"font-weight: 400\">The <\/span><strong>Update Booking <\/strong><span style=\"font-weight: 400\">intent should be invoked only through the Change Flight task. There are two things that can be done:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Restricting user access:<\/span><\/li>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Open the <\/span><strong>Update Booking <\/strong><span style=\"font-weight: 400\">dialog<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Access <\/span><strong>Dialog Settings<\/strong><span style=\"font-weight: 400\"> from the <\/span><strong>more<\/strong><span style=\"font-weight: 400\"> (vertical ellipses) option<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Set <\/span><strong>Options<\/strong><span style=\"font-weight: 400\"> to <\/span><em><span style=\"font-weight: 400\">Sub intent only<\/span><\/em><span style=\"font-weight: 400\"> dialog<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">This will restrict user access to this dialog, this dialog will not be available either directly or from the Help option.<\/span><\/li>\n<\/ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Restricting task access:<\/span><\/li>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Open the <\/span><strong>Update Booking <\/strong><span style=\"font-weight: 400\">dialog<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Open the <\/span><strong>UpdateBooking <\/strong><span style=\"font-weight: 400\">intent, <\/span><strong>NLP Properties<\/strong><span style=\"font-weight: 400\"> tab<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Under the <\/span><strong>Manage Context<\/strong><span style=\"font-weight: 400\"> section add \u201c<\/span><em><span style=\"font-weight: 400\">Change<\/span><\/em><span style=\"font-weight: 400\">\u201d to the <\/span><strong>Intent Preconditions<\/strong><span style=\"font-weight: 400\">.<\/span><span style=\"font-weight: 400\"><br \/><\/span><span style=\"font-weight: 400\">This will ensure that this dialog will be executed only if Change exists in the context.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Open <\/span><strong>the Change Flight <\/strong><span style=\"font-weight: 400\">\u00a0dialog<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Open the <\/span><strong>ChangeFlight <\/strong><span style=\"font-weight: 400\">intent node, <\/span><strong>NLP Properties<\/strong><span style=\"font-weight: 400\"> tab<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Under the <\/span><strong>Manage Context<\/strong><span style=\"font-weight: 400\"> section add \u201c<\/span><em><span style=\"font-weight: 400\">Change<\/span><\/em><span style=\"font-weight: 400\">\u201d to the <\/span><strong>Context Output<\/strong><span style=\"font-weight: 400\"> as expected by the Update Booking dialog<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Now the Update Booking can not be triggered by any other dialog.<\/span><\/li>\n<\/ol>\n<\/ol>\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=\"Sharing_context_across_FAQs\"><span style=\"font-weight: 400\">Sharing context across FAQs<\/span><\/span><\/h2>\n<p><span style=\"font-weight: 400\">The following Knowledge Graph is used in this scenario:<\/span><\/p>\n<p><strong>Primary Question<\/strong><span style=\"font-weight: 400\">: What are the compensations for a canceled flight?<\/span><\/p>\n<p><strong>Primary Question<\/strong><span style=\"font-weight: 400\">: What are the charges for changing flights?<\/span><\/p>\n<p><strong>Alternate<\/strong><span style=\"font-weight: 400\">: What are the charges?<\/span><\/p>\n<p><a ref=\"magnificPopup\" href=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154203\/kg-context-sharing.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-47901\" src=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154203\/kg-context-sharing-1024x531.png\" alt=\"\" width=\"640\" height=\"332\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154203\/kg-context-sharing-1024x531.png 1024w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154203\/kg-context-sharing-300x156.png 300w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004154203\/kg-context-sharing.png 1643w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400\">In the second question, the word <\/span><em><span style=\"font-weight: 400\">charges<\/span><\/em><span style=\"font-weight: 400\"> is in the context of changing flights. To enable it, all you need is to set a flag. For each question answered the Context tags are set automatically, we just instruct the Platform to use them appropriately.<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Go to <\/span><strong>Natural Language &gt; Thresholds &amp; Configurations<\/strong><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Expand the <\/span><strong>Knowledge Graph <\/strong><span style=\"font-weight: 400\">tab<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Scroll down and set the <\/span><strong>Qualify Contextual Paths<\/strong><span style=\"font-weight: 400\"> tag. With this setting, the KG engine will qualify a question if any of the available context tags are part of that particular FAQ path.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Run the assistant and see the effect.<\/span><\/li>\n<\/ol>\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=\"Sharing_context_between_intents_and_FAQs\"><span style=\"font-weight: 400\">Sharing context between intents and FAQs<\/span><\/span><\/h2>\n<p><span style=\"font-weight: 400\">The following Knowledge Graph is used in this scenario:<\/span><\/p>\n<p><strong>Primary Question<\/strong><span style=\"font-weight: 400\">: What are your flight change rates?<\/span><\/p>\n<p><strong>Alternate<\/strong><span style=\"font-weight: 400\">: what are the rates?<\/span><\/p>\n<p><span style=\"font-weight: 400\">The use case here is that the user might, while changing flights, ask about the rates. This should result in the appropriate FAQ being triggered to answer the query.<\/span><\/p>\n<p><span style=\"font-weight: 400\">The default setting for the Interruption Behavior for FAQs will ensure that the FAQs are attended to while a Dialog Task is in progress<\/span><\/p>\n<p><span style=\"font-weight: 400\">But this will not solve the use case described. It would answer the direct question \u2013 \u201c<\/span><em><span style=\"font-weight: 400\">What are the flight change rates<\/span><\/em><span style=\"font-weight: 400\">\u201d but not \u201c<\/span><em><span style=\"font-weight: 400\">What are the rates<\/span><\/em><span style=\"font-weight: 400\">\u201d. The reason being the FAQ not picking the context. To ensure that the context is picked by the FAQ:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">The <\/span><strong>Change Flight <\/strong><span style=\"font-weight: 400\">task is already emitting the <\/span><em><span style=\"font-weight: 400\">change <\/span><\/em><span style=\"font-weight: 400\">tag, the same will be used in this case<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Go to <\/span><strong>Natural Language<\/strong> <strong>&gt;<\/strong> <strong>Thresholds &amp; Configurations<\/strong><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Expand the <\/span><strong>Knowledge Graph <\/strong><span style=\"font-weight: 400\">tab<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Scroll down and set the <\/span><strong>Qualify Contextual Paths<\/strong><span style=\"font-weight: 400\"> tag (if not already set as per the previous use case)<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Run the assistant and see the changes taking effect.<\/span><\/li>\n<\/ol>\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","protected":false},"excerpt":{"rendered":"<p>In this Use Case, we will explore a scenario in a Travel Planning Assistant, where, sharing the context across intents, FAQs help in improving the user experience and the assistant\u2019s efficiency. Also, we will be looking at how the context can be used within a dialog flow to determine the sequence of events. For details&#8230;<\/p>\n","protected":false},"author":27,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[197],"tags":[],"class_list":["post-48011","post","type-post","status-publish","format-standard","hentry","category-travel-planing-assistant"],"_links":{"self":[{"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/posts\/48011","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\/27"}],"replies":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/comments?post=48011"}],"version-history":[{"count":3,"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/posts\/48011\/revisions"}],"predecessor-version":[{"id":48083,"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/posts\/48011\/revisions\/48083"}],"wp:attachment":[{"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/media?parent=48011"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/categories?post=48011"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/tags?post=48011"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}