I have QnaMaker and LUIS integrated into my bot. I want the user to be able to ask questions in between conversation. I already discovered that the problem is, that the bot always looks in luis and qna first, before processing the input of the user.
For example if I have a choice prompt with "Start now" and "Stop now", Luis or qna will interrupt and process the input, reprompt the dialog again resulting in an infinite loop and never reaching the next step.
I think this is bad design on my part. is there a way for the next step to process the result first? If it did not recognize the result, luis and qna should then process the input.
private async Task<bool> IsTurnInterruptedDispatchToQnAMakerAsync(ITurnContext turnContext, string topDispatch, string appName, CancellationToken cancellationToken = default(CancellationToken))
{
var dc = await _dialogs.CreateContextAsync(turnContext);
const string qnaDispatchKey = "q_xxxxxxxx";
if (topDispatch.Equals(qnaDispatchKey))
{
var results = await _services.QnAServices[appName].GetAnswersAsync(turnContext);
if (results.Any())
{
await turnContext.SendActivityAsync(results.First().Answer, cancellationToken: cancellationToken);
}
if (dc.ActiveDialog != null)
{
await dc.RepromptDialogAsync();
}
return true;
}
return false;
}
return false;
}
on OnTurnAsync()
var interruptedQnaMaker = await IsTurnInterruptedDispatchToQnAMakerAsync(turnContext, topDispatch, QnaConfiguration, cancellationToken);
if (interruptedQnaMaker)
{
await _basicAccessors.ConversationState.SaveChangesAsync(turnContext, false, cancellationToken);
await _basicAccessors.UserState.SaveChangesAsync(turnContext, false, cancellationToken);
return;
}