I have created a bot that will automatically update the QnA Maker KB. Currently supports Add operation, where you add QnA pairs in the KB and publish it. I used QnA Maker client library using C#. You can find the documentation here.
On providing the qna pairs by the user, I am calling the Client library.
if ((bool)stepContext.Result)
{
await stepContext.Context.SendActivityAsync(MessageFactory.Text("Here are the details you provided."), cancellationToken);
await stepContext.Context.SendActivityAsync(MessageFactory.Text("Questions - "), cancellationToken);
for (int i = 0; i < QnAData.QuestionPhrase.Count; i++)
{
await stepContext.Context.SendActivityAsync(MessageFactory.Text(QnAData.QuestionPhrase[i]), cancellationToken);
}
await stepContext.Context.SendActivityAsync(MessageFactory.Text("Answer - " + (string)stepContext.Values["Answer"]), cancellationToken);
await stepContext.Context.SendActivityAsync(MessageFactory.Text("Please wait while I update your Knowledge Base."), cancellationToken);
var authoringURL = $"https://{Configuration["ResourceName"]}.cognitiveservices.azure.com";
var client = new QnAMakerClient(new ApiKeyServiceClientCredentials(Configuration["Key"]))
{ Endpoint = authoringURL };
QnAClient.UpdateKB(client, Configuration["KnowledgeBaseId"], (string)stepContext.Values["Answer"]).Wait();
QnAClient.PublishKb(client, Configuration["KnowledgeBaseId"]).Wait();
await stepContext.Context.SendActivityAsync(MessageFactory.Text("I have added your qna pair in the Knowledge Base. Thank you for using QnA Updator Bot Service."));
return await stepContext.EndDialogAsync(null, cancellationToken);
}
else
{
await stepContext.Context.SendActivityAsync(MessageFactory.Text("Request Not Confirmed."));
return await stepContext.EndDialogAsync(cancellationToken: cancellationToken);
}
You can find the full article here : https://jd-bots.com/auto-updater-qna-maker-kb-bot/.
You can watch the video to check the outcome of the bot : https://youtu.be/nSGgph_RXiE.