Connecting Your Azure Bots with QnA Maker Services is the first step you need perform to connect you Bot with QnA Maker. Azure Bot Service is the Bot-Service powered by the Microsoft Bot Framework and Microsoft Azure. It enables rapid intelligent bot development. Azure Bot Service provides an end-to-end integrated environment for setting up backend services bot development. You can develop a bot, deploy it, connect it to different channels, test it in inbuilt web chat emulator, and modify the code from your web browser itself. Azure QnA Maker helps you in Build, train and publish a simple question and answer bot based on FAQ URLs, structured documents or editorial content very quickly and easily.
When you create a Bot using Azure Bot Service using “QnA Maker” template the Bot wont work unless you link the Bot Service with QnA Maker Service. In case you start testing the default created bot, the bot will send back following response.
From the given message it is clear that you need to provide the QnAKnowledgebaseId and QnASubscriptionKey in App Settings.
First get the Publish API settings from QnA Maker, you will find them from the Sample HTTP Request.
Go back to the Web App Bot and navigate to the Application Settings available under App Service Settings. There you will find two app settings entry for QnAKnowledgebaseId and QnASubscriptionKey. Update the settings values and save it.
Post that if you go back and test the Bot, you will able to get the bot responses based on the QnA Makers Questions and Answer.
If you want to Integrate through application code, you need to update the keys in the Web.Config file. Enter the same values for QnAKnowledgebaseId and QnASubscriptionKey in appSettings
Once Web.config is updated you can use following set of code to read the config file and send a call back to QnAMaker Services.
var qnaSubscriptionKey = WebConfigurationManager.AppSettings["QnASubscriptionKey"]; var qnaKBId = WebConfigurationManager.AppSettings["QnAKnowledgebaseId"]; if (!string.IsNullOrEmpty(qnaSubscriptionKey) && !string.IsNullOrEmpty(qnaKBId)) { await context.Forward(new BasicQnAMakerDialog(), AfterAnswerAsync, message, CancellationToken.None); } else { await context.PostAsync("Please set QnAKnowledgebaseId and QnASubscriptionKey in App Settings. Get them at https://qnamaker.ai."); }
Hope this helps.
Geek's Choice
Pingback: QnA Maker Azure service and connect with Knowledge Base