How to use the botbuilder-dialogs.DialogTurnStatus.complete function in botbuilder-dialogs

To help you get started, we’ve selected a few botbuilder-dialogs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / BotBuilder-Samples / samples / javascript_nodejs / 51.cafe-bot / dialogs / dispatcher / mainDispatcher.js View on Github external
let onTurnProperty = await this.onTurnAccessor.get(dc.context);

            // Evaluate if the requested operation is possible/ allowed.
            const reqOpStatus = await this.isRequestedOperationPossible(dc.activeDialog, onTurnProperty.intent);
            if (!reqOpStatus.allowed) {
                await dc.context.sendActivity(reqOpStatus.reason);
                // Initiate re-prompt for the active dialog.
                await dc.repromptDialog();
                return { status: DialogTurnStatus.waiting };
            } else {
                // continue any outstanding dialogs
                dialogTurnResult = await dc.continueDialog();
            }

            // This will only be empty if there is no active dialog in the stack.
            if (!dc.context.responded && dialogTurnResult !== undefined && dialogTurnResult.status !== DialogTurnStatus.complete) {
                // If incoming on turn property does not have an intent, call LUIS and get an intent.
                if (onTurnProperty === undefined || onTurnProperty.intent === '') {
                    // Call to LUIS recognizer to get intent + entities
                    const LUISResults = await this.luisRecognizer.recognize(dc.context);

                    // Return new instance of on turn property from LUIS results.
                    // Leverages static fromLUISResults method
                    onTurnProperty = OnTurnProperty.fromLUISResults(LUISResults);
                }

                // No one has responded so start the right child dialog.
                dialogTurnResult = await this.beginChildDialog(dc, onTurnProperty);
            }

            if (dialogTurnResult === undefined) return await dc.endDialog();
github howdyai / botkit / packages / botkit / src / conversation.ts View on Github external
public async end(dc: DialogContext): Promise {
        // TODO: may have to move these around
        // shallow copy todo: may need deep copy
        // protect against canceled dialog.
        if (dc.activeDialog &&  dc.activeDialog.state) {
            const result = {
                ...dc.activeDialog.state.values
            };
            await dc.endDialog(result);
            await this.runAfter(dc, result);
        } else {
            await dc.endDialog();
        }

        return DialogTurnStatus.complete;
    }
github hinojosachapel / CorePlus / typescript_nodejs / src / dialogs / main / index.ts View on Github external
// break;

                    case NONE_INTENT:
                    default:
                        // None or no intent identified, either way, let's query the QnA service.
                        turnResult = await dc.beginDialog(QnADialog.name);
                        break;
                    }

                    break;

                case DialogTurnStatus.waiting:
                    // The active dialog is waiting for a response from the user, so do nothing.
                    break;

                case DialogTurnStatus.complete:
                    // All child dialogs have ended. so do nothing.
                    break;

                default:
                    // Unrecognized status from child dialog. Cancel all dialogs.
                    await dc.cancelAllDialogs();
                }
            }
        }

        return turnResult;
    }
github microsoft / BotBuilder-Samples / samples / javascript_nodejs / 51.cafe-bot / dialogs / bookTable / index.js View on Github external
async bookTable(stepContext) {
            // report table booking based on confirmation outcome.
            if (stepContext.result) {
                // User confirmed.
                // Get current reservation from accessor
                let reservationFromState = await this.reservationsAccessor.get(stepContext.context);
                await stepContext.context.sendActivity(`Sure. I've booked the table for ` + reservationFromState.confirmationReadOut());
                // TODO: Book the table.
                if (stepContext.result === DialogTurnStatus.complete) {
                    // Clear out the reservation property since this is a successful reservation completion.
                    this.reservationsAccessor.set(stepContext.context, undefined);
                }
                await stepContext.cancelAllDialogs();

                return await stepContext.endDialog();
            } else {
                // User rejected cancellation.
                // clear out state.
                this.reservationsAccessor.set(stepContext.context, undefined);
                await stepContext.context.sendActivity(`Ok..I've cancelled the reservation`);
                return await stepContext.endDialog();
            }
        }
    }
github microsoft / botframework-solutions / templates / Virtual-Assistant-Template / typescript / generator-botbuilder-assistant / generators / app / templates / sample-assistant / src / dialogs / mainDialog.ts View on Github external
// Check dispatch result
        const dispatchResult: RecognizerResult = await cognitiveModels.dispatchService.recognize(dc.context);
        const intent: string = LuisRecognizer.topIntent(dispatchResult);

        if (this.settings.skills === undefined) {
            throw new Error('There is no skills in settings value');
        }
        // Identify if the dispatch intent matches any Action within a Skill if so, we pass to the appropriate SkillDialog to hand-off
        const identifiedSkill: ISkillManifest | undefined = SkillRouter.isSkill(this.settings.skills, intent);

        if (identifiedSkill !== undefined) {
            // We have identified a skill so initialize the skill connection with the target skill
            const result: DialogTurnResult = await dc.beginDialog(identifiedSkill.id);

            if (result.status === DialogTurnStatus.complete) {
                await this.complete(dc);
            }
        } else if (intent === 'l_general') {
            // If dispatch result is general luis model
            const luisService: LuisRecognizerTelemetryClient | undefined = cognitiveModels.luisServices.get(this.luisServiceGeneral);

            if (luisService === undefined) {
                throw new Error('The General LUIS Model could not be found in your Bot Services configuration.');
            } else {
                const result: RecognizerResult = await luisService.recognize(dc.context);
                if (result !== undefined) {
                    const generalIntent: string = LuisRecognizer.topIntent(result);

                    // switch on general intents
                    switch (generalIntent) {
                        case 'Escalate': {
github microsoft / BotBuilder-Samples / samples / javascript_nodejs / 13.basic-bot / bot.js View on Github external
switch (topIntent) {
                    case GREETING_INTENT:
                        await dc.beginDialog(GREETING_DIALOG);
                        break;
                    case NONE_INTENT:
                    default:
                        // None or no intent identified, either way, let's provide some help
                        // to the user
                        await dc.context.sendActivity(`I didn't understand what you just said to me.`);
                        break;
                    }
                    break;
                case DialogTurnStatus.waiting:
                    // The active dialog is waiting for a response from the user, so do nothing.
                    break;
                case DialogTurnStatus.complete:
                    // All child dialogs have ended. so do nothing.
                    break;
                default:
                    // Unrecognized status from child dialog. Cancel all dialogs.
                    await dc.cancelAllDialogs();
                    break;
                }
            }
        } else if (context.activity.type === ActivityTypes.ConversationUpdate) {
            // Handle ConversationUpdate activity type, which is used to indicates new members add to
            // the conversation.
            // see https://aka.ms/about-bot-activity-message to learn more about the message and other activity types

            // Do we have any new members added to the conversation?
            if (context.activity.membersAdded.length !== 0) {
                // Iterate over all new members added to the conversation
github microsoft / BotBuilder-Samples / generators / generator-botbuilder / generators / app / templates / core / bot.js View on Github external
switch (topIntent) {
                    case GREETING_INTENT:
                        await dc.beginDialog(GREETING_DIALOG);
                        break;
                    case NONE_INTENT:
                    default:
                        // None or no intent identified, either way, let's provide some help
                        // to the user
                        await dc.context.sendActivity(`I didn't understand what you just said to me.`);
                        break;
                    }
                    break;
                case DialogTurnStatus.waiting:
                    // The active dialog is waiting for a response from the user, so do nothing.
                    break;
                case DialogTurnStatus.complete:
                    // All child dialogs have ended. so do nothing.
                    break;
                default:
                    // Unrecognized status from child dialog. Cancel all dialogs.
                    await dc.cancelAllDialogs();
                    break;
                }
            }
        } else if (context.activity.type === ActivityTypes.ConversationUpdate) {
            // Handle ConversationUpdate activity type, which is used to indicates new members add to
            // the conversation.
            // See https://aka.ms/about-bot-activity-message to learn more about the message and other activity types

            // Do we have any new members added to the conversation?
            if (context.activity.membersAdded.length !== 0) {
                // Iterate over all new members added to the conversation
github microsoft / botbuilder-js / libraries / botbuilder-ai / samples / 13.basic-bot / bot.js View on Github external
switch (topIntent) {
                    case GREETING_INTENT:
                        await dc.beginDialog(GREETING_DIALOG);
                        break;
                    case NONE_INTENT:
                    default:
                        // None or no intent identified, either way, let's provide some help
                        // to the user
                        await dc.context.sendActivity(templateReferences.confusion);
                        break;
                    }
                    break;
                case DialogTurnStatus.waiting:
                    // The active dialog is waiting for a response from the user, so do nothing.
                    break;
                case DialogTurnStatus.complete:
                    // All child dialogs have ended. so do nothing.
                    break;
                default:
                    // Unrecognized status from child dialog. Cancel all dialogs.
                    await dc.cancelAllDialogs();
                    break;
                }
            }
        } else if (context.activity.type === ActivityTypes.ConversationUpdate) {
            // Handle ConversationUpdate activity type, which is used to indicates new members add to
            // the conversation.
            // see https://aka.ms/about-bot-activity-message to learn more about the message and other activity types

            // Do we have any new members added to the conversation?
            if (context.activity.membersAdded.length !== 0) {
                // Iterate over all new members added to the conversation
github microsoft / BotBuilder-Samples / samples / javascript_nodejs / 81.skills-skilldialog / dialogSkillBot / dialogs / activityRouterDialog.js View on Github external
async beginGetWeather(stepContext) {
        const activity = stepContext.context.activity;
        const location = activity.value || {};

        // We haven't implemented the GetWeatherDialog so we just display a TODO message.
        const getWeatherMessageText = `TODO: get weather for here (lat: ${ location.latitude }, long: ${ location.longitude })`;
        await stepContext.context.sendActivity(getWeatherMessageText, getWeatherMessageText, InputHints.IgnoringInput);
        return { status: DialogTurnStatus.complete };
    }