How to use the botbuilder-core.ActivityTypes function in botbuilder-core

To help you get started, we’ve selected a few botbuilder-core 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-js / samples / prompts-es6 / app.js View on Github external
.onReceive((context) => {
        if (context.request.type === botbuilder.ActivityTypes.message) {
            // Check to see if the user said cancel or menu
            const utterance = (context.request.text || '').trim();
            if (/^cancel/i.test(utterance)) {
                endDemo(context);
            } else if (/^menu/i.test(utterance)) {
                menu(context);
            } else {
                // Route incoming message to active prompt
                return prompts.Prompt.routeTo(context).then((handled) => {
                    // If no active prompt then start the task
                    if (!handled) { startDemo(context) }
                });
            }
        }
    });
github microsoft / botbuilder-js / libraries / botbuilder-dialogs / lib / waterfallDialog.js View on Github external
return __awaiter(this, void 0, void 0, function* () {
            // Don't do anything for non-message activities
            if (dc.context.activity.type !== botbuilder_core_1.ActivityTypes.Message) {
                return dialog_1.Dialog.EndOfTurn;
            }
            // Run next step with the message text as the result.
            return yield this.dialogResume(dc, dialog_1.DialogReason.continueCalled, dc.context.activity.text);
        });
    }
github microsoft / botbuilder-js / libraries / botbuilder / lib / botFrameworkAdapter.js View on Github external
.then(() => {
                    if (request.type === botbuilder_core_1.ActivityTypes.Invoke) {
                        // Retrieve cached invoke response.
                        const invokeResponse = context.services.get(INVOKE_RESPONSE_KEY);
                        if (invokeResponse && invokeResponse.value) {
                            const value = invokeResponse.value;
                            res.send(value.status, value.body);
                            res.end();
                        }
                        else {
                            throw new Error(`Bot failed to return a valid 'invokeResponse' activity.`);
                        }
                    }
                    else {
                        res.send(202);
                        res.end();
                    }
                });
github microsoft / botbuilder-js / libraries / botbuilder-dialogs / lib / prompts / prompt.js View on Github external
return __awaiter(this, void 0, void 0, function* () {
            // Don't do anything for non-message activities
            if (dc.context.activity.type !== botbuilder_core_1.ActivityTypes.Message) {
                return dialog_1.Dialog.EndOfTurn;
            }
            // Perform base recognition
            const state = dc.activeDialog.state;
            const recognized = yield this.onRecognize(dc.context, state.state, state.options);
            // Validate the return value
            let end = false;
            let endResult;
            if (this.validator) {
                yield this.validator(dc.context, {
                    recognized: recognized,
                    state: state.state,
                    options: state.options,
                    end: (output) => {
                        if (end) {
                            throw new Error(`PromptValidatorContext.end(): method already called for the turn.`);
github microsoft / botbuilder-js / libraries / botbuilder-dialogs / lib / prompts / oauthPrompt.js View on Github external
isTeamsVerificationInvoke(context) {
        const activity = context.activity;
        return activity.type === botbuilder_core_1.ActivityTypes.Invoke && activity.name == "signin/verifyState";
    }
    channelSupportsOAuthCard(channelId) {
github microsoft / botbuilder-js / libraries / botbuilder-dialogs / lib / prompts / oauthPrompt.js View on Github external
return __awaiter(this, void 0, void 0, function* () {
            let token;
            if (this.isTokenResponseEvent(context)) {
                token = context.activity.value;
            }
            else if (this.isTeamsVerificationInvoke(context)) {
                const code = context.activity.value.state;
                yield context.sendActivity({ type: 'invokeResponse', value: { status: 200 } });
                token = yield this.getUserToken(context, code);
            }
            else if (context.activity.type === botbuilder_core_1.ActivityTypes.Message) {
                const matched = /(\d{6})/.exec(context.activity.text);
                if (matched && matched.length > 1) {
                    token = yield this.getUserToken(context, matched[1]);
                }
            }
            return token !== undefined ? { succeeded: true, value: token } : { succeeded: false };
        });
    }
github microsoft / botbuilder-js / libraries / botbuilder / lib / consoleAdapter.js View on Github external
function next(i) {
                if (i < activities.length) {
                    responses.push({});
                    let a = activities[i];
                    switch (a.type) {
                        case 'delay':
                            setTimeout(() => next(i + 1), a.value);
                            break;
                        case botbuilder_core_1.ActivityTypes.Message:
                            if (a.attachments && a.attachments.length > 0) {
                                const append = a.attachments.length === 1 ? `(1 attachment)` : `(${a.attachments.length} attachments)`;
                                that.print(`${a.text} ${append}`);
                            }
                            else {
                                that.print(a.text);
                            }
                            next(i + 1);
                            break;
                        default:
                            that.print(`[${a.type}]`);
                            next(i + 1);
                            break;
                    }
                }
                else {
github microsoft / botbuilder-js / libraries / botbuilder-dialogs / lib / prompts / oauthPrompt.js View on Github external
isTokenResponseEvent(context) {
        const activity = context.activity;
        return activity.type === botbuilder_core_1.ActivityTypes.Event && activity.name == "tokens/response";
    }
    isTeamsVerificationInvoke(context) {