Monday, 12 March 2018

Bot Framework Tutorial 3: Understanding Bot Templates (in Azure)

It is quite interesting to see how Microsoft makes it easy for developers and even those without much programming knowledge to used available tools to develop amazing application. The Bot Framework is not an exception.

As you know, the Microsoft Bot Framework is a set of tools provided by Microsoft that allows you to build bots, which are apps that interacts with the users in a conversational manner. In this lesson, we would examine the concept of bot templates, the various templates available and the template to use as a beginner.

We would examine the following
  1. What are Bot Templates
  2. Basic Template
  3. Form Template
  4. Language Understanding 
  5. Question and Answer
  6. Proactive
  7. Final Notes

1. What are Bot Templates?

In the Azure portal, a template is said to 'provide a simple starting point for your bot'. This means that some of the basic setup for the bot would have been provided by the template.
When you start your bot application with a template, most of the bot building process is already done and so you  will have very little customization to make.
In the hands-on tutorial that I would post later, you will see that you can create a complete bot using  a template.

Let's now look at some of the available templates in Microsoft Azure.

2. Basic Template

Microsoft defines the basic template as 'A bot with a single dialog that echoes back the user input'.
This bots responds to the user input and contains the basic file needed to start runing.
When you create a bot using the basic template, the user's input is echoed back to the output. For example:

Input: My name is Kindson The Genius
Output: You said 'My name is Kindson The Genius'

3. Form Template

Microsoft defines the basic template as 'A bot that shows how to collect input from a user using a guided conversation using FormFlow'.
A form bot is designed to gather a specific set of information from the user. For instance, a bot that is build to collect users menu order would  prompt for such information as:
type of meal
type of drink
quatity of water etc

4. Language Understanding Template

Microsoft defines the basic template as 'A bot that shows how to handle natural language using the Cognitive Services LUIS API'.
LUIS stands for Language Understanding Intelligent Service.
This type of bot tries to process user input based on Natural Language Understanding. Think of apps like Siri in Apple devices or Cortana in Microsoft windows. You can actually speak to these apps as if you are talking to someone. That is what this type of the bots are all about.Is it not amazing that Microsoft now makes it easy to build these apps!

Take for example, you send a message like "what is the latest new in sports?", the bot can use the LUIS API  to interprete the meaning of this message and give the correct response.

Using LUIS, you can quickly deploy an HTTP enpoint that would interprete the user's input in terms of the intention that it conveys(find news) and the key entitities that are present (sports). LUIS enables you to specify a set of intents and entities that are relevant to the application, and the give you support through the process of building a language understanding application.

When you create a bot that uses LUIS template, Bot Service creates a corresponding LUIS applicaiton that would work with your bot.

5. Question and Answer Template

Microsoft defines the basic template as 'A bot that distills informaiton into conversational, easy-to-navigate answers'.
This is most easy to undestand template because it simply involve providing answers to user questions based on a pre-define question-and-answer knowledge base.

This template leverages on QnA Maker to format the questions and answers provided.

To use this template you need to sign in to QnA Maker and create a new service there. This would provide you with the knowledge base ID and a subscrition key that you would enter into your App Settings values for QnAKnowledgebaseId as well as QnASubscriptionKey respectively.
Once this values are updated, then your bot can answer users' questions provided that those questions exist in the QnA knwledge base.

6. Proactive Template

Microsoft defines the basic template as 'A bot that shows how to use Azure Functions to trigger events in Azure bots'.
This is the most cognitive of all the bots as you can see from the name. This type of bot can actually serve as an office assistant or a secretary, helping you perform various routine tasks such as booking a meeting, placing an order, sending emails, setting an alarm etc.
Normally, messages sent to this bot relates to the user's prior input. At certain times, the bot may send the user information that is not related to user's previous input.
An example would be when a user books a meeting, then the bot could proactively notify the user when the meeting time reaches.

7. Final Notes

This variaty of template makes possible for practically everyone to be able to leverate on Microsoft tools to build bots.  If you are a beginner, I would recomment starting with the Basic Template. Once you have your head around the basic template, you can then proceed to try  Form Template, then Question and Answer Templates. With time you will find out that you can seemlessly use any of the template depending of the type of bot you want to build.