From efcbcc7845460a08ed6fdf8fbe4d7845a06a5a95 Mon Sep 17 00:00:00 2001 From: My Ho Date: Thu, 31 Jan 2019 14:11:35 -0800 Subject: [PATCH] explain how initialDialogId is used --- javascript_nodejs/dialogs/DonateFoodDialog.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/javascript_nodejs/dialogs/DonateFoodDialog.js b/javascript_nodejs/dialogs/DonateFoodDialog.js index 49c8959..a2923c4 100644 --- a/javascript_nodejs/dialogs/DonateFoodDialog.js +++ b/javascript_nodejs/dialogs/DonateFoodDialog.js @@ -1,17 +1,29 @@ const { ComponentDialog, ChoicePrompt, WaterfallDialog } = require('botbuilder-dialogs'); const { getValidDonationDays, filterFoodBanksByDonation, createFoodBankDonationCarousel } = require('../services/schedule-helpers'); +const DONATION_DIALOG = 'donationDialog'; + class DonateFoodDialog extends ComponentDialog { constructor(dialogId) { super(dialogId); - // ID of the child dialog that should be started anytime the component is started. - this.initialDialogId = dialogId; + /** + * THIS IS REQUIRED to tell the framework which dialog + * will be use as the starting one. + * + * Value doesn't matter, you could use the passed-in dialogId + * or something new + * + * Without this, the first Diaglog added will be used, which in + * this example will be the Choice Prompt + * **/ + this.initialDialogId = DONATION_DIALOG; // or dialogId this.addDialog(new ChoicePrompt('choicePrompt')); // Define the conversation flow using a waterfall model. - this.addDialog(new WaterfallDialog(dialogId, [ + // The id used here need to match the value given to `initialId` + this.addDialog(new WaterfallDialog(DONATION_DIALOG, [ async function (step) { const validDonationDays = getValidDonationDays();