Reputation: 355
I'm trying to run a waterfall dialog from my MainDialog
. It appears that when I run await dc.BeginDialogAsync(nameof(OnboardingDialog));
, I am put into the first step of my OnboardingDialog
, which is good. However, when I respond to the first prompt within that dialog, I am passed back into my RouteDialog
. It seems like the reason for this is because within my DialogBot.cs
's OnTurnAsync
method, the dc.ActiveDialog
is equal to null
, and so my MainDialog
gets called again. Here's my OnTurnAsync
:
public override async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken))
{
var dc = await _dialogs.CreateContextAsync(turnContext);
if (dc.ActiveDialog != null)
{
var result = await dc.ContinueDialogAsync();
}
else
{
await dc.BeginDialogAsync(typeof(T).Name);
}
// Save any state changes that might have occured during the turn.
await ConversationState.SaveChangesAsync(turnContext, false, cancellationToken);
await UserState.SaveChangesAsync(turnContext, false, cancellationToken);
}
When MainDialog
gets called from the await dc.BeginDialogAsync(typeof(T).Name)
, it hits the RouteAsync
method which could be simplified to:
protected override async Task RouteAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken))
{
await dc.BeginDialogAsync(nameof(OnboardingDialog));
}
Then, when I respond to the first step in OnboardingDialog
, I just hit the await dc.BeginDialogAsync(typeof(T).Name);
again as dc.ActiveDialog
is null, instead of having my dialog continued by var result = await dc.ContinueDialogAsync()
.
I've tried a few things with saving/setting state on my DialogState
created from accessors but nothing seems to make my bot aware that it should be in a waterfall dialog. I can share the project but not in a public place. Let me know if anyone has hints for how to save ActiveDialog
's state. Thanks.
Upvotes: 0
Views: 358
Reputation: 7241
OP mentioned in comments it only happens in Cosmos. So, here's another user who just experienced this.
And, the answer.
For now, it should work if you remove the
PartitionKey
parameter fromCosmosDbStorageOptions
. You will likely need to delete your Container or use a different name, since yours is currently partitioned. Easiest to just delete your Container and let the bot make one for you.There's currently a bug in all the Bot Builder SDKs around reading from partitioned databases when the partitionKey is supplied. Tracking the issue here
Upvotes: 1