Cognitive Services QnA Maker Samples in Python

These REST samples show you how to programmatically create, update, publish, and replace a QnA Maker knowledge base, amongst many other ways to interact with it. All samples are in Python. To view these same samples in other languages:

cognitive-services-qnamaker-csharp

cognitive-services-qnamaker-java

cognitive-services-qnamaker-nodejs

Features

Included are the following samples:

All REST samples revolve around what you can do with a knowledge base, which is made up of FAQs or product manuals where there is a question and an answer. QnA Maker gives you more control over how to answer questions by allowing you to train a chat bot to give answers in a variety of ways that feels more like natural, conversational exchanges.

Getting Started

Prerequisites

For each sample, a subscription key is required from your Azure Portal account.

With the exception of creating a new knowledge base, these samples will require your QnA Maker account knowledge base ID. To find your knowledge base ID, go to My knowledge bases and select View Code on the right. You'll see the http request and your knowledge base ID is in the topmost line: for example, POST /knowledgebases/2700e6b9-91a1-41e9-a958-6d1a98735b10/.... Use only the ID.

Run the sample

  1. Create a new python project in your favorite IDE or create one in PyCharm, which has a free evaluation version. If using Pycharm, it is easiest to create one project, then fill it with python files (add to your root folder) for each sample.

  2. Copy/paste the sample you want to test into a python file.

  3. Add your Azure subscription key and your knowledge base ID (if applicable) at the top of the file where indicated.

  4. Run the sample. In PyCharm, go to Run > Edit Configurations and add a new configuration (click the + sign) and choose which script path you want to use (select your python file), then select OK. Run the sample now.

  5. Go to your knowledge bases in qnamaker.ai to see changes.

Quickstart

References

QnA Maker V4.0