How to use the botbuilder-dialogs.DialogTurnStatus.cancelled 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
}

            if (dialogTurnResult === undefined) return await dc.endDialog();

            // Examine result from dc.continue() or from the call to beginChildDialog().
            switch (dialogTurnResult.status) {
            case DialogTurnStatus.complete: {
                // The active dialog finished successfully. Ask user if they need help with anything else.
                await dc.context.sendActivity(MessageFactory.suggestedActions(GenSuggestedQueries(), `Is there anything else I can help you with?`));
                break;
            }
            case DialogTurnStatus.waiting: {
                // The active dialog is waiting for a response from the user, so do nothing
                break;
            }
            case DialogTurnStatus.cancelled: {
                // The active dialog's stack has been cancelled
                await dc.cancelAllDialogs();
                break;
            }
            }
            return dialogTurnResult;
        }
github microsoft / botbuilder-js / libraries / botbuilder-dialogs-adaptive / src / adaptiveDialog.ts View on Github external
protected async onEndOfActions(sequence: SequenceContext): Promise {
        // End dialog and return result
        if (sequence.activeDialog) {
            if (this.shouldEnd(sequence)) {
                const state: AdaptiveDialogState = sequence.activeDialog.state;
                return await sequence.endDialog(state.result);
            }
            return Dialog.EndOfTurn;
        } else {
            return { status: DialogTurnStatus.cancelled };
        }
    }
github microsoft / BotBuilder-Samples / javascript_nodejs / 20.cortana-skill / cortanaSkill.js View on Github external
activities.forEach(a => {
                    if (a.type === ActivityTypes.EndOfConversation) {
                        skillEnded = true;
                    }
                });
                return await next();
            });

            // Run turn
            result = await this.onRunTurn(innerDC, options);
        }

        // Check for end of skill and clear the conversation state if detected.
        if (skillEnded) {
            this.conversationState.clear(innerDC.context);
            result = { status: DialogTurnStatus.cancelled };
        }
        return result;
    }
github microsoft / botframework-solutions / templates / Virtual-Assistant-Template / typescript / samples / sample-skill / src / dialogs / skillDialogBase.ts View on Github external
// When the token is cached we get a TokenResponse object.
            const providerTokenResponse: IProviderTokenResponse | undefined = sc.result as IProviderTokenResponse;

            if (providerTokenResponse !== undefined) {
                // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/tslint/config
                const state: any = await this.stateAccessor.get(sc.context);
                // tslint:disable-next-line: no-any no-unsafe-any
                state.token = providerTokenResponse.tokenResponse.token;
            }

            return await sc.next();
        } catch (err) {
            await this.handleDialogExceptions(sc, err as Error);

            return {
                status: DialogTurnStatus.cancelled,
                result: CommonUtil.dialogTurnResultCancelAllDialogs
            };
        }
    }
    // Validators
github microsoft / BotBuilder-Samples / samples / javascript_nodejs / 48.qnamaker-active-learning-bot / bots / activelearning-bot.js View on Github external
async onTurn(turnContext) {
        // By checking the incoming Activity type, the bot only calls QnA Maker in appropriate cases.
        if (turnContext.activity.type === ActivityTypes.Message) {
            const dialogContext = await this.dialogs.createContext(turnContext);
            const results = await dialogContext.continueDialog();

            if ((results.status === DialogTurnStatus.cancelled) || (results.status === DialogTurnStatus.empty)) {
                await dialogContext.beginDialog(this.dialogHelper.activeLearningDialogName, this.qnaMakerOptions);
            }

            await this.conversationState.saveChanges(turnContext);

        // If the Activity is a ConversationUpdate, send a greeting message to the user.
        } else if (turnContext.activity.type === ActivityTypes.ConversationUpdate &&
                   turnContext.activity.recipient.id !== turnContext.activity.membersAdded[0].id) {
            await turnContext.sendActivity('Welcome to the QnA Maker sample! Ask me a question and I will try to answer it.');

        // Respond to all other Activity types.
        } else if (turnContext.activity.type !== ActivityTypes.ConversationUpdate) {
            await turnContext.sendActivity(`[${ turnContext.activity.type }]-type activity detected.`);
        }
    }
}
github microsoft / BotBuilder-Samples / samples / javascript_nodejs / 50.diceroller-skill / cortanaSkill.js View on Github external
activities.forEach(a => {
                    if (a.type === ActivityTypes.EndOfConversation) {
                        skillEnded = true;
                    }
                });
                return await next();
            });

            // Run turn
            result = await this.onRunTurn(innerDC, options);
        }

        // Check for end of skill and clear the conversation state if detected.
        if (skillEnded) {
            this.conversationState.clear(innerDC.context);
            result = { status: DialogTurnStatus.cancelled };
        }
        return result;
    }
github microsoft / botframework-solutions / templates / Virtual-Assistant-Template / typescript / generator-botbuilder-assistant / generators / skill / templates / sample-skill / src / dialogs / _skillDialogBase.ts View on Github external
protected async getAuthToken(sc: WaterfallStepContext): Promise {
        try {
            return await sc.prompt(MultiProviderAuthDialog.name, {});
        } catch (err) {
            await this.handleDialogExceptions(sc, err as Error);

            return {
                status: DialogTurnStatus.cancelled,
                result: CommonUtil.dialogTurnResultCancelAllDialogs
            };
        }
    }