Building Your First Bot using Microsoft Bot Framework

Building Your First Bot using Microsoft Bot Framework

Microsoft Bot Framework is a comprehensive  suite of tools and offering to build and deploy the conversational chat bots for your app users.  You can build and publish your intelligent bot that interacts naturally wherever your users are talking – from Skype, Facebook Messenger, Office 365 mail and other conversational medium. Read more about Bot framework over here..  In this post we will explore how to get it started.

First things first, Tools :

  • Download the Bot framework template from – Visual Studio Template – C#  and place the downloaded zip folder inside Visual Studio Project template folder (“%USERPROFILE%\Documents\Visual Studio 2015\Templates\ProjectTemplates\Visual C#” ) .
  • Followed by template placement, download the Bot Framework Emulator (Windows) and install it.

Creating New Project

Start the new instance of Visual Studio and create a new project by choosing the “Bot Application” template as shown in below screenshot.

Bot Application Template
Bot Application Template

Once the project creation is successful, if we explore the “Solution Explorer” of the created project, it is nothing but Web API project.

Bot Application - Solution Explorer
Bot Application – Solution Explorer

Before taking look inside a code, Run the application from Visual Studio.  This will launch in a browser  mode and we can then test it using the emulator which we had just downloaded.

Bot Application - Running
Bot Application – Running

Once your Bot is running, Launch the Emulator for Bot Framework, and set the Bot URL to the same port where your app is running.

Bot Application - Launch Emulator
Bot Application – Launch Emulator

That’s it. The default Bot which comes with template is nothing but an Echo Bot, which just each what you type along with length of the text provided.

Bot Application - Running on Emulator
Bot Application – Running on Emulator

“Hello Bot” and “This is my first Bot” were two different set of input from user and you can see the output received from the Bot.

Yes ! this is as simple as what you can see it over here.

Let’s take a step back and see what is inside. The MessageController.cs  which defines all the methods and properties to control your Bot. The MessageController Class is derived from the ApiController class, which is an abstract class.

For this Bot Implementation, the Post() method actually takes care of this request received from the user and replying the response by calculating the length of the message.

Bot Application - Message Controller
Bot Application – Message Controller

That’s it from now. We will explore more details on this implementation aspect in other post !

Hope this helps !

Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at http://abhijitjana.net , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.

2 Comments to “Building Your First Bot using Microsoft Bot Framework”

Comments are closed.