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

Is there a way for LUIS/QnA maker to ignore user's answer when it came from a choice prompt?


LUIS/QNA keeps triggering intents that are related to the choices in a choice prompt.

My question is there a way for LUIS/QNA to ignore user inputs that are from a choice prompt? or for choice prompt answer not appear as user inputs so LUIS/QNA will leave the choices alone?

For example in this choice prompt. This will not reach SecondStepAsync because LUIS/QNA will detect the choice of the user as an intent similar to the label of the choice and do something else.

    private static async Task<DialogTurnResult> FirstStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken = default(CancellationToken))
    {
        choices.Add(new Choice { Value = "Choose Red"});
        choices.Add(new Choice { Value = "Choose Green"}});

        return await stepContext.PromptAsync(
            ChoicePromptId,
            new PromptOptions
            {
                Prompt = MessageFactory.Text($"Welcome to FAQ! Choose the number of the question or type your own question."),
                Choices = choices,
            });
    }

    private static async Task<DialogTurnResult> SecondStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken = default(CancellationToken))
    {
        var choiceResult = (stepContext.Result as FoundChoice).Value.ToLower();

        switch (choiceResult)
        {
            case "choose red":
                await stepContext.Context.SendActivityAsync(MessageFactory.Text($"..."));
                break;

            case "choose green":
                await stepContext.Context.SendActivityAsync(MessageFactory.Text($"..."));
                break;

            default:
                break;
        }

        return await stepContext.NextAsync();
    }

Solution

  • LUIS is an independent service that just takes an input i.e. an utterance and reverts with an output i.e. intent.

    Now if you want LUIS to ignore the Choice Prompt utterances, then you will have build that in your OnTurnAsync method itself.

    You can take look here in this tutorial. Based on the responses given by user, you will have use appropriate services. This is how your onTurnAsync psuedo-code should look like

    OnTurnAsync()

    Record the utterance
    Check what was the active dialog. <Documentation [here][2]>
    IF (!choice Dialog)
      call LUIS
    else
      /*
        your code here.
      */