Developing Chatbots using Microsoft Bot Framework and LUIS
In 2017, chatbots have taken a dominant role in both business and consumer use. We have seen devices like Amazon’s Echo and Google Home, which can talk to their users and perform various tasks like playing music, placing orders, reading emails and scheduling meetings for their users. Very soon we are expected to see these boots connecting with various services and LOB applications, like CRM, health insurance and social services to provide all the information in one place, quickly.
Recently I got a chance to work on bots, and while exploring the information related to it I found Microsoft Bot framework – with which it’s easy to build and implement bots. I have built a basic Bot using LUIS (language understanding intelligent service) and Bot framework. Let’s discuss it in detail –
Microsoft Bot framework is a complete framework to build and deploy your bots on various channels (Facebook, Skype and more). Bot framework handles all the complexities of state management, message routing, etc. You only need to build your web API using this framework. For a simple bot, you need only a hosting server like Azure and Bot application, and to add intelligence to your bot there is an additional API from Microsoft cognitive services – LUIS, which helps to parse your message into intents and entities.
The basic architecture of bots, starts from the Microsoft cognitive services, which help to create AI based apps and provide various APIs like Vision, Speech and Language, and Video. The Microsoft cognitive services provides the LUIS which helps to convert messages to the meaningful data.
Figure 1 Microsoft Bot Framework
Language understanding intelligent system (LUIS)
LUIS is an intelligent service which reads the input message from users and convert to the simple Intents and entities, by which you can extract what is the user’s intention and other related entities of message. To work with LUIS, first you need to add an app on LUIS and then define new model using the related intents and entities which later helps you to parse your messages, LUIS models are based on active learning system, which helps us to build more accurate models. LUIS service is integrated within the bot applications so need to add LUIS manually.
Microsoft Bot Framework
Bot framework is a complete setup to building the bots, it manages the conversation state, message routing, adding bots to channels, registration of your bots, and supports the language translation.
We can divide the Bot framework in two parts, one is BOT connector another is Web API.
Bot connector: Bot connector provides various services to enable communication between bot web API and user and including services bot registration, conversation and state management and channel management etc. Bot connecter have a great feature – it gives a power to connect your bot with multiple channels like Facebook, skype Microsoft teams and it is even adding more channels. So, without thinking about the channels we can focus on developing the conversation logic.
Your web API: Your Web API where you write the actual logic of your bot. you create the conversation using dialogs and forms, understand the LUIS results and send the reply to the user. To create a BOT Web API, you will need a bot application template which you can find on Visual Studio Online templates. You can use the template to get started with bot development.it will give you the initial project settings to start. To test the BOT, you will need to get the BOT keys and LUIS keys and Microsoft BOT framework emulator which helps to test the bot.
How conversation can be created with BOTs
While building the bots, we may need to build some strong conversations including message replay, and context to manage the message chain. For that we can use components like Dialogs and FormFlow.
Dialogs: The dialog gives you most of the flexibility you need. But it also requires you to manage message parsing and manage any state your dialog may need to reference. Dialog is the nice tool to build conversation.
FormFlow: It provides a guided conversation with the ability to provide options, do input validation, and confirm user responses. They are a good choice for replacing existing web forms with something more like a natural conversation.
The dialog can be called within another dialog, and this feature allows you to build conversations that can be reused. You can also have an option to call a Form within a dialog. This allow us to build mixed features of both.
In this year, we will see many more bots taking over customer helpdesk to resolve minor issues, and incrementally integrate with other services, like health and other social organizations. In my next blog, I will give a brief of how to build the basic model for language understanding with LUIS.