Sebastian Zolg
Sebastian Zolg

Reputation: 1961

Enterprise Bot template not resuming MainDialog in single step WaterfallDialog

When starting a dialog saying I want to talk to a human using the Enterprise Bot Template, the WaterfallDialog starts, displays the contact card and ends the flow by calling EndDialogAsync().

However, MainDialogs CompleteAsync() method is never called. Thus the bot is not asking for further help.

I noticed that in multistep WaterfallDialogs this works correctly. I believe that this has somehow to do with the RouterDialog.cs implementation, but could not make sense of it.

EscalateDialog.cs

private async Task<DialogTurnResult> SendPhone(WaterfallStepContext sc, CancellationToken cancellationToken)
{
    await _responder.ReplyWith(sc.Context, EscalateResponses.ResponseIds.SendPhoneMessage);
    return await sc.EndDialogAsync();
}

MainDialog.cs

protected override async Task CompleteAsync(DialogContext dc, CancellationToken cancellationToken = default(CancellationToken))
{
    // The active dialog's stack ended with a complete status
    await _responder.ReplyWith(dc.Context, MainResponses.ResponseIds.Completed);
}

Upvotes: 2

Views: 86

Answers (1)

Sebastian Zolg
Sebastian Zolg

Reputation: 1961

As discussed in comments, this issue no longer occures in the latest enterprise bot template. I verified this myself today using version 4.3.0.171 of Enterprise Bot Template from marketplace.

If you're as me started with a previous version of the template and you want the same behaviour, then you have to change the RouterDialog.cs file.

Simply add the following lines of code in the OnContinueDialogAsync handler method:

...
case DialogTurnStatus.Empty:
{
    await this.RouteAsync(innerDc);
    // FIX: Waterfalls with no turns should Complete.
    if (innerDc.Stack.Count == 0)
        await CompleteAsync(innerDc);
    break;
}
...

After knowing where the problem came from, I could find the related GitHub PR merged on January 30 2019.

Side by side comparision of the changed file:

code fix

Result after fix is applied:

result

Upvotes: 1

Related Questions