Wednesday, October 26, 2016

My First Bot Using Microsoft Bot Framework

Hello Guys,

I am exploring Microsoft bot framework nowadays and i would like to share some of my experience with you all.

You might have heard about Internet Bots in current time there are many Bot Frameworks are build like Facebook, Microsoft Bot,Hubot,Lita (Chat bots) etc...There are many.

what is a bot exactly?

Generally we do use apps in daily life but apps are mostly one directional communication it works based on your inputs it never thinks. in case of bots generally bots are used with any AI framework so it can think what you want and they can understand your words (mostly).

Siri, Cortana and nowaydas Google Allo is best examples of bots.

what bots can do ?

Generally they can help us ordering food, book a cab,shop for cloths and can find restaurants for us. Many bots are programmed with AI which acts like humans when you talk to them so it feels like asking a person for help instead of just typing in a search engine so in short it is more interactive.


Lets build our first Bot using Microsoft Bot Framework

Prerequisite : 

1. Visual Studio 2015 ( i was facing issues while building my bot in 2012 - not sure why)
2.  Please download Bot Application template from here which will be used to create bot projects in VS. - Download
3. copy that template here : %USERPROFILE%\Documents\Visual Studio 2015\Templates\ProjectTemplates\Visual C#

Once you are done with above setup you are ready to create your first Bot.

Step 1: Create in new Bot Application in Visual studio.


Step 2; Add Dictionary.cs in your project. Write following code into it.


Step 3: Add Following code in MessagesController.cs



You can play with json object which we are getting and display specific output to user.

Step 4: Update the service X-Mashape key i am using one of the service from there which will give me the meaning of any word i will send to Bot. here

Step 5; Press F5 it will start listening your requests on specific port.



Step 6: Open Microsoft Bot framework simulator which we downloaded in above steps. Please set your app URL as highlighted in below picture. You can host your on cloud as well and you can register your bot at Register your Bot here



That is all your bot is ready to provide you meaning of any English word. In next blog i will be connecting my bot to LUIS to make my bot intelligent. 










4 comments:

  1. Nice one!. Instead of screenshot of code use code snippet it will be more useful for people!

    ReplyDelete
  2. Thank you jalpesh for suggestion i will update it soon.

    ReplyDelete
  3. Nice start Nirav. I agree to Jalpesh. Use of code snippet is easy to use, better look & feel and also easy to update in case of any correction required.

    ReplyDelete