问题
I am searching for documentation on the integration of QnA Maker API with LUIS in Azure BOT Framework. But after a lot of research, I couldn't find any such document.
If anyone came across the same scenario, please post your efforts.
I am using C# as scripting here.
回答1:
There are several general ways to do it, but it's ultimately up to you as the Bot developer to decide how to structure it.
A general overview is provided in the docs here, but if you want a more code oriented sample, this blog post should help you -
Dialog management with QnA, Luis, and Scorables
In the sample, the LuisDialog acts as a kind of message controller, which guides the user to a certain kind of dialog based on intent. This also can be used to direct a user to a QnA dialog ->
[Serializable]
[LuisModel("YourLuisAppID", "YourLuisSubscriptionKey")]
public class LuisDialog : LuisDialog<object>
{
// methods to handle LUIS intents
[LuisIntent("")]
[LuisIntent("None")]
public async Task None(IDialogContext context, LuisResult result)
{
// You can forward to QnA Dialog, and let Qna Maker handle the user's
query if no intent is found
await context.Forward(new QnaDialog(), ResumeAfterQnaDialog,
context.Activity, CancellationToken.None);
}
[LuisIntent("Some-Intent-Like-Get-Weather")]
public async Task GetWeather(IDialogContext context, LuisResult result)
{
....
// some tasks, forward to other dialog, etc
}
}
This is one way to do it, and a popular one. In this setup, if there is no intent that LUIS can detect, it'll route the user's query to a QnA dialog for the Qna Service (which you train) to answer.
Alternatively, you can create specifically a "Question intent" and try to forward it to QnA that way, if the user's intent was to ask a question. This is trickier however, as this method requires you to manually create custom code to manage the 'scores' of the responses.
Hope this was enough to help you get to what you need!
EDIT - Apologies, fixed the first link.
In addition, I'll just paste 3 common scenarios listed from the docs as ways you can use LUIS + QnA:
1) Call both QnA Maker and LUIS at the same time, and respond to the user by using information from the first one that returns a score of a specific threshold.
2) Call LUIS first, and if no intent meets a specific threshold score, i.e., "None" intent is triggered, then call QnA Maker. Alternatively, create a LUIS intent for QnA Maker, feeding your LUIS model with example QnA questions that map to "QnAIntent."
3)Call QnA Maker first, and if no answer meets a specific threshold score, then call LUIS.
来源:https://stackoverflow.com/questions/47812965/azure-bot-framework-integrate-qna-maker-with-luis