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)

Setting up the development environment

In this section, we will see how to set up the development environment but, before that, let's check out the prerequisites needed for setting it up.

Prerequisites

To use the Microsoft Bot Framework Connector, you must have the following:

  • A Microsoft account (Hotmail, Live, or Outlook) to log into the Bot Framework developer portal, which you will use to register your bot.
  • An Azure subscription (free trial at https://azure.microsoft.com/en-us/). This Azure subscription is essential for having an Azure-accessible REST endpoint exposing a callback for the Connector service.
  • Developer accounts on one or more communication service (such as Skype, Slack, or Facebook) where your bot will communicate.

In addition, you may wish to have an Azure Application Insights account so that you can capture telemetry from your bot. There are additionally different ways to go about building a bot: from scratch, coded directly to the Bot Connector REST API, the Bot Builder SDK's for Node.js and .NET, and the Bot Connector .NET template, which is what this quick start guide demonstrates.

Setting up the Bot Framework Connector SDK .NET

This is a step-by-step guide to setting up the development environment to develop a bot in C# using the Bot Framework Connector SDK .NET template:

  1. Install the prerequisite software:
    1. You can download the community version of Visual Studio 2015 (latest update) for free at www.visualstudio.com.
    2. Update all VS extensions to their latest versions by navigating to Tools | Extensions and Updates | Updates.
  2. Download and install the Bot Application template:
    1. Download the file from the direct download link, http://aka.ms/bf-bc-vstemplate.
    2. Save the ZIP file to your Visual Studio 2015 templates directory, which is traditionally in %USERPROFILE%DocumentsVisual Studio 2015TemplatesProjectTemplatesVisual C#.
  3. Open Visual Studio.
  1. Create a new C# project using the new Bot Application template:
  1. The template is a fully functional Echo Bot that takes the user's text utterance as input and returns it as output. In order to run, however, the following has to take place:
    1. The bot has to be registered with the Bot Connector.
    2. The AppId and AppPassword from the Bot Framework registration page have to be recorded in the project's web.config.
    3. The project needs to be published to the web.
    4. Use the Bot Framework emulator to test your bot application.

The Bot Framework provides a channel emulator that lets you test calls to your bot as if they were being called by the Bot Framework cloud service. To install the Bot Framework emulator, download it from https://emulator.botframework.com/.

Once installed, you're ready to test, by starting your bot in Visual Studio using a browser as the application host: