{"id":18936,"date":"2019-03-28T07:55:19","date_gmt":"2019-03-28T07:55:19","guid":{"rendered":"https:\/\/developer.kore.ai\/v8-0\/?p=18936"},"modified":"2021-03-25T16:52:20","modified_gmt":"2021-03-25T16:52:20","slug":"creating-a-simple-bot","status":"publish","type":"post","link":"https:\/\/developer.kore.ai\/v8-0\/docs\/bots\/chatbot-overview\/creating-a-simple-bot\/","title":{"rendered":"Creating a Simple Bot"},"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>After you have <a href=\"\/docs\/bots\/getting-started\/how-to-open-bot-builder\/\">signed up<\/a> with the Kore.ai Bots platform, the next step is to create a Bot. Before you create a Bot, it is recommended to go through the basics of Bot building from <a href=\"\/docs\/bots\/getting-started\/getting-started-bots\/\" target=\"_blank\" rel=\"noopener noreferrer\">this link<\/a>.<\/p>\n<p>You can follow the steps given in this document to build the Bot at your own pace. Or use the Guided Help for the step-by-step Bot creation process.<\/p>\n<p>To access the Guided Help, follow the below steps:<\/p>\n<ol>\n<li>Log in to your Bot account.<\/li>\n<li>On the <strong>Bot Builder Landing Page<\/strong>, click <strong>Help <\/strong>on the top-right.<\/li>\n<li>On the Page Help window, click <strong>Guided Help<\/strong> next to <em>Build a &#8216;Hello world&#8217; bot with guided help<\/em>.<\/li>\n<li>A list of use cases is displayed. Click <strong>Get Started<\/strong> to proceed with a use case.<\/li>\n<li>This document helps you with the <strong>Dialog Task Bot<\/strong> (Flight Status Bot).<\/li>\n<p><a ref=\"magnificPopup\" href=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v8-0\/wp-content\/uploads\/sites\/16\/20201201080130\/GuidedHelp.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v8-0\/wp-content\/uploads\/sites\/16\/20201201080130\/GuidedHelp.png\" alt=\"\" width=\"693\" height=\"765\" class=\"alignnone size-full wp-image-25968\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v8-0\/wp-content\/uploads\/sites\/16\/20201201080130\/GuidedHelp.png 693w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/v8-0\/wp-content\/uploads\/sites\/16\/20201201080130\/GuidedHelp-272x300.png 272w\" sizes=\"auto, (max-width: 693px) 100vw, 693px\" \/><\/a><\/ol>\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<h3><span class=\"ez-toc-section\" id=\"Bot_Overview\">Bot Overview<\/span><\/h3>\n<p>This Bot gives you the flight status arriving\/departing from Los Angeles International Airport depending upon the user selection.<\/p>\n<p>This Bot can:<\/p>\n<ul>\n<li>Ask the user if they want to know about the arrivals or departures.<\/li>\n<li>Make a service call to an API to fetch the details of flights arriving and departing out of the airport.<\/li>\n<li>Display the flight numbers based on the user preference of Arrival or Departure.<\/li>\n<li>Request the user to select a flight number.<\/li>\n<li>Display the status details of the selected flight.<\/li>\n<li>Handle any errors.<\/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<h3><span class=\"ez-toc-section\" id=\"Build_the_Bot\">Build the Bot<\/span><\/h3>\n<p>You can create a Standard Bot. To create, follow the below steps:<\/p>\n<ol>\n<li>Log in to your Kore.ai Bots platform account.<\/li>\n<li>On the Bots landing page, click <strong>+ New Bot<\/strong> on the top-right.<\/li>\n<li>On the Create New Bot window, enter the Bot details:\n<ul>\n<li><strong>Bot Name<\/strong> &#8211; Give a name to your Bot. For example, <em>Airport Bot<\/em>. If the name is already used, try something else.<\/li>\n<li>Select <em>English <\/em>from the <strong>Default Bot Language <\/strong>drop-down list and <em>Standard Bot from <\/em>the <strong>Bot Type<\/strong> drop-down list.<\/li>\n<\/ul>\n<\/li>\n<li>Click <strong>Create<\/strong>.<\/li>\n<\/ol>\n<p><a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-creation.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18956\" src=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-creation.png\" alt=\"\" width=\"500\" height=\"468\" \/><\/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>\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=\"Create_a_Dialog_Task\">Create a Dialog Task<\/span><\/h3>\n<p>After the Bot creation, you are directed to the Bot Summary page. The first step is to add an <em>Intent Dialog<\/em>. Intent Dialog is the first step in the user-bot conversation flow.<\/p>\n<ol>\n<li>On the <strong>Tasks<\/strong> widget, click <strong>+ New Task<\/strong>\u00a0and select <strong>Dialog Task<\/strong>.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-addtask.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18957\" src=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-addtask.png\" alt=\"\" width=\"500\" height=\"241\" \/><\/a><\/li>\n<li>On the Bot Tasks page, enter the following details:\n<ul>\n<li><strong>Intent Name<\/strong> &#8211; Enter the Intent name, this is the phrase that triggers the dialog. The intent name must be simple and not more than 3-4 words. For example, <em>Get flight status<\/em>.<\/li>\n<li>\u00a0Under the <strong>More Options<\/strong>, you can add a <strong>description<\/strong> and other dialog related details. Let us retain the default settings.<\/li>\n<\/ul>\n<\/li>\n<li>Click <strong>Create &amp; Proceed.<\/strong><br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-intent.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18958\" src=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-intent.png\" alt=\"\" width=\"820\" height=\"461\" \/><\/a><\/li>\n<li>On the User Intent window, by default, the <strong>Component Properties<\/strong> tab is selected. Let us retain the default properties.<\/li>\n<li>Close the User Intent window.<\/li>\n<\/ol>\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<h3><span class=\"ez-toc-section\" id=\"Create_a_User_Preference_Entity_Node\">Create a User Preference Entity Node<\/span><\/h3>\n<p>An Entity node is typically used to gather information from the user. Let us use it to capture the user preference of arrival or departure details.<\/p>\n<ol>\n<li>Click the <strong>+<\/strong> icon next to the <strong>User Intent<\/strong> node.<\/li>\n<li>Select <strong>Entity<\/strong> &gt; <strong>New entity node +<\/strong>.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-addentity.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18960\" src=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-addentity.png\" alt=\"\" width=\"500\" height=\"270\" \/><\/a><\/li>\n<li>On the Entity window, by default, the <strong>Component Properties <\/strong>tab is selected.<\/li>\n<li>Under the <strong>General Settings<\/strong> section, enter the following details:\n<ul>\n<li><strong>Name<\/strong>: <em>Preference<\/em><\/li>\n<li><strong>Display Name<\/strong>: <em>Preference\u00a0<\/em><\/li>\n<li><strong>Type<\/strong>: Select <em>List of Items (enumerated)<\/em> from the drop-down list. You can provide a list of values that the user can select. To add a list of values,\n<ul>\n<li style=\"list-style-type: none\">\n<ul>\n<li>Click the <strong>Settings <\/strong>icon next to the field.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-addlov.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18961\" src=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-addlov.png\" alt=\"\" width=\"500\" height=\"259\" \/><\/a><\/li>\n<li>Select the <strong>Static List<\/strong>\u00a0option.<\/li>\n<li>Under the <strong>Keys &amp; Values To Use<\/strong> section, enter the <strong>Display Name <\/strong>as\u00a0<em>Arrival<\/em> and <em>Departure <\/em>in separate rows<em>. <\/em><strong>Value<\/strong> and <strong>Synonyms<\/strong> columns auto-populates, leave them as is.<\/li>\n<li>Click <strong>Save<\/strong>.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-addlovlist.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18962\" src=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-addlovlist.png\" alt=\"\" width=\"820\" height=\"461\" \/><\/a><\/li>\n<li>Go back to the Entity window.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>Under the<strong> User Prompts<\/strong> section, enter the following text:<br \/>\n<code>Hello {{context.session.UserContext.firstName}}! Welcome to *Los Angeles International Airport*. I can help you with flight Arrival\/Departure information. Please select your preference.<\/code><br \/>\n<strong>Note<\/strong>: The context variable retrieves the user&#8217;s first name. Also, markdown is used for the airport name to appear in bold.<\/li>\n<li>Click <strong>Enter<\/strong> to save.<\/li>\n<li>Under the<strong> Display List of Values <\/strong>section, select <em>Yes, use channel-specific standard formatting for default messages and show the available list of values to the end-user <\/em>option. This displays the list of values as a button template in supported channels.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-adduserprompt.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18963\" src=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-adduserprompt.png\" alt=\"\" width=\"500\" height=\"349\" \/><\/a><\/li>\n<\/ul>\n<\/li>\n<li>Close the <strong>Entity <\/strong>window.<\/li>\n<\/ol>\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<h3><span class=\"ez-toc-section\" id=\"Create_a_Service_Node\">Create a Service Node<\/span><\/h3>\n<p>A Service node allows you to make a backend API call. Here the service node is used to call an API to get flight information for flights <em>From and To <\/em>LAX airport. In this tutorial, a dummy API setup is used.<\/p>\n<ol>\n<li>Click the <strong>+<\/strong> icon next to the <strong>Preference\u00a0Entity<\/strong> node.<\/li>\n<li>Select <strong>Service <\/strong>&gt; <strong>New service node +<\/strong>.\n<ul>\n<li>The service node is used to make a backend API call to get flight information for flights <em>From <\/em>and <em>To <\/em>LAX airport.<\/li>\n<\/ul>\n<\/li>\n<li>On the Service window, by default, the <strong>Component Properties <\/strong>tab is selected.<\/li>\n<li>Under the <strong>General Settings<\/strong> section, enter the following details:\n<ul>\n<li><strong>Name<\/strong>: <em>Fetchflightdetails<\/em><\/li>\n<li><strong>Display Name<\/strong>: <em>Fetch Flight Details<\/em><\/li>\n<li><strong>Service Type<\/strong>: <em>Custom Service<\/em><\/li>\n<li><strong>Type<\/strong>: <em>Webservice<\/em><\/li>\n<li><strong>Sub Type<\/strong>: <em>REST<\/em><\/li>\n<li>Under the <strong>Request Definition<\/strong> section, Click <strong>DEFINE REQUEST<\/strong>.<\/li>\n<li>On the <strong>Define Request <\/strong>page<strong>,<\/strong> enter the following details:\n<ul>\n<li><strong>Request Type<\/strong> &#8211; <em>GET<\/em><\/li>\n<li><strong>Request URL<\/strong> &#8211; <code>http:\/\/5e85a56644467600161c6579.mockapi.io\/FlightDetails<\/code><br \/>\nThis API does not require any Auth or Header Parameters.<\/li>\n<li>Click the <strong>Test Request<\/strong> tab.\n<ul>\n<li>Click <strong>Test<\/strong> on the top-right.<\/li>\n<li>Wait for the test to complete and you get a Status Code 200.<\/li>\n<li>Click <strong>Save as Sample Response<\/strong>.<\/li>\n<li>Click <strong>Save<\/strong>.<\/li>\n<\/ul>\n<p><a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-addservice.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18965\" src=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-addservice.png\" alt=\"\" width=\"820\" height=\"461\" \/><\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>Close the <strong>Service <\/strong>window.<\/li>\n<\/ol>\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<h3><span class=\"ez-toc-section\" id=\"Create_a_Flight_Selection_Entity_Node\">Create a Flight Selection Entity Node<\/span><\/h3>\n<p>This Entity node is to capture the Flight Number for which the user wants the status details.<\/p>\n<ol>\n<li>Click the <strong>+<\/strong> icon next to the <strong>Fetch Flight Details<\/strong> <strong>Service<\/strong> node.<\/li>\n<li>Select <strong>Entity<\/strong> &gt; <strong>New entity node +<\/strong>.\n<ul>\n<li>The Entity\u00a0node is required to capture the flight number selected by the user.<\/li>\n<\/ul>\n<\/li>\n<li>On the Entity window, by default, the <strong>Component Properties <\/strong>tab is selected.<\/li>\n<li>Under the <strong>General Settings<\/strong> section, enter the following details:\n<ul>\n<li><strong>Name<\/strong>: <em>SelectFlight<\/em><\/li>\n<li><strong>Display Name<\/strong>: <em>Select Flight<\/em><em>\u00a0<\/em><\/li>\n<li><strong>Type<\/strong>: <em>String\u00a0<\/em>(users can write a custom script to convert the API string output to a list of values in the following steps, this is the requirement of the dummy API used)<\/li>\n<\/ul>\n<\/li>\n<li>Under the<strong> User Prompts <\/strong>section, enter the following text:<br \/>\n<code>Please provide the flight number.<\/code><\/p>\n<ul>\n<li><strong>Manage Prompts:<\/strong> Users can define a specific prompt for the Web SDK channel.<\/li>\n<li>Click <strong>MANAGE PROMPT MESSAGES<\/strong>.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-manageprompt.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18966\" src=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-manageprompt.png\" alt=\"\" width=\"500\" height=\"291\" \/><\/a><\/li>\n<li>Click <strong>ADD PROMPT MESSAGE<\/strong>.<\/li>\n<li>On the New Prompt Message window, select <em>Web\/Mobile client<\/em> from the <strong>Channel<\/strong> drop-down list.<\/li>\n<li>Under the <strong>Message <\/strong>section, click the <strong>JavaScript <\/strong>tab.<\/li>\n<li>Enter the following <strong>JavaScript<\/strong>. The JavaScript extracts flight numbers matching user preference from the string output from API call and displays them in the <em>Quick Reply<\/em>\u00a0format.\n<pre>var data = context.Fetchflightdetails.response.body.details;\r\ncontext.flights = [];\r\ncontext.info;\r\nvar msg;\r\nfor (var i = 0; i &lt; data.length; i++)\r\n{\r\n    if (context.entities.Preference == data[i].Type)\r\n    {\r\n        var details = {\r\n            \"Airlines\" : data[i].Airlines,\r\n            \"FlightNo\" : data[i].FlightNo,\r\n            \"Airport\" : data[i].Airport,\r\n            \"AirportName\" : data[i].AirportName,\r\n            \"Time\" : data[i].Time\r\n        };\r\n        context.flights.push(details);\r\n    }\r\n}\r\nvar message = {\r\n    \"type\" : \"template\",\r\n    \"payload\" : {\r\n       \"template_type\" : \"quick_replies\",\r\n       \"text\" : \"Here are the flights \" + context.entities.Preference + \" details for Los Angeles International Airport today. Please select the flight number to see details\",\r\n       \"quick_replies\" : []\r\n    }\r\n};\r\nfor (i=0; i &lt; context.flights.length; i++)\r\n{\r\n   var replies = {\r\n        \"content_type\":\"text\",\r\n        \"title\" : context.flights[i].FlightNo,\r\n        \"payload\" : context.flights[i].FlightNo\r\n    };\r\nmessage.payload.quick_replies.push(replies);\r\n}\r\nreturn JSON.stringify(message);<\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li>Click <b>Save<\/b>.<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-addprompt.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18967\" src=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-addprompt.png\" alt=\"\" width=\"820\" height=\"461\" \/><\/a><\/li>\n<li>Go back to Dialog Builder and close the Entity window.<\/li>\n<\/ol>\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<h3><span class=\"ez-toc-section\" id=\"Create_a_Script_Node\">Create a Script Node<\/span><\/h3>\n<p>A Script node is used to write custom JavaScript in the Dialog task. Here, users can use the script to extract the selected flight details. Later, users can add more functionality to this script.<\/p>\n<ol>\n<li>Click the <strong>+<\/strong> icon next to the <strong>Select Flight Entity<\/strong> node.<\/li>\n<li>Select <strong>Script<\/strong> &gt; <strong>New script node +<\/strong>.<\/li>\n<li>On the Script window, by default, the <strong>Component Properties <\/strong>tab is selected.<\/li>\n<li>Under the <strong>General Settings<\/strong> section, enter the following details:\n<ul>\n<li><strong>Name<\/strong>: <em>ValidateFlight<\/em><\/li>\n<li><strong>Display Name<\/strong>: <em>Validate Flight\u00a0<\/em><\/li>\n<\/ul>\n<\/li>\n<li>Under the <strong>Script Definition <\/strong>section, click <strong>Define Script<\/strong>.<\/li>\n<li>On the Add Script dialog box, copy the following JavaScript. This code extracts the details of the selected flight number.\n<pre>context.details;\r\nvar x = context.flights.length;\r\nfor (var l = 0; l &lt; x; l++)\r\n{\r\n\u00a0 \u00a0 if (context.entities.SelectFlight == context.flights[l].FlightNo)\r\n\u00a0 \u00a0 {\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0context.details = {\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \"Airlines\" : context.flights[l].Airlines,\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \"FlightNo\" : context.flights[l].FlightNo,\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \"Airport\" : context.flights[l].Airport,\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \"AirportName\" : context.flights[l].AirportName,\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \"Time\" :context.flights[l].Time\r\n\u00a0 \u00a0 \u00a0 \u00a0 };\r\n\u00a0 \u00a0 \u00a0 \u00a0 break;\r\n\u00a0 \u00a0 }\r\n}<\/pre>\n<\/li>\n<li>Click <strong>Save<\/strong>.<\/li>\n<li>Close the Script window.<\/li>\n<\/ol>\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<h3><span class=\"ez-toc-section\" id=\"Create_a_Message_Node\">Create a Message Node<\/span><\/h3>\n<p>A Message node is used to display a message from the Bot to the user. Here, users can use the Message node to show appropriate flight details, based on user preference.<\/p>\n<ol>\n<li>Click the <strong>+<\/strong> icon next to the <strong>Validate Flight Script<\/strong> node.<\/li>\n<li>Select <strong>Message<\/strong> &gt; <strong>New message node +<\/strong>.<\/li>\n<li>On the Message window, by default, the <strong>Component Properties <\/strong>tab is selected.<\/li>\n<li>Under the <strong>General Settings<\/strong> section, enter the following details:\n<ul>\n<li><strong>Name<\/strong>: <em>FlightDetails<\/em><\/li>\n<li><strong>Display Name<\/strong>: <em>Flight Details<\/em><em>\u00a0<\/em><\/li>\n<\/ul>\n<\/li>\n<li>Under the <strong>Bot Responses<\/strong> section, enter the following text:<br \/>\n<code>Here are your flight details.<\/code><\/li>\n<li>Click <strong>Enter<\/strong> to save<em>.<br \/>\n<\/em><\/li>\n<li><strong>Manage Prompts:<\/strong> Users can define a specific prompt for the Web SDK channel.\n<ul>\n<li>Click <strong>MANAGE RESPONSES<\/strong>.<\/li>\n<li>On the Manage Bot Responses page, click <strong>ADD BOT RESPONSE<\/strong>.<\/li>\n<li>Select <em>Web\/Mobile client<\/em> from the <strong>Channel<\/strong> drop-down list.<\/li>\n<li>Under the <strong>Message<\/strong> section, click the <strong>JavaScript <\/strong>tab.<\/li>\n<li>Copy the following JavaScript. The JavaScript is written to display the flight details in the <em>Table<\/em>\u00a0format.\n<pre>var message = {\r\n \"type\": \"template\",\r\n \"payload\": {\r\n \"template_type\": \"mini_table\",\r\n \"layout\": \"horizontal\",\r\n \"text\":\"Flight \" + context.entities.Preference + \" Information\" ,\r\n \"elements\": [\r\n {\r\n \"primary\":[[\"Flight No\"], [context.details.FlightNo, \"right\"]],\r\n \"additional\":[[\"Airlines\", context.details.Airlines],[\"From\",context.details.Airport],[\"Time\",context.details.Time],[\"Remarks\",\"On Time\"]]\r\n }\r\n ]\r\n}\r\n};\r\nprint(JSON.stringify(message));<\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<ol>\n<li style=\"list-style-type: none\">\n<ul>\n<li>Click <b>Save<\/b>.<\/li>\n<\/ul>\n<\/li>\n<li>Go back to the Message window.<\/li>\n<li>On the Message window, click the <strong>Connections <\/strong>tab.\n<ul>\n<li>From the drop-down list, change the default connection from <em>Not Connected <\/em>to <em>End of Dialog<\/em>.<\/li>\n<li>Click\u00a0<strong>Save<\/strong>.<\/li>\n<\/ul>\n<\/li>\n<li>Close the Message window.<\/li>\n<\/ol>\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<h4>Test the Bot<\/h4>\n<p>To test the Dialog task, you can use the <em>Talk to bot<\/em> option at the bottom right.<\/p>\n<ol>\n<li>Enter the utterance (intent name) <em>Get me the flight status.<\/em><\/li>\n<li>Follow the Bot instructions:\n<ul>\n<li>Select Arrival\/Departure<\/li>\n<li>Select Flight No<\/li>\n<li>See the flight details displayed in a tabular format.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-test1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18970\" src=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-test1.png\" alt=\"\" width=\"820\" height=\"461\" \/><\/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>\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=\"Add_Events\">Add Events<\/span><\/h3>\n<p>Currently, the Bot is waiting for user input on start. Also, the Bot can guide the user at the start of the conversation. For this, you can add an Event Handler to initiate this task every time a new connection is established from the Web\/Mobile SDK.<\/p>\n<ol>\n<li>Close the Dialog Builder and go to the Bot Tasks page.<\/li>\n<li>Hover over the Left Navigation pane, and select <strong>Natural Language<\/strong> &gt; <strong>Default Conversation <\/strong>&gt; <strong>Event Handlers<\/strong>.<\/li>\n<li>From the events list, click <strong>Configure\u00a0<\/strong>against the <strong>On Connect<\/strong> event.<\/li>\n<li>On the On Connect window, by default, the <strong>Initiate Task<\/strong> option is selected; retain it.<\/li>\n<li>From the drop-down list, select the <strong>Get Flight Status<\/strong> task.<\/li>\n<li>Click <strong>Save and Enable<\/strong>.<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<p><a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-addevent.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18972\" src=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-addevent.png\" alt=\"\" width=\"820\" height=\"461\" \/><\/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>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h4>Test the Bot<\/h4>\n<p>To test the Dialog task, you can use the <em>Talk to bot<\/em> option at the bottom right. Since the <em>onConnect<\/em> event is configured, the dialog is automatically initiated.<br \/>\nFollow the Bot instructions:<\/p>\n<ol>\n<li>Select Arrival\/Departure<\/li>\n<li>Instead of selecting Flight No, manually enter a number that does not exist on the list.<\/li>\n<li>You can see a generic message like <em>I am sorry, something went wrong and I had to discard your task<\/em>. Please retry&#8221;.<\/li>\n<\/ol>\n<p>In the next steps, you can see how to rectify this.<\/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<h3><span class=\"ez-toc-section\" id=\"Modify_Script_Node\">Modify Script Node<\/span><\/h3>\n<p>As the <strong>String<\/strong> type is used in the <strong>Select Flight<\/strong> entity, you can handle the scenario that the user, instead of selecting from the list, has manually entered an incorrect flight number. You can do this by displaying an appropriate message based on <strong>Connections<\/strong>.<br \/>\nIn this step, you can modify the script that you saved earlier to add verification of the user entry.<\/p>\n<ol>\n<li>Open the Dialog Builder page. You can do this either\n<ul>\n<li>From the Left Navigation pane, click <strong>Bot Tasks<\/strong> and select the <strong>Get Flight Status <\/strong>task.<\/li>\n<li>From the Left Navigation pane, click <strong>Dashboard &gt; Bot Summary<\/strong> select the <strong>Get Flight Status<\/strong> task.<\/li>\n<\/ul>\n<\/li>\n<li>Select <strong>ValidateFlight Script<\/strong> node.<\/li>\n<li>On the Validate Flight Script window, under the <strong>Script Definition<\/strong> section, click <strong>Define Script<\/strong>.<\/li>\n<li>On the Add Script dialog box, copy the following JavaScript and replace the existing code. You can add a valid tag to be set when the flight number entered by the user matches an entry returned by the API service call.\n<pre>context.valid = false;\r\ncontext.details;\r\nvar x = context.flights.length;\r\nfor (var l = 0; l &lt; x; l++)\r\n{\r\n\u00a0 \u00a0 if (context.entities.SelectFlight == context.flights[l].FlightNo)\r\n\u00a0 \u00a0 {\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0context.valid = true;\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0context.details = {\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \"Airlines\" : context.flights[l].Airlines,\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \"FlightNo\" : context.flights[l].FlightNo,\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \"Airport\" : context.flights[l].Airport,\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \"AirportName\" : context.flights[l].AirportName,\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \"Time\" :context.flights[l].Time\r\n\u00a0 \u00a0 \u00a0 \u00a0 };\r\n\u00a0 \u00a0 \u00a0 \u00a0 break;\r\n\u00a0 \u00a0 }\r\n}\r\nif (context.valid === false)\r\n{\r\n\u00a0 \u00a0 delete context.entities.SelectFlight;\r\n}<\/pre>\n<\/li>\n<li>Close the Validate Flight Script window.<\/li>\n<\/ol>\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<h3><span class=\"ez-toc-section\" id=\"Create_Conditional_Flow\">Create Conditional Flow<\/span><\/h3>\n<p>The following are the steps to add the conditional flow from the Validate Flight Script node. A new connection from this Script node to a new Message node is established. This is to display an error message from the Bot to the user and redirect to select the flight number again.<\/p>\n<h4>Create Error Message<\/h4>\n<ol>\n<li>Hover over the Validate Flight Script node.<\/li>\n<li>You can see an array of icons on the node.\n<ul>\n<li>Click the <strong>+<\/strong> icon. A new connection is created. From this new connection, create a new Bot message node.<\/li>\n<li>Select <strong>Message<\/strong> &gt;\u00a0<strong>New message node +<\/strong>.<\/li>\n<li>On the Message window, by default, the <strong>Component Properties <\/strong>tab is selected.<\/li>\n<li>Under the <strong>General Settings<\/strong> section, enter the following details:\n<ul>\n<li><strong>Name<\/strong>: <em>ErrorMessage<\/em><\/li>\n<li><strong>Display Name<\/strong>: <em>Error Message<\/em><em>\u00a0<\/em><\/li>\n<\/ul>\n<\/li>\n<li>Under the <strong>Bot Responses<\/strong> section, enter the following text:<br \/>\n<code>The Flight number entered is incorrect. Let us start again.<\/code><\/li>\n<li>Click <strong>Enter<\/strong> to save<em>.<br \/>\n<\/em><\/li>\n<li>Click the <strong>Connections<\/strong> tab.<\/li>\n<li>From the drop-down list, change the default connection from <em>Not Connected<\/em> to <em>SelectFlight<\/em>.<\/li>\n<li>Click\u00a0<strong>Save<\/strong>.<\/li>\n<\/ul>\n<\/li>\n<li>Close the Error Message window.<\/li>\n<\/ol>\n<h4>ValidateFlight Script Connections<\/h4>\n<ol>\n<li>Click the <strong>ValidateFlight<\/strong> Script node.<\/li>\n<li>On the Validate Flight Script window, click the <strong>Connections<\/strong> tab.<\/li>\n<li>Click <strong>+ ADD IF<\/strong>.<\/li>\n<li>Under the <strong>IF <\/strong>section,\n<ul>\n<li>Select <strong>Context<\/strong><\/li>\n<li>For <strong>If Condition<\/strong>, enter the text as <strong>valid<\/strong><em>.<\/em><\/li>\n<li>Select the operator as <strong>equals<\/strong><em>.<\/em><\/li>\n<li>Enter the value as <strong>true<\/strong><em>.<\/em><\/li>\n<li>If this condition is true, then the dialog goes to <strong>FlightDetails<\/strong><em>.<\/em><\/li>\n<\/ul>\n<\/li>\n<li>Under the <strong>ELSE<\/strong> section,\n<ul>\n<li>If this condition is false, then the dialog goes to <strong>ErrorMessage<\/strong><em>.<\/em><\/li>\n<\/ul>\n<\/li>\n<li>Click <strong>Save<\/strong>.<\/li>\n<li>Close the Validate Flight Script window.<\/li>\n<\/ol>\n<p><a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-editscript.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18973\" src=\"\/wp-content\/uploads\/sites\/16\/SimpleBot-editscript.png\" alt=\"\" width=\"820\" height=\"461\" \/><\/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>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h4>Test the Bot<\/h4>\n<p>To test the Dialog task, you can use the <em>Talk to bot<\/em> option at the bottom right. Since the <em>onConnect<\/em> event is configured, the dialog is automatically initiated. Alternately, you can always try the following utterance (intent name) <em>Get me the flight status.<\/em><br \/>\nFollow the Bot instructions:<\/p>\n<ol>\n<li>Select Arrival\/Departure<\/li>\n<li>Enter an invalid flight number.<\/li>\n<li>You can see the appropriate error message and prompted to enter the flight number again.<\/li>\n<li>Select a flight number.<\/li>\n<li>You can see the flight details in a tabular format.<\/li>\n<\/ol>\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<p>You have successfully created and tested your first Bot.<\/p>\n<p>The next steps are to:<\/p>\n<ul>\n<li>Train your Bot to respond to various user utterances like <em>I want to know the status of a flight<\/em>, <em>What is the status of QR040?<\/em>\u00a0You can achieve this by <a href=\"\/docs\/bots\/bot-builder-tool\/train-nlp-optimization\/optimizing-bots\/\">training your Bot<\/a>.<\/li>\n<li>Enable a channel and publish your Bot for user access. <a href=\"\/docs\/bots\/bot-builder-tool\/channel-enablement\/adding-channels-to-your-bot\/\">See here for more<\/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<div class=\"w-post-elm post_navigation layout_simple inv_false\">\n\t<a class=\"post_navigation-item order_first to_prev\" href=\"https:\/\/developer.kore.ai\/v8-0\/docs\/bots\/chatbot-overview\/using-the-dialog-builder-tool\/\"><\/p>\n<div class=\"post_navigation-item-arrow\"><\/div>\n<div class=\"post_navigation-item-meta\">Previous Post<\/div>\n<div class=\"post_navigation-item-title\"><span>Using the Dialog Builder Tool<\/span><\/div>\n<p>\t<\/a><br \/>\n<a class=\"post_navigation-item order_second to_next\" href=\"#\"><\/p>\n<div class=\"post_navigation-item-meta\"><\/div>\n<div class=\"post_navigation-item-title\"><span><\/span><\/div>\n<p>\t<\/a><\/div>\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":"After you have signed up with the Kore.ai Bots platform, the next step is to create a Bot. Before you create a Bot, it is recommended to go through the basics of Bot building from this link. You can follow the steps given in this document to build the Bot at your own pace. Or...","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[68],"tags":[],"class_list":["post-18936","post","type-post","status-publish","format-standard","hentry","category-chatbot-overview"],"_links":{"self":[{"href":"https:\/\/developer.kore.ai\/v8-0\/wp-json\/wp\/v2\/posts\/18936","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developer.kore.ai\/v8-0\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developer.kore.ai\/v8-0\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v8-0\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v8-0\/wp-json\/wp\/v2\/comments?post=18936"}],"version-history":[{"count":8,"href":"https:\/\/developer.kore.ai\/v8-0\/wp-json\/wp\/v2\/posts\/18936\/revisions"}],"predecessor-version":[{"id":26189,"href":"https:\/\/developer.kore.ai\/v8-0\/wp-json\/wp\/v2\/posts\/18936\/revisions\/26189"}],"wp:attachment":[{"href":"https:\/\/developer.kore.ai\/v8-0\/wp-json\/wp\/v2\/media?parent=18936"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developer.kore.ai\/v8-0\/wp-json\/wp\/v2\/categories?post=18936"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developer.kore.ai\/v8-0\/wp-json\/wp\/v2\/tags?post=18936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}