'How to stay in a bots dialog (Bot Framework, C#)
I am currently planing to use dialogs inside my C# bot. I have already designed a complete dialog and implemented it into my current solution but when I test it out, I can only trigger the first part of it.
My bot is configured as following:
protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
string[] PostCodeDialogStartTrigger = new string[] { "trigger1", "trigger2", "trigger3" };
if (PostCodeDialogStartTrigger.Contains(turnContext.Activity.Text) /* Maybe || ConversationState != null */)
{
await Dialog.RunAsync(turnContext, ConversationState.CreateProperty<DialogState>(nameof(DialogState)), cancellationToken);
}
else
{
// First, we use the dispatch model to determine which cognitive service (LUIS or QnA) to use.
var recognizerResult = await BotServices.Dispatch.RecognizeAsync(turnContext, cancellationToken);
// Top intent tell us which cognitive service to use.
var topIntent = recognizerResult.GetTopScoringIntent();
// Next, we call the dispatcher with the top intent.
await DispatchToTopIntentAsync(turnContext, topIntent.intent, recognizerResult, cancellationToken);
}
}
I have a set of strings inside PostCodeDialogStartTrigger. I want that the dialog starts when the users message matches one of the triggers. Otherwise my regular process should start, which includes LUIS and the QnA Maker for one-dimensional Conversations. The thing is that i cant stay in the dialog because the next message wouldnt trigger the dialog again, obviously.
Is there a way to check the ConversationState or UserState and if it has progressed, will the dialog continue?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
