Integrate LUIS, QnA Maker and Personality Chat in your Bot – Part 1

After reading the comprehensive documentation of Azure Bot Service, correcting a few logical mistakes, solving syntax problems and fixing some READme docs, I’m going to tell you how easy and straight forward is to integrate LUIS, QnAMaker & Personality Chat (an AI Labs project) from Microsoft.

This will be a slightly longer post as I will brief on each step in detail on how to achieve each target required to combine all of the goodness in one bot. I assume you’re already aware of basics of Bot Framework.

Organizations who are looking for their own branded Virtual Agents can have a look at the templates and the docs provided by the Bot Framework Team. 

In this post, as a real life business case, we will see how can we create an Airline Bot (I name it as: AMA Airlines). This bot will have following features;

  1. Flight Tracking (Status)
  2. Flight Booking (New / Modification)
  3. FAQs (General Questions and Answers) 
  4. Small Talk Capabilities (Chit-Chat)

In order to kill two birds with one stone, we will start with simpler stuff i.e. FAQs and Small Talk Capabilities. For FAQs, we will be using QnA Maker and for latter, we will be using the Personality Chat. 

QnA Maker & Personality Chat

As you’re already aware, QnA Maker enables you to create a knowledge-base (KB) from your semi-structured content such as Frequently Asked Question (FAQ) URLs, product manuals, support documents and custom questions and answers where as Personality Chat is an AI Labs project of Microsoft which has enhances your bot’s conversational capabilities, by handling small talk, in line with a distinct chosen personality (in our case, it will be professional)

All you have to do is to create your QnA Maker service. The first step asks you to create a service in your Azure (get a free trial if you just want to try out first). After creating the service, specify the credentials, name and URL of the FAQs (here, you can put your airline’s FAQ). In addition to this, you can also add multiple links, custom responses and much more. 

In Step 4, you will see an option of adding Chit-chat capabilities, you can choose Professional in this case.

Create the KB and it will take you to the landing page where you can tweak your questions and answers

Note:

If you’re satisfied with the test, you can then publish it. Once you click on the publish, you will see deployment details. You should copy them (probably Notepad) as you will need them later.

 

You’ve successfully setup the QnA Maker w/ Chit-Chat now. In my following post, I will tell you how you can integrate this into your bot. 

LUIS (Language Understanding Intelligent Service) 

LUIS is one of the most used and famous Cognitive Services that applies custom machine-learning intelligence to a user’s conversational, natural language text to predict overall meaning, and pull out relevant, detailed information.

Your LUIS app can easily be created using LUIS Portal. However, I would recommend you to read LUIS docs as its content developers have done an awesome job in defining the best practices and several business use-cases. If you follow the best practices, you will surely see the better outcome of your app model. 

For the sake of simplicity and your ease, I have already made a LUIS app which you can import, add BookFlight utterances and utilize the already added TrackFlight intent. 

So, after testing the app, if you’re satisfied with the result, you can then publish the app. 

Note: 

After publishing the app, you must note AppID and Authoring Key from Manage section of your LUIS app. 

The CLI Walk

This part features Microsoft Bot Framework 4 (BFv4) SDK with C#.

In case you are looking for an extensive support on .NET and Nodejs stack then you can follow James Mann or Michael Szul’s series on BFv4. We also have an opensource Bot Builder Community Project on GitHub where you can find out reusable components for your bots. 

So first of all, you can just download this template and try to create your project. This (Echo Bot template) will create the .bot file automatically for you and then you will be using one of the Bot Builder tools MSBot to add LUIS and FAQ with your configuration file (BotConfiguration.bot). Please refer to this link in case you want to more about bot builder tools and their installation guide. 

Now, to add LUIS to your bot file, you can use the below syntax in your CLI;

msbot connect luis --name "<appName>" --appId <appId> --version 0.1 --authoringKey <authoringKey>

For FAQ, please use below to add to your MSBot; 

msbot connect qna --name "<appName>" --kbId <knowledgeBaseId> --subscriptionKey <subscriptionKeyInAzure> --endpointKey <endpointKey> --hostname "https://amaqna.azurewebsites.net"

Note: Subscription Key is not Subscription ID in Azure but it is the access key which can be found in the keys section of your FAQ Cognitive Service. 

The Great Dispatch Tool

Now, you have got LUIS & QnA Maker added to your bot’s configuration file. The challenge is when to invoke what, Chit-Chat (Personality Chat), QnA Maker or LUIS? The answer is, Dispatch Tool will decide when.

Dispatch is a tool to create and evaluate LUIS models used to dispatch intent across multiple bot modules such as LUIS models, QnA knowledge bases and others (added to dispatch as a file type).

Again, you can use CLI to create Dispatch which is simple, straight forward and fast. Below is the syntax to initialize the Dispatch followed by the creation;

dispatch init --bot BotConfiguration.bot
dispatch create

You can also evaluate your dispatch model by just using the below syntax and make necessary changes as per the generated Summary (you won’t spend too much time on it if you plan your bot properly) 

dispatch eval

By this time, you must be equipped with your LUIS, FAQ and Dispatch configuration and necessary files must have been generated. 

In my next post, we’ll deep dive into the code and I will explain how straight forward it is to integrate all of the above seamlessly along with the new Dialogs. 

Until next time, happy coding!

 

Related Posts