Create an Interactive Chat Bot Part 1

When I first heard of Microsoft's investments into Bots I must admit I didn't see the point. Then actually seeing them in action I was sold - it's a great new communication channel you can create for users. It's also potentially very low hanging fruit. As an example take QnA Maker.

QnA Maker is a (currently) free tool from Microsoft that allows you to create a Chatbot from semi-structured FAQ documents or web pages. This takes just a few minutes. The site is https://QnAMaker.ai

Once you've signed up you can click 'Create New Service' on the top menu.

You're presented with a page to name your Service (your Bot) and choose the sources of the FAQ you'd like to setup.

In my case I named the Bot SharePointFAQBot and uploaded a document that contained a series of questions and answers; How do I check-in a document? etc

If my FAQ was online I could have entered the URL(s) also, though a word of warning this doesn't work with authenticated links, so ironically if your FAQ was already in SharePoint you couldn't enter that url.

QnAMaker churned for just a couple of seconds before telling me it was ready. It had identified 22 Question / Answer pairs, and puts them in a tabular format for editing and review;

One of the Microsoft guys told me that when they first started trialing Bots the majority of questions were "Tell me a joke" and "What's the weather". As such it's perhaps best to put in default answers to these questions - to keep users engaged. They'll be surprised to get an answer to flippant questions and may stick with the channel as a result. You can do this by clicking 'Add new QnA Pair'.

I added a couple of jokes here with slightly different wording for the questions. One of the clever things here is that when QnA Maker receives a question it doesn't need an exact match between your question wording and that entered. It's going to have a go at matching (behind the scenes it assigns a probability score against its guess which you can use in your code - topic for a later blog post).

After saving those changes we can now test the Bot by clicking that option in the left-hand menu.

You ask questions as a user will and the answers are displayed. However check out the options on the left I've highlighted in red. Other best guesses at which answer should be displayed are shown there. By clicking on preferred answers you can train the AI to work better during real interactions! I envisage the Business Analysts and the human interaction experts going through this to make sure the channel will be effective when used in production.

Once this is fit for purpose you can click the Publish button, and some anti-climax ensues;

When published what you have is a working web service you can pass JSON formatted questions to and get a response. To get this in production now requires using Azure Bot Service, or coming up with some solution to call the REST interface and display the responses. In short, the user friendly aspect of this ends at this screen. Business users can maintain the FAQ text and conversations nicely with this tool, but IT intervention is needed to deploy. (Which is why this blog post if part 1).

Note that I've greyed out part of the screenshot above, hiding my Ocp-Apim-Subscription-Key value. This is sensitive information because it can be used to call your Bot and use your resources, so keep it private! (It can be reset if you believe it's been divulged though).

There are some remaining things to keep in mind about QnAMaker;

  • It is still in Preview so is subject to change
  • QnA Maker is free with limts;
    • Default limit of 10k transactions per month, 10 per minute
    • A free premium tier is available on request (fill in a form on the site) giving you higher usage limts;
      • 500k transactions per month, 1000 per minute
    • There is a 20 Mb knowledge base size limit (but that's a lot of QnA pairs)
  • Your QnA pairs can be in any language (though service has been most thoroughly tested in English)
  • If providing FAQ in multiple languages create a separate service per language

That's about it. In the next post on this topic I'll show some of the different ways we can publish this content onto SharePoint, Mobiles, or whatever channel we choose in fact.

It may help you to know that I created a video outlining the steps above and that can be viewed here;