{"id":59,"date":"2018-07-14T00:30:00","date_gmt":"2018-07-14T00:30:00","guid":{"rendered":"https:\/\/kindsonthegenius.com\/blog\/2018\/07\/14\/what-are-dialogs-in-chatbots-same-as-forms-in-web-application\/"},"modified":"2020-11-05T14:21:26","modified_gmt":"2020-11-05T13:21:26","slug":"what-are-dialogs-in-chatbots-same-as-forms-in-web-application","status":"publish","type":"post","link":"https:\/\/kindsonthegenius.com\/blog\/what-are-dialogs-in-chatbots-same-as-forms-in-web-application\/","title":{"rendered":"What are Dialogs in Chatbots? (Same as Forms in Web Application)"},"content":{"rendered":"<p>We would talk about Dialogs.<\/p>\n<p>If you have been following my lessons on\u00a0 <a href=\"https:\/\/kindsonthegenius.com\/blog\/what-are-dialogs-in-chatbots-same-as-forms-in-web-application#t6\">How to Build Chatbots or MS Bot Framework Tutorials<\/a>, you would realize for you to develop a useful chatbot application, you simply need the right information, and from the right person. That is exactly what I do for my subscribers.<\/p>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<p><b>Contents<\/b><\/p>\n<ol>\n<li><a href=\"#t1\">Introduction<\/a><\/li>\n<li><a href=\"#t2\">What are Dialogs in Chatbots?<\/a><\/li>\n<li><a href=\"https:\/\/kindsonthegenius.com\/blog\/what-are-dialogs-in-chatbots-same-as-forms-in-web-application\/\">Where to Start<\/a><\/li>\n<li><a href=\"#t4\">Adding New Dialogs<\/a><\/li>\n<li><a href=\"#t5\">Redirecting to Another Dialog<\/a><\/li>\n<li><a href=\"#t6\">Final Notes <\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h3><b id=\"t2\">1. Introduction<\/b><\/h3>\n<p>Honestly, it&#8217;s really very easy to develop applications no matter how complex they are. Ask me why. The reason is because, the tools are already there. Also bits and pieces of any application have already be developed, you simply need to find them and piece them together. And that&#8217;s it.<\/p>\n<p>Today, I would tell you about dialogs in Chatbots. If you understand the concepts of dialogs in chatbots, then you will see that development of chatbots is really easy if you have a basic knowleges of programming.<\/p>\n<p>&nbsp;<\/p>\n<h3><b id=\"t2\">2. What is a Dialog?<\/b><\/h3>\n<p>A dialog si simply a single flow of communication between the user and the chatbot. For example:<br \/>\n<span style=\"font-family: 'times' , 'times new roman' , serif;\"><br \/>\n<\/span><span style=\"font-family: 'times' , 'times new roman' , serif;\"><span style=\"color: #20124d;\">User: Please play me a song<\/span><\/span><br \/>\n<span style=\"color: #274e13;\"><span style=\"font-family: 'times' , 'times new roman' , serif;\"><i>Bot: Which song would you like me to play<\/i><\/span><\/span><br \/>\n<span style=\"color: #20124d;\"><span style=\"font-family: 'times' , 'times new roman' , serif;\">User: Ada Ada by Flavour<\/span><\/span><br \/>\n<span style=\"color: #274e13;\"><span style=\"font-family: 'times' , 'times new roman' , serif;\"><i>Bot: I could not get Ada Ada by Flavour. Would you like Golibe by Flavour?<\/i><\/span><\/span><br \/>\n<span style=\"color: #20124d;\"><span style=\"font-family: 'times' , 'times new roman' , serif;\">User: Ok<\/span><\/span><\/p>\n<p>You see fromthe above that this is a single flow of conversation that follows a particular logic. If along the line, the user would like to know about the wheather, then another dialog would be needed. Or if the user wants the bot to get stock market reports, similarly, another dialog would be needed.<\/p>\n<p>&nbsp;<\/p>\n<h3><b id=\"t3\">3. Where to Start<\/b><\/h3>\n<p>To start developing a chatbot you simply need to download the template.This template already is a complete chatbot but just with one dialog.You could just build and run this template and it works perfectly. Just<br \/>\nThis is the same way that you have a single form when you start a new web application in visula studio.<br \/>\nSo just go ahead to download the template from <a href=\"https:\/\/github.com\/kenakamu\/line-bot-sdk-csharp\/releases\" target=\"_blank\" rel=\"noopener noreferrer\">this link<\/a>. It is in a zip file. Unzip it. Open it in Visual Studio and then run it.<br \/>\nTo actually test it by sending messages and getting response, you need an Emulator Applicaiton. You can also get it free from here and install.<br \/>\nRefer to this tutorial. <a href=\"http:\/\/kindsonthegenius.blogspot.com\/2018\/07\/build-your-first-chatbot-in-visual.html\" target=\"_blank\" rel=\"noopener noreferrer\">Build Your First Chatbot in Visual Studio <\/a><br \/>\n<a href=\"https:\/\/youtu.be\/YCUNwz3Nwb0\" target=\"_blank\" rel=\"noopener noreferrer\">Video Lessons here<\/a><\/p>\n<p>&nbsp;<\/p>\n<h3><b id=\"t4\">4. Adding New Dialog<\/b><\/h3>\n<p>Just like you can add several forms or pages to your web application, you can also add several dialogs to your Chatbot application. Once you have the template with the root dialog, you can simply add new dialog by adding a new class file. You could also copy and modify the existing dialog file<\/p>\n<p><b><\/b><br \/>\n<ins style=\"display: block; text-align: center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-7041870931346451\" data-ad-slot=\"4209786523\"><\/ins><\/p>\n<h3><b id=\"t5\">5. Redirecting to Another Dialog<\/b><\/h3>\n<p>You can easily redirect from on dialog to another in a chatbot application. But unlike web application, you don&#8217;t use hyperlinks, you simply write the code to do this.<br \/>\nWhen you redirect to another dialog, you are adding it to the stack. This means that you could return to the previous dialog later.<br \/>\nI would tell you two ways to redirect to another dialog:<\/p>\n<p>1. Using <span style=\"color: blue;\">context.call<\/span>: This simple calls the new child dialog without passing any parameter<\/p>\n<p>2. Using <span style=\"color: blue;\">context.forward()<\/span>: This method allows us to invoke a child dialog and pass an a parameter (which could be a message) to the dialog.<br \/>\nThe syntax is:<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #0000cc;\">        [LuisIntent(\"\")]<\/span>\r\n        <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">async<\/span> Task <span style=\"color: #0066bb; font-weight: bold;\">None<\/span>(IDialogContext context, IAwaitable&lt;IMessageActivity&gt; message, LuisResult result)\r\n        {\r\n            <span style=\"color: #333399; font-weight: bold;\">var<\/span> qnaDialog = <span style=\"color: #008800; font-weight: bold;\">new<\/span> qnaDialog();\r\n            <span style=\"color: #333399; font-weight: bold;\">var<\/span> messageToSend = <span style=\"color: #008800; font-weight: bold;\">await<\/span> message;\r\n            <span style=\"color: #008800; font-weight: bold;\">await<\/span> context.Forward(qnaDialog, AfterQNADialog, messageToSend, CancellationToken.None);\r\n        }\r\n<\/pre>\n<p>Listing 1: Foward message to a QnaDialog<\/p>\n<p>&nbsp;<\/p>\n<p>This Listing 1 shows how to foward the program execution to a QNA Dialog when no intent is identified by the LUIS dialog<\/p>\n<p>Here, a new instace of the qnaDialog is created\u00a0 and th foward method takes an input message and passes it to the new dialog. It also specifies a callback when the new child dialog is completed. In this case the function to call after completion is AfterQNADialog.<\/p>\n<p>Once it has completed, the AfterQNADialog will call context.Done.<\/p>\n<p>&nbsp;<\/p>\n<p><b>Bot Framework Tutorial Series<\/b><\/p>\n<div style=\"outline-style: none;\"><a href=\"https:\/\/kindsonthegenius.com\/blog\/bot-framework-tutorials-1-introduction-to-microsoft-bot-framework\/\" target=\"_blank\" rel=\"noopener noreferrer\">Bot Framework Tutorial &#8211; 1. Introduction to Microsoft Bot Framework<\/a><\/div>\n<div style=\"outline-style: none;\">\n<div style=\"outline-style: none;\"><a href=\"https:\/\/kindsonthegenius.com\/blog\/bot-framework-tutorial-2-create-your-first-chat-bot-in-azurestep-by-step\/\" target=\"_blank\" rel=\"noopener noreferrer\">Bot Framework Tutorial 2: Create Your First Chat Bot in Azure(Step by Step)<\/a><\/div>\n<div style=\"outline-style: none;\"><a href=\"https:\/\/kindsonthegenius.com\/blog\/bot-framework-tutorial-3-understanding-bot-templates-in-azure\/\" target=\"_blank\" rel=\"noopener noreferrer\">Bot Framework Tutorial 3: Understanding Bot Templates (in Azure)<\/a><\/div>\n<div style=\"outline-style: none;\"><a href=\"https:\/\/kindsonthegenius.com\/blog\/bot-framework-tutorial-4-creating-a-question-and-answerqna-bot\/\" target=\"_blank\" rel=\"noopener noreferrer\">Bot Framework Tutorial 4: Creating a Question and Answer(Qna) Bot<\/a><\/div>\n<div style=\"outline-style: none;\"><a href=\"https:\/\/kindsonthegenius.com\/blog\/bot-framework-tutorial-5-how-to-train-a-question-and-answerqna-bot\/\" target=\"_blank\" rel=\"noopener noreferrer\">Bot Framework Tutorial 5: How to Train a Question and Answer(QnA) Bot<\/a><\/div>\n<div style=\"outline-style: none;\"><a href=\"https:\/\/kindsonthegenius.com\/blog\/build-your-first-chatbot-in-visual-studio-step-by-step\/\" target=\"_blank\" rel=\"noopener noreferrer\">Build Your First ChatBot in Visual Studio (Step by Step)<\/a><\/div>\n<div style=\"outline-style: none;\"><a href=\"https:\/\/kindsonthegenius.com\/blog\/what-is-luis-language-understanding-intelligent-service\/\" target=\"_blank\" rel=\"noopener noreferrer\">What is LUIS (Language Understanding Intelligent Service)<\/a><\/div>\n<div style=\"outline-style: none;\"><a href=\"https:\/\/kindsonthegenius.com\/blog\/series-of-easy-tutorials-on-bot-framework-how-to-create-intelligent-bots-using-ms-cognitive-services\/\" target=\"_blank\" rel=\"noopener noreferrer\">Series of Easy Tutorials on Bot Framework (How to Create Intelligent Bots using MS Cognitive Services)<\/a><\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<h3><b id=\"t6\">6. Final Notes<\/b><\/h3>\n<p>Just as I mentioned previously, I just want to provide an overview of what Dialogs are and I hope by now you clearly understand the concept of dialogs. I would say you should take some time to do the beginners tutorials on MS Bot Framework so it becomes clearer to you.<\/p>\n<p>Thank you for learning and if you have any comments or questions, leave them in the comments box below or by the left of this page.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We would talk about Dialogs. If you have been following my lessons on\u00a0 How to Build Chatbots or MS Bot Framework Tutorials, you would realize &hellip; <\/p>\n","protected":false},"author":1,"featured_media":528,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[195],"tags":[],"_links":{"self":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/59"}],"collection":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/comments?post=59"}],"version-history":[{"count":11,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/59\/revisions"}],"predecessor-version":[{"id":1769,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/59\/revisions\/1769"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/media\/528"}],"wp:attachment":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/media?parent=59"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/categories?post=59"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/tags?post=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}