How to use the botbuilder-core.MessageFactory 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 / libraries / botbuilder-dialogs / lib / choices / choiceFactory.js View on Github external
let connector = '';
        let txt = (text || '');
        txt += ' ';
        ChoiceFactory.toChoices(choices).forEach((choice, index) => {
            const title = choice.action && choice.action.title ? choice.action.title : choice.value;
            txt += `${connector}${opt.includeNumbers ? '(' + (index + 1).toString() + ') ' : ''}${title}`;
            if (index == (choices.length - 2)) {
                connector = (index == 0 ? opt.inlineOr : opt.inlineOrMore) || '';
            }
            else {
                connector = opt.inlineSeparator || '';
            }
        });
        txt += '';
        // Return activity with choices as an inline list.
        return botbuilder_core_1.MessageFactory.text(txt, speak, botbuilder_core_1.InputHints.ExpectingInput);
    }
    /**
github microsoft / botbuilder-js / libraries / botbuilder-dialogs / lib / prompts / prompt.js View on Github external
text = prompt.text;
        }
        // Create temporary msg
        let msg;
        switch (style) {
            case ListStyle.inline:
                msg = choices_1.ChoiceFactory.inline(choices, text, null, options);
                break;
            case ListStyle.list:
                msg = choices_1.ChoiceFactory.list(choices, text, null, options);
                break;
            case ListStyle.suggestedAction:
                msg = choices_1.ChoiceFactory.suggestedAction(choices, text);
                break;
            case ListStyle.none:
                msg = botbuilder_core_1.MessageFactory.text(text);
                break;
            default:
                msg = choices_1.ChoiceFactory.forChannel(channelId, choices, text, null, options);
                break;
        }
        // Update prompt with text and actions
        if (typeof prompt === 'object') {
            prompt.text = msg.text;
            if (msg.suggestedActions && Array.isArray(msg.suggestedActions.actions) && msg.suggestedActions.actions.length > 0) {
                prompt.suggestedActions = msg.suggestedActions;
            }
            return prompt;
        }
        else {
            msg.inputHint = botbuilder_core_1.InputHints.ExpectingInput;
            return msg;
github microsoft / botbuilder-js / libraries / botbuilder-dialogs / lib / prompts / oauthPrompt.js View on Github external
return __awaiter(this, void 0, void 0, function* () {
            // Validate adapter type
            if (!('getUserToken' in context.adapter)) {
                throw new Error(`OAuthPrompt.prompt(): not supported for the current adapter.`);
            }
            // Initialize outgoing message
            const msg = typeof prompt === 'object' ? Object.assign({}, prompt) : botbuilder_core_1.MessageFactory.text(prompt, undefined, botbuilder_core_1.InputHints.ExpectingInput);
            if (!Array.isArray(msg.attachments)) {
                msg.attachments = [];
            }
            // Add login card as needed
            if (this.channelSupportsOAuthCard(context.activity.channelId)) {
                const cards = msg.attachments.filter((a) => a.contentType === botbuilder_core_1.CardFactory.contentTypes.oauthCard);
                if (cards.length == 0) {
                    // Append oauth card
                    msg.attachments.push(botbuilder_core_1.CardFactory.oauthCard(this.settings.connectionName, this.settings.title, this.settings.text));
                }
            }
            else {
                const cards = msg.attachments.filter((a) => a.contentType === botbuilder_core_1.CardFactory.contentTypes.signinCard);
                if (cards.length == 0) {
                    // Append signin card
                    const link = yield context.adapter.getSignInLink(context, this.settings.connectionName);