Microsoft QnA Maker
The Teneo QnA Maker connector allows Teneo and Microsoft developers to connect a QnA Maker knowledge base with a Teneo solution. Teneo developers leveraging QnA Maker, which is part of the Azure Cognitive Services, will benefit from Microsoft’s state-of-the-art toolkit, which will allow them to develop a bot based on existing data in just minutes. In Microsoft’s own words, developers will be able to build, train, and publish sophisticated bots using FAQ pages, support websites, product manuals, SharePoint documents, or editorial content through an easy-to-use UI or via REST APIs.
At the same time, other related, more complex use cases can be built in Teneo, using Studio’s intuitive graphical UI and powerful flow builder, with support for 86 languages, multi-turn dialogues, context, custom channel behaviors, custom entities, sentiment analysis, and much more.
In this guide, we will explain how to get started in QnA Maker and seamlessly use a trained QnA Maker knowledge base within Studio.
The Teneo QnA Maker connector is made up of:
- A pre-built Teneo solution that contains the integration with Microsoft’s QnA Maker
- A sample QnA Maker knowledge base to get started
In order to use this solution, you will need a Azure subscription. Create a free account before you begin. You will also need a QnA Maker resource, created in the Azure portal. You will need to download and import the solution and download the QnA Maker knowledge base. See instructions on how to do this here.
Teneo QnA Maker Connector Solution
The following table lists and describes the contents of the solution.
|MS QnA Maker||Folder||This is a folder containing the main flow that handles questions about the QnA Maker knowledge base.|
|MS QnA Maker Connector Flow||Flow||This flow retrieves the use-case-related question, stores it, and passes it to the QnA Maker integration, then extracts the response and passes it back to the user.|
|qnaMakerQuestion||Flow variable||This flow variable stores the user question to be passed on to the integration.|
|qnaMakerAnswer||Flow variable||This flow variable stores the response from the published QnA Maker knowledge base.|
|qnaMakerApiSubscriptionKey||Global variable||This global variable contains the QnA Maker Authorization Endpoint key, used as a header by the integration.|
|qnaMakerKbEndpoint||Global variable||This global variable contains the endpoint URL for the QnA Maker trained and published knowledge base, used as a header by the integration.|
|Follow up of flow||Scripted Context||This global scripted context allows for a very seamless implementation of follow-up questions, like 'Who did Elvis marry?' followed by a related questions like 'When did he marry?'.|
|QnA Maker Integration||Integration||The QnA Maker integration calls the QnA Maker API, passing the user request and retrieving the response, which is stored in a string variable for easy access within the flows.|
Microsoft QnA Maker Knowledge Base
For this example, the knowledge base we will be using is an FAQ about Elvis Presley. The following instructions detail how to access and set up the knowledge base.
Sign up for an Azure Cognitive Services subscription
If you don’t have an Azure Cognitive Services subscription, go to Cognitive services and sign up for free. You can use the free tier to do everything that is included in this guide.
Set up a QnA Maker service in Azure
Before you can create any QnA Maker knowledge bases, you must first set up a QnA Maker service or resource in Azure. You will only need to do this once.
- Go to Azure Portal.
- Follow Microsoft’s step-by-step guide to create a QnA service or resource in Microsoft Azure (find it here).
Create a new QnA Maker knowledge base
The next step will be connecting your QnA Maker service or resource to a new QnA Maker knowledge base.
- Go to QnA Maker.
- Refer to this Microsoft tutorial in order to create your own QnA Maker knowledge base.
- Name your knowledge base.
- To populate your knowledge base, you will be able to skip the step of extracting data, as we have already created a knowledge base TSV file using the data from Graceland's FAQ page about Elvis. You don't need to do anything with this file just yet, as we will import it later, but you can download it here.
- Click on 'Create your KB' at the bottom.
Import knowledge base TSV
Once your knowledge base has been created, navigate to the 'Settings' section of your knowledge base:
- Under 'Settings', scroll down to 'Import knowledge base' and select 'QnAs'.
- Locate your ElvisFacts-QnAMaker-Kb.tsv file. !!! If you would like to create a different knowledge base from a website or by adding specific data files, feel free to replace this file with the new one.
- Click on 'Import knowledge base'.
- Navigate to the location where your TSV file is stored and select it.
- Click on 'Replace' when you see a message warning you about overwriting existing knowledge bases (you should have an empty knowledge base at this point).
- Wait until you see a message stating the import has been successful and click 'OK'.
You should be redirected to the 'Edit' section in your knowledge base and you should have a total of 27 QnAs about Elvis in your knowledge base at this point.
- Save and train your QnA Maker knowledge base by clicking on 'Save and train' at the top right corner to have your intents and answers created.
Publish your knowledge base
- Go to the 'Publish' section at the top and click on 'Publish':
- You should now see a message saying that the knowledge base has been published successfully, as well as a text field showing deployment details for a sample HTTP request in Postman and Curl. Under the 'Curl' tab, please copy the following information and store it somewhere, as you will need it later:
- your POST URL (for example
- the value for Authorization: EndpointKey (for example
Working on the Solution in Teneo
Now it is time to work on the solution inside Teneo in order to connect it to your Microsoft QnA maker.
Set up your Global configuration
Once your pre-built solution has been imported, please add your Lexical Resources (SOLUTION → Resources → Lexical), and then navigate to Globals and map the above values to these two Global Variables:
|Variable Name||Example Value||Description|
|qnaMakerApiSubscriptionKey||Authorization Endpoint key|
As an alternative to populating those Global Variables, you could also add those two parameters as input parameters in Try Out as in the following picture:
Test your MS QnA Maker flow
Your 'MS QnA Maker Connector Flow' will handle the extraction of the information and the connection with the integration. It will also allow you to provide different fallbacks if the user question is not found in the QnA Maker knowledge base or if the Global configuration has not been set up. The main trigger of your flow is based on Elvis-related keywords. Please remember to adapt your condition if your knowledge base is different.
The following dialogue was created via QnA Maker, published as a knowledge base and available within Studio in less than 30 minutes, after extracting the information from Graceland’s FAQ page about Elvis: https://www.graceland.com/elvis-faq
User: When was Elvis born?
Bot: Elvis was born on January 8, 1935.
User: When did he die?
Bot: Elvis Presley passed away due to heart failure August 16, 1977, at Graceland in Memphis, Tennessee. He was 42 years old.
User: What was his first performance?
Bot: He first performed at Overton Park Shell on July 30, 1954.
User: And his first movie?
Bot: 'Love Me Tender' (1957) was Elvis' first movie.
User: How many movies did Elvis make?
Bot: Elvis made 31 feature films and 2 concert documentaries.
- Download the solution here.
- Dowload the QnA Maker sample KB here.
- Import the solution into Teneo. For more details see: How to import solutions.