Bridge Communications

Saturday, November 5, 2016

Building a Bot with Microsoft Bot Framework - Part II

Last week I began a series on the Bot Framework.  This week we'll start to look at the auto generated code in a new project and explain how to use it for your bot.

Let's examine the default bot code generated by a new project.


I have broken the code down into 3 sections as you can see from the image above.

Entry Point

The nice thing about a bot app is it is nothing more than an azure website, which makes it familiar to developers as far as deployment.  Your bot will hit this website in the messages\api folder, and specifically this Post code.

Message Type

The message type of the activity is useful when determining what type of message you receive and how to respond to it.  There is no code here to show it, but a user connects to your bot they are given a generic message.  You can find this type of entry point and provide your own message quite easily.  For the most part you will be interested in messages of the type Message as they represent user responses in your bot.

The Reply Mechanism

The reply mechanism in the generated code sends back a text reply.  It is the simplest form of reply, but certainly not the only type.  Text replies can include bold text, urls, images, and much more.  Other types of replies can include form dialogs, which present the users with a set of choices to pick from.

Examples of Text Replies

Send a photo
reply = activity.CreateReply("Here is a **duck** ![duck](http://aka.ms/Fo983c)");

Send bold text
reply = activity.CreateReply("Here is a **bold** chunk **text**");

Send a Url
reply = activity.CreateReply("Here is a [our website](https://www.bridgeoc.com)");

Next week we'll dive in to some more advanced topics.

Doug Routledge, C# Lync, Skype for Business, SQL, Exchange, UC, 
Full Stack Developer  BridgeOC Bridge Operator Console
Twitter - @droutledge @ndbridge



No comments:

Post a Comment