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:
Included are the following samples:
- Create knowledge base. Create a brand new knowledge base with given FAQ URLs. You may supply your own.
- Update knowledge base. Update an existing knowledge base by changing its name.
- Publish knowledge base. Publish any existing knowledge base to the host your Azure account.
- Replace knowledge base. Replace an entire existing knowledge base with a custom question/answer pair.
- Download knowledge base. Download the contents of your existing knowledge base in JSON.
- Delete knowledge base. Delete an existing knowledge base, which has already been published.
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.
For each sample, a subscription key is required from your Azure Portal account.
* To create a new account/resource for QnA Maker, see Create a Cognitive Services API account in the Azure portal. You may need to 'Search in Marketplace' for QnA Maker if you don't see it in the list given.
* For existing accounts, the key can be found in your Azure Portal dashboard in your QnA Maker resource under Resource Management > Keys.
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
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.
Copy/paste the sample you want to test into a python file.
Add your Azure subscription key and your knowledge base ID (if applicable) at the top of the file where indicated.
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.
Go to your knowledge bases in qnamaker.ai to see changes.
- Quickstart: Create a new knowledge base in Python
- Quickstart: Update a knowledge base in Python
- Quickstart: Publish a knowledge base in Python
- More quickstarts coming soon... in the meantime, refer to Quickstart for Microsoft QnA Maker API with Python for all quickstarts in minimal format.