What are Dialogs in Chatbots? (Same as Forms in Web Application)

What are Dialogs in bot Framework

We would talk about Dialogs.

If you have been following my lessons on  How to Build Chatbots or MS Bot Framework Tutorials, 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.


  1. Introduction
  2. What are Dialogs in Chatbots?
  3. Where to Start
  4. Adding New Dialogs
  5. Redirecting to Another Dialog
  6. Final Notes


1. Introduction

Honestly, it’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’s it.

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.


2. What is a Dialog?

A dialog si simply a single flow of communication between the user and the chatbot. For example:

User: Please play me a song
Bot: Which song would you like me to play
User: Ada Ada by Flavour
Bot: I could not get Ada Ada by Flavour. Would you like Golibe by Flavour?
User: Ok

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.


3. Where to Start

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
This is the same way that you have a single form when you start a new web application in visula studio.
So just go ahead to download the template from this link. It is in a zip file. Unzip it. Open it in Visual Studio and then run it.
To actually test it by sending messages and getting response, you need an Emulator Applicaiton. You can also get it free from here and install.
Refer to this tutorial. Build Your First Chatbot in Visual Studio
Video Lessons here


4. Adding New Dialog

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

5. Redirecting to Another Dialog

You can easily redirect from on dialog to another in a chatbot application. But unlike web application, you don’t use hyperlinks, you simply write the code to do this.
When you redirect to another dialog, you are adding it to the stack. This means that you could return to the previous dialog later.
I would tell you two ways to redirect to another dialog:

1. Using context.call: This simple calls the new child dialog without passing any parameter

2. Using context.forward(): This method allows us to invoke a child dialog and pass an a parameter (which could be a message) to the dialog.
The syntax is:


        public async Task None(IDialogContext context, IAwaitable<IMessageActivity> message, LuisResult result)
            var qnaDialog = new qnaDialog();
            var messageToSend = await message;
            await context.Forward(qnaDialog, AfterQNADialog, messageToSend, CancellationToken.None);

Listing 1: Foward message to a QnaDialog


This Listing 1 shows how to foward the program execution to a QNA Dialog when no intent is identified by the LUIS dialog

Here, a new instace of the qnaDialog is created  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.

Once it has completed, the AfterQNADialog will call context.Done.


Bot Framework Tutorial Series


6. Final Notes

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.

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.