Book Image

Building Bots with Microsoft Bot Framework

By : Kishore Gaddam
Book Image

Building Bots with Microsoft Bot Framework

By: Kishore Gaddam

Overview of this book

Bots help users to use the language as a UI and interact with the applications from any platform. This book teaches you how to develop real-world bots using Microsoft Bot Framework. The book starts with setting up the Microsoft Bot Framework development environment and emulator, and moves on to building the first bot using Connector and Builder SDK. Explore how to register, connect, test, and publish your bot to the Slack, Skype, and Facebook Messenger platforms. Throughout this book, you will build different types of bots from simple to complex, such as a weather bot, a natural speech and intent processing bot, an Interactive Voice Response (IVR) bot for a bank, a facial expression recognition bot, and more from scratch. These bots were designed and developed to teach you concepts such as text detection, implementing LUIS dialogs, Cortana Intelligence Services, third-party authentication, Rich Text format, Bot State Service, and microServices so you can practice working with the standard development tools such as Visual Studio, Bot Emulator, and Azure.
Table of Contents (10 chapters)

How to use dialogs in bot applications

Now, we will see how to use dialogs for the same Hello World bot application.

Dialogs will be used in a conversational process, where there is an interaction or exchange of messages between the user and the bot. Each dialog is an abstraction that encapsulates its own state in a C# class that implements IDialog. To work with dialogs, we need to import the Microsoft.Bot.Builder.Dialogs namespace. Add a C# class HelloWorldDialog into your project. To add a class, right-click on your project and navigate to Add | Class... from the menu:

Figure 16: Using Visual Studio IDE to add a new class to an existing project

Give the Name as HelloWorldDialog:

Figure 17: Using Visual Studio IDE to name a new class

In order to change the Hello World example, add the following code in HelloWorldDialog. To use the Bot Builder, we first need to import the required namespace:

using Microsoft.Bot...