Search code examples
botframeworkazure-language-understandingazure-qna-maker

Does Microsoft QnA maker use LUIS?


I am planning to use QnA maker, but does it use LUIS in the background ? If the questions are asked in a different way than the one trained to QnA maker, will it respond ?


Solution

  • does it use LUIS in the background ?

    No, but you can Combining Search, QnA Maker, and/or LUIS.

    According to the document, the following three ways are suggested to implement QnA together with LUIS.

    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.

    Here I post a code sample just for the third approach wrote in C#.

    In MessagesController call QnA Maker first:

    if (activity.Type == ActivityTypes.Message)
    {
        await Conversation.SendAsync(activity, () => new Dialogs.MyQnADialog());
    }
    

    In MyQnADialog, see if there is matched answer, if not, call LUIS:

    [QnAMakerAttribute("QnASubscriptionKey", "QnAKnowledgebaseId", "No Answer in Knowledgebase, seraching in Luis...", 0.5)]
    [Serializable]
    public class MyQnADialog : QnAMakerDialog
    {
    
        protected override async Task DefaultWaitNextMessageAsync(IDialogContext context, IMessageActivity message, QnAMakerResults result)
        {
            if (result.Answers.Count == 0)
            {
                await context.Forward(new MyLuisDialog(), this.ResumeAfterNewOrderDialog, message, CancellationToken.None);
            }
            context.Wait(this.MessageReceivedAsync);
            //return base.DefaultWaitNextMessageAsync(context, message, result);
        }
        private async Task ResumeAfterNewOrderDialog(IDialogContext context, IAwaitable<object> result)
        {
            var resultfromnewdialog = await result;
            context.Wait(this.MessageReceivedAsync);
        }
    
    }