{"id":18003,"date":"2017-08-22T19:52:02","date_gmt":"2017-08-22T19:52:02","guid":{"rendered":"http:\/\/developer.kore.ai\/v7-2\/?post_type=docs&#038;p=11876"},"modified":"2021-03-30T08:51:27","modified_gmt":"2021-03-30T07:51:27","slug":"default-dialog","status":"publish","type":"post","link":"https:\/\/developer.kore.ai\/v7-2\/docs\/bots\/bot-intelligence\/default-dialog\/","title":{"rendered":"Default Conversations"},"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 id=\"default-dialog\">There are multiple places where the platform responds to user utterances, without the developer having to code the details. Examples include:<\/p>\n<ul>\n<li><strong>Default Dialog<\/strong> when the user intent is not found or understood by the Bot, <a href=\"#Default_Dialog\">see here<\/a>.<\/li>\n<li><strong>Standard Responses<\/strong> to certain questions, greetings, error and warning scenarios etc., <a href=\"#Standard_Responses\">see here<\/a>.<\/li>\n<li><strong>Event Handlers<\/strong> for certain common bot events can be defined, <a href=\"\/v7-2\/docs\/bots\/advanced-topics\/event-based-bot-actions\/\" target=\"_blank\" rel=\"noopener noreferrer\">see here for more<\/a>.<\/li>\n<\/ul>\n<p>Though these are set by default by the platform, you can customize them as per your business requirements. In this document, we look into such customizations.<\/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<h2 id=\"default-dialog\"><span class=\"ez-toc-section\" id=\"Default_Dialog\">Default Dialog<\/span><\/h2>\n<p>You can choose to run a dialog task or display a standard error message if the Natural Language Processor for Kore.ai cannot determine the user intent. The default setting is to display a standard error message.<\/p>\n<p>From the <strong>Natural Language -&gt; Default Conversation<\/strong> section, select the <strong>Default Dialog<\/strong> tab to define a default dialog task.<\/p>\n<p>For example, you can switch the conversation from the bot to a live agent, or run a generic dialog such as the main menu if the user intent could not be determined in the bot conversation.<\/p>\n<p>If a default dialog task is not defined, standard error messages and any customizations defined in the <strong>Standard Responses<\/strong> section are used.<\/p>\n<p>The following illustration is an example of the <strong>Default Dialog<\/strong> section in Bot Builder configured to run the <em>Get Account Help<\/em> dialog task when the user intent cannot be determined in <em>Banking Portal<\/em>\u00a0bot.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/13\/Default-Dialog-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-21889\" src=\"\/wp-content\/uploads\/sites\/13\/Default-Dialog-2.png\" alt=\"\" width=\"820\" height=\"461\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095209\/Default-Dialog-2.png 820w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/13\/20221201095209\/Default-Dialog-2-300x169.png 300w\" sizes=\"auto, (max-width: 820px) 100vw, 820px\" \/><\/a><\/p>\n<h4>To define a default dialog<\/h4>\n<p>To complete the following procedure, you must have already defined a dialog to select as the default dialog.<\/p>\n<ol>\n<li>On the\u00a0<strong>Natural Language -&gt; Default Conversation<\/strong> tab, select the <strong>Default Dialog<\/strong>\u00a0section<\/li>\n<li>In the <strong>If user&#8217;s intent is not understood<\/strong> section, select <strong>Automatically run a dialog task<\/strong>.<\/li>\n<li>In the <strong>Default Dialog Task<\/strong> field displayed, select a default dialog from the list, and then click <strong>Save<\/strong>.<\/li>\n<\/ol>\n<p>The <strong>Settings successfully saved<\/strong> message is displayed.<\/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<h2 id=\"standard-responses\"><span class=\"ez-toc-section\" id=\"Standard_Responses\">Standard Responses<\/span><\/h2>\n<p>In the Kore.ai Bot Builder tool, you can view the default Natural Language Processing, or NLP interpreter responses to user inputs or events.<\/p>\n<p>For example, a reply to a user input of <em>Hi!\u00a0<\/em>The Bot will reply with one of the following responses, chosen at random at runtime:<\/p>\n<ul>\n<li>Hi!<\/li>\n<li>Hello<\/li>\n<li>Hi there!<\/li>\n<li>Hey \ud83d\ude42<\/li>\n<\/ul>\n<p>The NLP interpreter displays pre-defined text responses to users based on an event, condition, trigger, or user input. Depending on your custom Bot and users of that Bot, you may want to modify the default responses to users displayed for an event or request for input.<\/p>\n<p>For example:<\/p>\n<ul>\n<li><strong>User Input<\/strong> &#8211; When were you born?<\/li>\n<li><strong>Event<\/strong> &#8211; Authorization Failure.<\/li>\n<li><strong>Trigger<\/strong> &#8211; Task canceled.<\/li>\n<\/ul>\n<p>You can define both standard bot responses, or if desired, add a channel override response that is displayed only in the specified channel the user is in, otherwise, one of the standard default responses are displayed. <a href=\"\/v7-2\/docs\/bots\/bot-builder-tool\/train-nlp-optimization\/custom-behavior\/default-standard-responses\/\">See here for a comprehensive list of default standard responses<\/a>.<\/p>\n<p>For example, in the SMS channel, you may only want to use short Bot responses to save data.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Default_Responses\">Default Responses<\/span><\/h3>\n<p>To access and manage the default responses in Bot Builder,<\/p>\n<ul>\n<li>Hover over the left navigation menu and select <strong>Natural Language -&gt; Default Conversation<\/strong><\/li>\n<li>Select <strong>Standard Responses<\/strong>\u00a0section to display the <strong>Statements<\/strong> tab as shown in the following illustration.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/13\/standard-responses.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15277\" src=\"\/wp-content\/uploads\/sites\/13\/standard-responses.png\" alt=\"\" width=\"622\" height=\"358\" \/><\/a><\/li>\n<\/ul>\n<p>For each standard response category tab, the event or user input is listed followed by one or more NLP interpreter standard responses. You can modify the default response, and if needed, add additional responses selected randomly by the NLP interpreter in response to user input or system event.<\/p>\n<p>In the <strong>Standard Response<\/strong>\u00a0section, the standard\u00a0bot responses are categorized in the following tabs:<\/p>\n<ul>\n<li><strong>Statements<\/strong> &#8211; Responses displayed to the user as the result of an action by the bot or user. For example, a user cancels a task, or a user gives an invalid response to your bot request.<\/li>\n<li><strong>Queries<\/strong> &#8211; Statements from the bot to the user to ask for more information, for example,\u00a0<em>Which field do you want to change?<\/em><\/li>\n<li><strong>Error &amp; Warnings<\/strong> &#8211;\u00a0Statements from the bot to the user when an error occurs during the scenario, such as\u00a0<em>End date cannot be before or same as the start date!<\/em><\/li>\n<li><strong>Questions<\/strong> &#8211; Questions the Bot may pose to the user when not included in any other category.<\/li>\n<li><strong>Choices<\/strong> &#8211; The bot is asking for Yes\/No input, for example, <em>Would you like to receive push notifications every time this task occurs?<\/em><\/li>\n<li><strong>Greeting<\/strong> &#8211; Initial responses by the bot when the bot is installed, or other initial contacts, for example, when a user returns to the interaction after a period of inactivity.<\/li>\n<\/ul>\n<p>The previous\u00a0illustration shows the <strong>Statements<\/strong> tab in the <strong>Standard Responses<\/strong> section on the <strong>Natural Language<\/strong> tab for a Bot.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Add_Edit_Responses\">Add &amp; Edit Responses<\/span><\/h3>\n<p><strong>To add a new Standard Response<\/strong><\/p>\n<p><span style=\"text-decoration: underline\">Note<\/span>: If the standard responses are updated at the conditions wherein an ambiguity will be presented to the user, the bot response will not display the ambiguous choices to the user and you need to use the function \u201c<strong><em>getChoices()<\/em><\/strong>\u201c to present the ambiguity list (see point 6 below).<\/p>\n<ol>\n<li>Select a tab category for the standard\u00a0response, for example, <strong>Greeting<\/strong>, and then hover the situation for which you want to add the response. Click <strong>Add Response<\/strong>:\n<ol>\n<li>The <strong>Add Channel Overrides<\/strong>\u00a0dialog is displayed.<\/li>\n<li>In the <strong>Choose a channel<\/strong> drop-down list, select a channel to create a channel-specific response. You can go with Any Channel option to enable the response for all channels.<\/li>\n<li>In case of Channel specific response, <strong>Choose a Task <\/strong>drop-down list, select <strong>Any Task<\/strong> to apply this channel-specific response to all tasks, or select a specific task.<\/li>\n<li>When\u00a0a specific task is selected, the <strong>Choose a Field is<\/strong> drop-down is displayed. Select <strong>Any Field<\/strong> or a specific field for this channel-specific response.<\/li>\n<li>In the Bot\u00a0<strong>Response<\/strong> editor, you can override the default Bot Response for this channel using basic editor controls on the <strong>Simple Mode<\/strong> tab, or write custom JavaScript for the response on the <strong>Advanced Mode<\/strong> tab. For the:\n<ul>\n<li><strong>Simple Mode<\/strong> tab &#8211; Enter the text for the default standard\u00a0response, for example,\u00a0<span style=\"color: #0000ff\">*There* you are, I was ~hoping~ you would return soon!<span style=\"color: #333333\"> and then o<\/span><\/span>ptionally, format the text using the formatting buttons for bold, italics, header styles, hyperlinks, ordered and unordered lists, and inserting a line. For more information, see <a href=\"\/v7-2\/docs\/bots\/bot-builder-tool\/dialog-task\/prompt-editor\/\">Using the Prompt Editor<\/a>.<\/li>\n<li><strong>Advanced Mode tab<\/strong> &#8211; Enter JavaScript to override the channel message as described in the following code examples.\n<p class=\"note\"><strong>Note:<\/strong>\u00a0Use the following keys to return default values for:<br \/>\n<span style=\"color: red;font-family: courier\">response.message<\/span> &#8211; Returns the default message as a string.<br \/>\n<span style=\"color: red;font-family: courier\">response.choices<\/span> &#8211; Returns the options choice or confirmation message types as an array.<\/p>\n<ul>\n<li><strong>Slack Channel Override Example<\/strong>\n<pre class=\"lang:default decode:true\">var message = {};\r\nvar attachments = [];\r\nvar attachment = {\r\n    'text': \"Exception occurred during API execution\",\r\n    'color': '#FFCC00',\r\n    'attachment_type': 'default'\r\n};\r\nattachments.push(attachment);\r\nmessage.attachments = attachments;\r\nprint(JSON.stringify(message));<\/pre>\n<\/li>\n<li><strong>FaceBook Channel Override Example<\/strong>\n<pre class=\"lang:default decode:true \">var message = {\r\n    text: response.message\r\n};\r\nvar buttons = [];\r\nfor (var i = 0; i &lt; response.choices.length; i++) {\r\n    var choiceItem = response.choices[i];\r\n    if (choiceItem.length &gt; 20) {\r\n        choiceItem = choiceItem.substring(\r\n            0, 18) + '..';\r\n    }\r\n    var element = {\r\n        content_type: 'text',\r\n        title: choiceItem,\r\n        payload: choiceItem\r\n    };\r\n    buttons.push(element);\r\n}\r\nmessage.quick_replies = buttons;\r\nprint(JSON.stringify(message));<\/pre>\n<\/li>\n<li><strong>Email Channel Override Example<\/strong>\n<pre class=\"lang:default decode:true \">var message = {};\r\nvar text = response.message + ' &lt;br&gt; ';\r\nfor (var i = 0; i &lt; response.choices.length; i++) {\r\n    text = text.concat(\r\n        '&lt;u&gt; + response.choices[i] + ' &lt;\r\n        \/u&gt; &lt;br&gt;');\r\n    }\r\n    message.text = text;\r\n    print(JSON.stringify(message));<\/pre>\n<\/li>\n<li><strong>SMS Channel Override Example<\/strong>\n<pre class=\"lang:default decode:true \">var message = {};\r\n    var indexArray = ['a', 'b', 'c',\r\n        'd', 'e',\r\n        'f', 'g', 'h', 'i', 'j',\r\n        'k', 'l', 'm', 'n', 'o',\r\n        'p', 'q', 'r', 's', 't',\r\n        'u', 'v', 'w', 'x', 'y',\r\n        'z'\r\n    ];\r\n    var text = response.message + '\\\\n';\r\n    for (var i = 0; i &lt; response.choices\r\n        .length; i++) {\r\n        text = text.concat(indexArray[i] +\r\n            ') ' + response.choices[\r\n                i] + '\\\\n');\r\n    }\r\n    message.text = text;\r\n    print(JSON.stringify(message));<\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>Using the <strong>getChoices()<\/strong> function, you can also customize the <strong>response display format<\/strong> using the <a href=\"\/v7-2\/docs\/bots\/sdks\/message-templates\/\" target=\"_blank\" rel=\"noopener noreferrer\">message formatting templates<\/a>. When the getChoices() function is called and there is an ambuguity, the platform returns the ambiguous choices information as an array which can be used to present the options to the end users.<br \/>\nFor example, to display the standard response for <em>&#8220;Did you mean&#8221; in<\/em> a button format you can use the following code:<\/p>\n<pre class=\"lang:default decode:true \">var info =getChoices() ;\r\nvar message = {\r\n\"type\": \"template\",\r\n\"payload\": {\r\n  \"template_type\": \"button\",\r\n  \"text\": \"Did you mean\",\r\n  \"subText\": \"You can now customize response for did you mean\",\r\n  \"buttons\": []\r\n }\r\n};\r\nfor (i = 0; i &lt; info.length; i++) {\r\nvar button = {\r\n  \"type\": \"postback\",\r\n  \"title\": info[i],\r\n  \"payload\": \"payload1\"\r\n};\r\n\r\nmessage.payload.buttons.push(button);\r\n}\r\nprint(JSON.stringify(message)); \r\n<\/pre>\n<\/li>\n<li>Click\u00a0<strong>Done<\/strong> to save and close the <strong>Edit Response<\/strong> dialog and apply the new standard response.<\/li>\n<\/ol>\n<\/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><\/div><\/div><\/div><\/div><\/div><\/section>\n","protected":false},"excerpt":{"rendered":"There are multiple places where the platform responds to user utterances, without the developer having to code the details. Examples include: Default Dialog when the user intent is not found or understood by the Bot, see here. Standard Responses to certain questions, greetings, error and warning scenarios etc., see here. Event Handlers for certain common...","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[47],"tags":[],"class_list":["post-18003","post","type-post","status-publish","format-standard","hentry","category-bot-intelligence"],"_links":{"self":[{"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/posts\/18003","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/comments?post=18003"}],"version-history":[{"count":18,"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/posts\/18003\/revisions"}],"predecessor-version":[{"id":22615,"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/posts\/18003\/revisions\/22615"}],"wp:attachment":[{"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/media?parent=18003"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/categories?post=18003"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developer.kore.ai\/v7-2\/wp-json\/wp\/v2\/tags?post=18003"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}