1
votes

I have dialogs for viewing an order and for expediting an order. A user may want to expedite in the middle of the viewOrder dialog and then return to look up more line items. I'm checking for the expedite intent as an interrupt and pushing the dialog on the stack.

At the end of the dialog, I'm prompting the user if they want to return to the previous conversation. If Yes, I call endDialog which pops the dialog off the stack and returns to the previous dialog. This is working. If No, I call cancelAllDialogs. I expect this to clear the dialog stack, but it appears to be cancelling only the current (expedite) dialog and it's still returning to the previous viewOrder dialog.

My goal is to figure out how to clear the dialog stack if the user says at the end of the expedite dialog that they do not want to continue.

At first I tried having the dialog return a continueDialog boolean value and cancelling from the interrupt function. But await only waits on beginning the dialog, not the result, so the interrupt function completes before the user goes through the expedite dialog.

I changed to just push the new dialog on to the stack and handle cancelling from the expedite function, but cancelAllDialogs doesn't appear to cancel clear the stack from within this separate dialog.

async continueAction(step) {
     if (step.result) {
          return await step.endDialog();
     } else {
          await step.context.sendActivity(`OK, please let me know if there is anything else I can do for you.`);
          return await step.cancelAllDialogs();
     }
}

Note that "step" is just the name of my dialog context, you may have this as "context", "stepContext", "dc", "innerDc", etc.

step.result.value is the result of the ConfirmPrompt, and I am correctly arriving in the else block when selecting 'No'. I expect cancellAllDialogs to clear the stack but it seems to be cancelling only the active dialog.

1

1 Answers

3
votes

When starting a new waterfall dialog, the original dialog stack becomes the parent within the dialog context, so you need to reference that when you cancel all dialogs, i.e.

return await step.parent.cancelAllDialogs();

This will clear the entire stack. I checked and confirmed that even if I have multiple levels of dialog (e.g. I invoked expedite interruption 3 times without answering the prompt), this line will clear the entire stack.