Introduction
The Bot Framework enables you to build bots that support different types of interactions with users. You can design conversations in your bot to be freeform. Your bot can also have more guided interactions where it provides the user choices or actions. The conversation can use simple text strings or more complex rich cards that contain text, images, and action buttons. And you can add natural language interactions, which let your users interact with your bots in a natural and expressive way.
Bot Builder SDK introduced Dialogs that allows users to model conversations and manage conversation flow. Dialogs can contain waterfall steps and prompts (Options). As the user interacts with the bot, the bot will start, stop, and switch between various dialogs in response based on user messages.
In this article, we will learn about the condition inside the Waterfall Bot Framework.

Prerequisite
I have explained about Bot framework installation, deployment, and implementation in the below articles.
- Getting Started with Chatbot Using Azure Bot Service
- Getting Started with Bots Using Visual Studio 2017
- Deploying A Bot to Azure Using Visual Studio 2017
- How to Create ChatBot In Xamarin
Create New Bot Service
Let's create a new bot service application using Visual Studio 2017. Open Visual Studio > Select File > Create New Project (Ctrl + Shift +N) > select Bot application.
The Bot application template was created with all the components and all required NuGet references installed in the solutions.
In this solution, we have two main class MessagesController.cs and RootDialog.cs. Let us start discussing here.


RootDialog Class
Step 1
You can Create/Edit the RootDialog class. Create a class that is marked with the [Serializable] attribute (so the dialog can be serialized to state) and implement the IDialog interface.
- using System;
- using System.Threading.Tasks;
- using Microsoft.Bot.Builder.Dialogs;
- using Microsoft.Bot.Connector;
- [Serializable]
- public class RootDialog : IDialog<object>
- {
- }
Step 2
IDialog interface has only StartAsync() method. StartAsync() is called when the dialog becomes active. The method is passed the IDialogContext object, used to manage the conversation.
- public async Task StartAsync(IDialogContext context)
- {
- }
Step 3
You can wait for a message from the conversation, call context.Wait(<method name>) and pass it the method you called when the message is received. When MessageReceivedAsync() is called, it passes the dialog context and an IAwaitable of type IMessageActivity. To get the message, await the result.
- [Serializable]
- public class RootDialog : IDialog<object>
- {
- public Task StartAsync(IDialogContext context)
- {
- context.Wait(MessageReceivedAsync);
- return Task.CompletedTask;
- }
- private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
- {
- }
- }
Step 4
Let's start editing MessageReceivedAsync method as per our requirement or create a new async method. The following code is a welcome message conversation dialog.



Ajinkya ChikhalePosted Jan 12, 2021, 8:47 AM
Sir I want to store conversation data. I got the User messages from (context.activity.text). But I am not getting how to get BOT responses .Could you please help.
Dev pandeyPosted Nov 6, 2018, 1:16 AM
Dear Sir, am working on Dynamic Unit Testing of our Bot, do you have any references
vivek sharmaPosted Jan 8, 2018, 4:22 AM
Sir please suggest me where Its my coding or setting problem or something else
vivek sharmaPosted Jan 8, 2018, 4:20 AM
As I have develop Chat Bot, we develop chat bot with skype, messaging working fine, but in calling there is a voice message "you can't talk this bot we are working on it"
vivek sharmaPosted Jan 8, 2018, 4:16 AM
Thanks, For your Help
vivek sharmaPosted Dec 22, 2017, 5:58 AM
Sir, Suggest me how we deal with communication with 2 or more users in a call as you suggest we can use Direct Line channel API
vivek sharmaPosted Dec 20, 2017, 5:08 AM
Can we create our own WPF Chat UX, which can communicate with Bot Framework
vivek sharmaPosted Dec 18, 2017, 6:08 AM
How we create our own UI for Chat as like Emulator
vivek sharmaPosted Dec 18, 2017, 6:07 AM
Thanks , working fine
vivek sharmaPosted Dec 5, 2017, 6:18 AM
Hi, I am trying, but after send msg , it showing MSG "couldn't send"
Bhashitha HemanthaPosted Dec 5, 2017, 5:54 AM
Suthahar J thanks.. greate tutorials..i'm having an issue with posting data from database in a bot. what should I use? normal dialog,formflow,rich cards or prompts? and how to do that? could you please post a tutorial about it too.
Naveen BishtPosted Aug 29, 2017, 12:13 AM
Gud bhai nice....keep it up