EDIT:
In going through the source code, I found the following in botbuilder.d.ts
. It would seem that in waterfalls you don't need to call endDialog
explicitly?
/* You can terminate a waterfall early by either falling through every step of the waterfall using
* calls to `skip()` or simply not starting another prompt or dialog.
*
* __note:__ Waterfalls have a hidden last step which will automatically end the current dialog if
* if you call a prompt or dialog from the last step. This is useful where you have a deep stack of
* dialogs and want a call to [session.endDialog()](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.session.html#enddialog)
* from the last child on the stack to end the entire stack. The close of the last child will trigger
* all of its parents to move to this hidden step which will cascade the close all the way up the stack.
* This is typically a desired behavior but if you want to avoid it or stop it somewhere in the
* middle you'll need to add a step to the end of your waterfall that either does nothing or calls
* something like [session.send()](/en-us/node/builder/chat-reference/classes/_botbuilder_d_.session.html#send)
* which isn't going to advance the waterfall forward.
* @example
* <pre><code>
* var bot = new builder.BotConnectorBot();
* bot.add('/', [
* function (session) {
* builder.Prompts.text(session, "Hi! What's your name?");
* },
* function (session, results) {
* if (results && results.response) {
* // User answered question.
* session.send("Hello %s.", results.response);
* } else {
* // User said never mind.
* session.send("OK. Goodbye.");
* }
* }
* ]);
* </code></pre>
*/
I'm learning the MS Bot Framework version 3 -- that's the version they're working with here.
I follow the concept of how waterfalls work (https://docs.microsoft.com/en-us/azure/bot-service/nodejs/bot-builder-nodejs-dialog-manage-conversation-flow?view=azure-bot-service-3.0), but one thing I don't understand is what role endDialog
plays.
For instance, in the code we are working with, there are a bunch of separate dialogs which all have the form
module.exports = function showTickets() {
this.bot.dialog('/showAllTickets', [
async function showAllTicketsFn(session, args, next) {
this.beginDialog.bind(this, '/showTickets')(session, args, next);
}.bind(this)
]);
};
Basically one dialog loading another (with some other code in between, like setting data in the data store). Nowhere is endDialog
called. But in the example from the MS tutorial, every waterfall ends with some form of endDialog
(endDialog
or endDialogWithResults
, etc).
Does every dialog 'opened' with beginDialog
automatically 'close' itself when its waterfall is done, that is, when the functions that are passed in the array to bot.dialog
are run through? (in the code above, the waterfall is only one step).
When does one need to call endDialog
explicitly?
Thanks for any help!