Skip to main content

An introduction to the Microsoft Bot Framework



Today was Day One of the Microsoft Ignite Australia event held in sunny Gold Coast that 2 of my colleagues & I got the chance to attend.

I loved the sessions around the Microsoft Cognitive Services & the Microsoft Bot Framework which inspired me to write my first bot.

What are bots?

Bots are simply applications that perform automated tasks. A simple example is a chatbot. An interesting example of such a bot is "Dom the pizza bot". Instead of calling up or ordering online, customers will be able to simply message Dom, the Domino’s pizza bot, and request food with a single world or emoji.


Even Cortana or Siri are example of such bots. Clearly showing how bots are the way of the future!

How do these bots communicate you ask?

Most use-cases for bots include instances where bots are communicating with users & providing insights without any specific human intervention. 

The medium through which these bots communicate are called "Channel(s)". 

At the time of writing this article, the following channels are supported by the Microsoft Bot Framework:
  1. Skype (auto-configured)
  2. Microsoft Teams
  3. Web Chat (auto-configured, embeddable)
  4. Direct Line (API to host your bot in your app)
  5. Office 365 mail
  6. Facebook Messenger
  7. GroupMe
  8. Kik
  9. Slack
  10. SMS via Twilio
  11. Telegram

Make sure to look at the live list here.

What can I do with these bots?

When you combine the power of using the Microsoft Bot Framework via the aforementioned channels AND Microsoft's Cognitive Services APIs, you can make some really kick a$$ bots.

FYI, if you haven't heard of Microsoft's Cognitive Services, they're some super funky APIs and services available to developers to make their applications more intelligent, engaging and discoverable. 

Microsoft Cognitive Services expands on Microsoft’s evolving portfolio of machine learning APIs and enables developers to easily add intelligent features – such as emotion and video detection; facial, speech and vision recognition; and speech and language understanding – into their applications. Check this out for more info. https://www.microsoft.com/cognitive-services/en-us/documentation.


Your first bot

So to begin with, you can build a super simple greeting bot. You say hello, and it greets you back. Begin by logging into azure and creating a new Bot Service.

Click the + icon & search for "Bot Service"

Click "Create"

Add an "App name" & select or add a "Resource Group" and click "Create"
Now remember, unless you selected the option to "Pin to dashboard" your bot will not appear on your dashboard. As you can see that I forgot to pin it, I should be able to view my bot in my notifications. Click the notifications icon (highlighted in red) & then click the relevant notification.


In order to authenticate your bot with the Bot Framework, you'll need to register your application and generate an App ID and password. 

Click the button to "Create Microsoft App ID and password"
This should open up a new window that helps you generate an App ID and password.
Click the "Generate an app password to continue" button

A new popup with your password will now appear. REMEMBER TO COPY THIS PASSWORD SOMEWHERE.

You can now click the "Finish and go back to Bot Framework" button
When you go back, your App ID will be pre-filled & you will need to paste your password in the relevant slot.

Remember to paste your password in


You now get to choose a language for your bot. My C#'s a tad better than my node but to show you show simple this really is, I'm choosing NodeJS. Use the "Basic" template to create a bot. Remember to click the "Create Bot" button at the bottom of the page.

Choose "NodeJS" and select the "Basic" template and click "Create Bot" at the bottom of the page

Your bot will be created in a few .. (ok quick, 1 min dance party https://youtu.be/ULC2C3VjO-o)





Once your bot is created, it should spit out the templated code. You should already be able to play with the templated code in the chat window. I have highlighted a key method here. 



You can be as silly and creative as you'd like.


Select channels to add it to one of the available channels. I'm going to add it to my Microsoft Teams.

Check out the available channels and add the ones you want by clicking "Add"

Add it to teams if you want



When you're ready, you can go to public with your bot, by navigating to settings and adding your bot details.


You can then navigate to publish and add the necessary details if you'd like to publish your bot.


Your bot

You can also navigate to the Microsoft Bot Framework dev site & view your bots here:

Log in with your standard credentials & click "My Bots"







My bot in action

By clicking the "Add to Skype" button this should open your Skype. Here's the bot in action on skype.





Easy-peasy huh? If you'd like to know more I've to some more useful links for you here:
https://app.pluralsight.com/library/courses/microsoft-bot-framework-getting-started/table-of-contents 





Comments

Popular posts from this blog

Internet Information Services(IIS) reveals its real or internal IP Address

In the ever changing world of global data communications, inexpensive Internet connections, and fast-paced software development, security is becoming more and more of an issue. Security is now a basic requirement because global computing is inherently insecure.

Keeping that in mind, we recently ran our flagship product through a security audit. It was such a helpful exercise in tying-off any remaining lose ends in our application in terms of application security. 
Based on the security audit report, there was a relatively minor issue that appeared when accessing the /images directory of our application. Turns out that the Location response header of the 301 request returns an Internal IP address. The issue is detailed below.

Issue reportedInternet Information Services (IIS) may reveal its real or internal IP address in the Location header via a request to the /images directory. The value returned whilst pen testing is https://10.0.0.10/images.

The riskInformation regarding internal IP add…

IIS Request Filtering to block HTTP Verbs (For example Trace)

The issueRequest Filtering is a built-in security feature that was introduced in Internet Information Services (IIS) 7.0. This can be used to block specific verbs like "Trace".

When request filtering blocks an HTTP request, IIS 7 will return an HTTP 404 error to the client and log the HTTP status with a unique substatus that identifies the reason that the request was denied. Verb Denied.

HTTP SubstatusDescription404.5URL Sequence Denied404.6Verb Denied404.7File Extension Denied404.8Hidden Namespace404.1Request Header Too Long404.11URL Double Escaped404.12URL Has High Bit Chars404.13Content Length Too Large

Unit Testing HttpContext.Current.Session in MVC3 .NET

We recently changed some functionality where during the "CREATE" process, we go through a wizard to save application data. This data is saved only to the session in the final step when the user clicks the final submit.

This was easy enough to implement but when I started writing unit tests for my static methods that Add, Update, Delete or Modify the contents of our application data in the session, I got the following error:
System.NullReferenceException: Object reference not set to an instance of an object.

Turns out I had forgotten to setup the HttpContext.
The following "TestInitialise" method fixed my problem :)

[TestInitialize]
public void TestSetup()
{
// We need to setup the Current HTTP Context as follows:

// Step 1: Setup the HTTP Request
var httpRequest = new HttpRequest("", "http://localhost/", "");

// Step 2: Setup the HTTP Response
var httpResponce = new HttpResponse(new StringWriter());

// Step 3: Se…