Hands-on: Microsoft Bot Framework with LUIS

This year during the Microsoft Build event Microsoft has released the Bot Framework. The Bot Framework is a default template that allows you to create your own bot. But what is a bot and how does it work? The possibilities are endless and it can change the way how we interact with technology. In this blog post will explain what a bot is and cover my own hands-on experience.

What is a bot?

There are many different bots and the following video explains the difference between these bots.

In this case, we are focusing at a chat bot or also called a social bot. A bot is a piece of software designed to do certain tasks for you. This can be creating a reminder, sending an email or gathering information. With simulating the interaction, it feels like real human interaction. Bots are most likely found in chat applications like Slack, Skype or Facebook but you can also find them in your phone or computer, like Apple’s Siri or Microsoft Cortana. There are different ways to interact with a bot. This can be with voice commands like Siri or Cortana or by text with Skype or Slack.

Getting started with the Microsoft Bot framework

As the video explains creating a bot is not rocket since anymore. The getting started documentation will guide you to create and publish a simple bot. To avoid retyping the entire documentation I provided some basic information and you can find the full getting started guide here. Please note there is a minimal requirement of Visual Studio 2015 with the latest updates.

There are 2 downloads required before you start.

  1. “Bot Application” template for Visual Studio 2015 (direct download).
  2. “Bot Framework Channel Emulator” (direct download).

The “Bot Application” template needs to be extracted in the user profile and this will add a new option in the “New Project” list.

bot-framework-vs-2015-project

The “Bot Framework Channel Emulator” is the tool to interact with your bot. The default template is a working project which will return the text received and the total amount of characters.

bot-framework-channel-emulator

Language understanding with LUIS

In order to understand the user input, we need have a kind of translation. Microsoft Reseach has created a service named LUIS “Language Understanding Intelligent Service” which can do this translation.

Language Understanding Intelligent Service (LUIS) offers a fast and effective way of adding language understanding to applications. With LUIS, you can use pre-existing, world-class, pre-built models from Bing and Cortana whenever they suit your purposes — and when you need specialized models, LUIS guides you through the process of quickly building them.
LUIS draws on technology for interactive machine learning and language understanding from Microsoft Research and Bing, including Microsoft Research’s Platform for Interactive Concept Learning (PICL). LUIS is a part of a project of Microsoft Cognitive Services.

 

Source: luis.ai

Check out this Microsoft Build presentation which will guide you step by step to implement LUIS in your bot.

 

My creation named Logit Bot

To get some experience I have created a bot named Logit Bot. My goal is to provide another way to get the latest publications from my blog. Like many other blogs, mine is based on WordPress which has a rich library of plugins. In order to query and receive the latest posts, I installed the plugin “JSON API”. This allows me to directly query my own blog using JSON web API.

Two retrieve the publications in the code I have created two methods. One for receiving the latest publication and another for search a specific topic.

GetPosts will query my blog for the latest posts. By default, the API query will resolve 5 posts. To limit the results I have added the “count=1” is added to the URI path.

In order to search for a specific topic, I also added a method named SearchPosts. This method will use the “get_search_results” API with a specific query. For now I have limited the results with a maximum of 30 posts. A full query will look like “api/get_search_results/?search=docker&count=30”

By using LUIS the input message is validated and based on the intent the action is selected.

I have shared the code on GitHub so if you want to see more of the code you can check it right here.

In order to integrate with a Skype or any other channel, you need to publish the bot public. Because I have a Microsoft Azure subscription I have decided to publish my bot in Azure. I have one remark, the Microsoft getting started guide states to update the “MicrosoftAppId/Password” in the web.config. This can also be done in the application settings within Azure so these are not stored within the code repository.

logit-bot-azure-settings

Once the bot is public, you should be able to register your bot at the Bot Framework website.

logit-bot-register

Once registered you should be able to test it with Skype which looks like this.

logit-bot-introduction     logit-bot-posts

In order to get your bot in the bot directory, you need to publish your bot. I did not achieve this because there are legal requirements like a term of use and privacy policy. While my bot is not published yet you can still try it out in Skype! Click on the “Add to Skype” button to add the Logit Bot to your contact list and let me know what you think!

Conclusion

A Bot is a very elegant way to have simple human-like interaction to achieve certain tasks. There is a lot of potential in this kind of technology in various scenarios. Bots can change how we interact with helpdesks to resolve basic issues like a password reset or to create a ticket. From a consumer perspective, it can check the current bank balance or submit a transaction.

From my experience, it is quite easy to create a very basic bot. With a service like LUIS a bot is getting another dimension. As mentioned at the start the possibilities are endless but as the video explains it also contains a certain risk. I’m very curious if this trend will evolve in a standard. I hope this blog post was useful and inspiring and please share your thoughts and ideas of bots in the comment bellow.