SOLVED

Skill Dialog: endDialog() does not work

Brass Contributor

Hi,

I am implementing a dialogRootBot that will call a skillDialogBot.  

 

My dialogRootBot is able to invoke the skillDialogBot.  The conversation can progress until the point where the skillDialogBot is supposed to return the results to the dialogRootBot.

 

The skillDialogBot has the following setup

this.addDialog(new TextPrompt(TEXT_PROMPT))
	.addDialog(new ConfirmPrompt(CONFIRM_PROMPT))
	.addDialog(new WaterfallDialog(WATERFALL_DIALOG, [
		this.processStep.bind(this)
	]));

 

The processStep is laid out like this

async processStep(stepContext) {
	const details = stepContext.options;
	details.result = {
		status: 'success'
	};
	return await stepContext.endDialog(stepContext.options);
}

I was expecting the dialogRootBot to get the result from the skillDialogBot after processStep has called endDialog, but that never happens.  Instead, the user is stuck with the skillDialogBot until the user manually types in "abort", which is the command the dialogRootBot is monitoring to cancel all dialogs in its onContinueDialog() implementation

 

Here is how the onContinueDialog() looks like

async onContinueDialog(innerDc) {
        const activeSkill = await this.activeSkillProperty.get(innerDc.context, () => null);
        const activity = innerDc.context.activity;
        if (activeSkill != null && activity.type === ActivityTypes.Message && activity.text) {
            if (activity.text.toLocaleLowerCase() === 'abort') {
                // Cancel all dialogs when the user says abort.
                // The SkillDialog automatically sends an EndOfConversation message to the skill to let the
                // skill know that it needs to end its current dialogs, too.
                await innerDc.cancelAllDialogs();
                return await innerDc.replaceDialog(this.initialDialogId, { text: 'Request canceled!' });
            }
        }

        return await super.onContinueDialog(innerDc);
    }

 

I modeled this after the botbuilder-samples\samples\javascript_nodejs\81.skills-skilldialog sample.  If I were to change the skillDialogBot and have it do a ConfirmPrompt() before the finalStep()'s endDialog(), then the conversation ends correctly with the skillDialogBot() posting the dialog's results to the rootDialogBot.

 

For the sake of clarity, this is how the bookingDialog in the skills-skilldialog sample looks like

 

/**
     * Confirm the information the user has provided.
     */
    async confirmStep(stepContext) {
        const bookingDetails = stepContext.options;

        // Capture the results of the previous step.
        bookingDetails.travelDate = stepContext.result;
        const messageText = `Please confirm, I have you traveling to: ${ bookingDetails.destination } from: ${ bookingDetails.origin } on: ${ bookingDetails.travelDate }. Is this correct?`;
        const msg = MessageFactory.text(messageText, messageText, InputHints.ExpectingInput);

        // Offer a YES/NO prompt.
        return await stepContext.prompt(CONFIRM_PROMPT, { prompt: msg });
    }

    /**
     * Complete the interaction and end the dialog.
     */
    async finalStep(stepContext) {
        if (stepContext.result === true) {
            const bookingDetails = stepContext.options;
            return await stepContext.endDialog(bookingDetails);
        }
        return await stepContext.endDialog();
    }

 

Is it not possible to endDialog() without a prompt?

 

Thank You

2 Replies
best response confirmed by voonsionglum (Brass Contributor)
Solution

@voonsionglumEnd dialog method provides the collected data as return value back to the parent context. This can be the bot's turn handler or an earlier active dialog on the dialog stack. This is how the prompt classes are designed. Please check documentation (Implement Dialog, Using Dialogs)to get the clear idea on how Dialogs work 

For the sake of reference, when using stepContext.beginDialog(), it appears that we cannot reliably endDialog() if the waterfall dialog does not have a prompt step added.  If there is a use case where we want to use a skillDialogBot and call a specific dialog in the skillDialogBot via stepContext.beginDialog(), and the called dialog is only doing processing (eg. call REST APIs) without the need to prompt users for further information, at the end of the processing, we can opt to end the conversation instead.  

 

Hence, assuming we have finalStep() bound to the waterfall dialog as the last step, just use the following in finalStep()

 

return await stepContext.context.sendActivity({
   type: ActivityTypes.EndOfConversation,
	code: EndOfConversationCodes.CompletedSuccessfully,
	value: stepContext.options
});

 

1 best response

Accepted Solutions
best response confirmed by voonsionglum (Brass Contributor)
Solution

@voonsionglumEnd dialog method provides the collected data as return value back to the parent context. This can be the bot's turn handler or an earlier active dialog on the dialog stack. This is how the prompt classes are designed. Please check documentation (Implement Dialog, Using Dialogs)to get the clear idea on how Dialogs work 

View solution in original post