{"id":48053,"date":"2022-10-04T18:10:14","date_gmt":"2022-10-04T17:10:14","guid":{"rendered":"https:\/\/developer.kore.ai\/v10-1\/?p=48053"},"modified":"2022-10-04T19:23:07","modified_gmt":"2022-10-04T18:23:07","slug":"travel-va-using-global-variables","status":"publish","type":"post","link":"https:\/\/developer.kore.ai\/v10-1\/docs\/bots\/how-tos\/travel-planing-assistant\/travel-va-using-global-variables\/","title":{"rendered":"Travel VA: Using Global Variables"},"content":{"rendered":"<p><span style=\"font-weight: 400\">The Kore.ai XO Platform allows you to declare and use variables within the assistants you build. These variables can be used to capture values that are commonly used by different tasks, nodes, and other elements.<\/span><\/p>\n<p><span style=\"font-weight: 400\">In this Use Case we will explore a scenario in a <\/span><span style=\"font-weight: 400\">Travel Planning Assistant<\/span><span style=\"font-weight: 400\">, where Variables can be used. We will see how Global Variables can be used to pass API endpoints and change them easily when migrating from development to testing to production environments.<\/span><\/p>\n<p><span style=\"font-weight: 400\">For details on what Variables are and how they are implemented in the Kore.ai XO Platform, <\/span><a href=\"https:\/\/developer.kore.ai\/v10-1\/docs\/bots\/bot-settings\/bot-management\/using-bot-variables\/\"><span style=\"font-weight: 400\">refer here<\/span><\/a><span style=\"font-weight: 400\">. For a use case with Content Variables, <\/span><a href=\"https:\/\/developer.kore.ai\/v10-1\/docs\/bots\/how-tos\/how-to-use-content-variables\/\"><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\">In our Travel Planning Assistant, we have two tasks:<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Check Flight Status<\/span><span style=\"font-weight: 400\">, which makes a service call and retrieves the flight status based on a flight number provided by the user.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Update Booking, which makes a service call to update user bookings based on the booking number and type of update.<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400\">Both the above tasks call the same service and the service API endpoint changes for development, testing, and production environments.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Changing the service call in both the Dialog Tasks is cumbersome and can lead to errors, if the change is not done properly.<\/span><\/p>\n<p><span style=\"font-weight: 400\">In this document, we will see how Global Variable can be used to store the API endpoint and use it for the service calls.<\/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<p><span style=\"font-weight: 400\">To go through these configurations, you need to know at least the basics of <\/span><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\"><span style=\"font-weight: 400\">building a Virtual Assistant<\/span><\/a><span style=\"font-weight: 400\">. This is because your assistant needs to have been already built when you begin working on your variables.<\/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=\"Implementation\"><span style=\"font-weight: 400\">Implementation<\/span><\/span><\/h1>\n<p><span style=\"font-weight: 400\">Declaring a Global Variable to hold the API endpoint will help make the transition easier and faster.<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Open the Travel Planning Assistant.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Select the <\/span><strong>Build<\/strong><span style=\"font-weight: 400\"> tab from the top menu.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">From <\/span><strong>Configurations <\/strong><span style=\"font-weight: 400\">select the <\/span><strong>Environment Variables<\/strong><span style=\"font-weight: 400\"> section.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Click <\/span><strong>Add Variable<\/strong><span style=\"font-weight: 400\"> to open the corresponding window.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Enter <\/span><strong>Variable Name<\/strong><span style=\"font-weight: 400\"> and <\/span><strong>Variable Value<\/strong><span style=\"font-weight: 400\">. For this use case, we are calling the Variable <\/span><em><span style=\"font-weight: 400\">bookingURL<\/span><\/em><span style=\"font-weight: 400\">, and for value, we are entering the <\/span><em><span style=\"font-weight: 400\">Service API call endpoint.<\/span><\/em><\/li>\n<li style=\"font-weight: 400\"><strong>Save<\/strong><span style=\"font-weight: 400\">.<br \/><a ref=\"magnificPopup\" href=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004133651\/add-var-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-47842\" src=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004133651\/add-var-1-1024x450.png\" alt=\"\" width=\"640\" height=\"281\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004133651\/add-var-1-1024x450.png 1024w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004133651\/add-var-1-300x132.png 300w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004133651\/add-var-1.png 1947w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><br \/><\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Now open the <\/span><strong>Check Flight Status <\/strong><span style=\"font-weight: 400\">Dialog Task.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Select the <\/span><strong>Get Status <\/strong><span style=\"font-weight: 400\">Service Node.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Click <\/span><strong>Edit Request<\/strong><span style=\"font-weight: 400\"> under the <\/span><strong>Request Definition<\/strong><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Replace the request URL with the Global Variable created above. using the <\/span><span style=\"font-weight: 400\">env<\/span><span style=\"font-weight: 400\"> prefix followed by any parameters needed. In this case:<\/span><span style=\"font-weight: 400\"><br \/><\/span><code><span style=\"font-weight: 400\">{{env.bookingURL}}{{context.entities.FlightNumber}}<\/span><\/code><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\/20221004133640\/service-request.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-47839\" src=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004133640\/service-request-1024x203.png\" alt=\"\" width=\"640\" height=\"127\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004133640\/service-request-1024x203.png 1024w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004133640\/service-request-300x59.png 300w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v10-1\/wp-content\/uploads\/sites\/35\/20221004133640\/service-request.png 1921w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Repeat for the <\/span><strong>Update Booking <\/strong><span style=\"font-weight: 400\">Dialog Task.<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Now when you Export and Import the assistant to another environment, all you need to worry about is to change the value of the Global Variable and the changes will be effective in both the Dialog Tasks.<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400\"><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><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Kore.ai XO Platform allows you to declare and use variables within the assistants you build. These variables can be used to capture values that are commonly used by different tasks, nodes, and other elements. In this Use Case we will explore a scenario in a Travel Planning Assistant, where Variables can be used. We&#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-48053","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\/48053","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=48053"}],"version-history":[{"count":2,"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/posts\/48053\/revisions"}],"predecessor-version":[{"id":48088,"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/posts\/48053\/revisions\/48088"}],"wp:attachment":[{"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/media?parent=48053"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/categories?post=48053"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developer.kore.ai\/v10-1\/wp-json\/wp\/v2\/tags?post=48053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}