Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find Knowledge base ID (kbid) for QnAMaker?

I am trying to integrate QnAmaker knowledge base with Azure Bot Service. I am unable to find knowledge base id on QnAMaker portal. How to find the kbid in QnAPortal?

like image 348
Andy Avatar asked Feb 26 '19 05:02

Andy


2 Answers

The Knowledge Base Id can be located in Settings under “Deployment details” in your knowledge base. It is the guid that is nestled between “knowledgebases” and “generateAnswer” in the POST (see image below).

enter image description here

Hope of help!

like image 93
Steven Kanberg Avatar answered Sep 28 '22 08:09

Steven Kanberg


Hey you can also use python to get this by take a look at the following code. That is if you wanted to write a program to dynamically get the kb ids.

import http.client, os, urllib.parse, json, time, sys

# Represents the various elements used to create HTTP request path for QnA Maker 
operations.
# Replace this with a valid subscription key.
# User host = '<your-resource-name>.cognitiveservices.azure.com' 
host = '<your-resource-name>.cognitiveservices.azure.com'
subscription_key = '<QnA-Key>'
get_kb_method = '/qnamaker/v4.0/knowledgebases/'

try:
    headers = {
    'Ocp-Apim-Subscription-Key': subscription_key,
    'Content-Type': 'application/json'
    }

    conn = http.client.HTTPSConnection(host)
    conn.request ("GET", get_kb_method, None, headers)

    response = conn.getresponse()
    data = response.read().decode("UTF-8")
    result = None
    if len(data) > 0:
        result = json.loads(data)
        print 
        #print(json.dumps(result, sort_keys=True, indent=2))
    # Note status code 204 means success.
    KB_id = result["knowledgebases"][0]["id"]
    print(response.status)
    print(KB_id)

except :
    print ("Unexpected error:", sys.exc_info()[0])
    print ("Unexpected error:", sys.exc_info()[1])
like image 25
Islam El-Ghazali Avatar answered Sep 28 '22 08:09

Islam El-Ghazali