Creating An Azure Q&A / FAQ Chat Bot

QnA webpage

I’ve taken a look at using node.js and Python to create a chat bot in the past but never really progressed the idea, mainly because my website doesn’t currently need a chat bot. However after completing my recent project around text sentiment using Azure cognitive services I thought I would take another look at a chat bot, especially as Microsoft offer a training module on the subject.

This project requires an Azure subscription. If, like me, money is a little tight then consider the free trail subscription. I’ve been using the free subscription for my projects and although its nearly over it has allowed me to play / learn more about Azure.

The type of chat bot I’m creating today is a FAQ (Frequently Asked Questions) chat bot and it is build using Microsoft’s QnA Maker. This type of chat bot is generally but on websites and used to answer customer questions that would have been (or may still be) held in FAQ. I see it like an interactive search function.

The QnA Maker can be found at: https://www.qnamaker.ai/ , open it up and login using your Azure account.

QnA webpage
QnA webpage

At the top of the QnA Maker page is an option to “Create a knowledge base” , which is aptly named as it is where our knowledge base (KB) is created. Step 1 is to create the QnA service in Azure.

geektechstuff_q_n_a_create_kb
QnA Create Knowledge Base

The Azure settings may seem a little daunting, especially when subscription pricing is mentioned. For it’s creation the following is needed:

  • A unique name
  • A subscription (Free Trial if your going the free route)
  • A pricing tier (F0 if using the free trial)
  • A location close to you
  • A resource group (I’m using the same group as my text sentiment Twitter bot)
  • A search location; try to keep it the same as the location you chose above
  • A unique app name; a green tick will confirm if the app name is unique
geektechstuff_create_qna
QnA Azure creation screen

With all those details in, click deploy and give Azure a few minutes to complete the deployment. Then reopen the QnA “Create a knowledge base” page and chose the appropriate drop down settings to connect your QnA service to your knowledge base.

QnA creation step 3 and 4
QnA creation step 3 and 4

 

Step 3 is giving the QnA knowledge base a name, make it something relevant and remember it can be changed later on if needed.

Step 4 is populating the knowledge base with a URL or file (.pdf, .docx, .xlsx). The format for the URL / file should be:

Question with a question mark (?) at the end.

Answer.

e.g.

Which is the best website for geeky tech stuff?

The best website is geektechstuff.com as it provides lots of geeky tech stuff

For the chit-chat option I would recommend reading https://docs.microsoft.com/en-us/azure/cognitive-services/qnamaker/how-to/chit-chat-knowledge-base as it gives a break down of the three types (Professional, Comic, Friend) and helps to understand the type of response you will get from each type. Choose a type (or none) and click “Create your KB“.

qna_time_to_publish_geektechstuff
QnA Publish

QnA will then allow you to test the knowledge base via a simple chat window and at the top of the page is the option to publish. Click publish and await for the success message.

A successful deployment
A successful deployment

Note: Make sure to record the postman / curl information as you will need it later.

With the QnA knowledge base created, open a new browser window and open the Azure Portal (https://portal.azure.com/). Click “Create a resource” on the left of the portal screen and search for “bot“.

geektechstuff_search_web_app_bot
Make sure to chose Web App Bot

For this Q&A / FAQ bot we will be using a “Web App Bot“. As before Azure will now ask for a unique name, a subscription model and the resource group (same as the QnA resource group) details. Azure will also ask for a SDK (I’m using version 3) and a SDK language (I’m using C#). With the rest of the setting left to default, hit create and give Azure a minute or two to create the resource.

geektechstuff_azure_bot_application_settings
Azure Bot Application Settings

Once the bot is created open the “Application Settings” from the bot menu and navigate down the window until you can see the options for:

  • QnAAuthKey
  • QnAEndpointHostName
  • QnAKnowledgebaseId
geektechstuff_bot_application_settings_QA
Lots of Bot App Settings

These values were on the successful deployment page earlier under the “postman” option.

QnAAuthKey = Authorization EndPoint Key

QnAKnowledgebaseId = the alpha-numeric bit in the POST address, e.g.  POST /knowledgebases/THIS_BIT_HERE/generateAnswer

QnAEndpointHostName = Host

With those entered make sure to press “Save” and then the Q&A / FAQ bot is ready for testing. To test, click “Overview” on the left side and then choose “Test:” and start typing.

geektechstuff_test_cfaq_chat_bot
Testing FAQ chat bot

 

 

 

One thought on “Creating An Azure Q&A / FAQ Chat Bot

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.