How to use the botbuilder-core.CardFactory.contentTypes 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-lg / src / activityFactory.ts View on Github external
private static getCardAttachment(type: string, input: any): Attachment {
        const card: any = {};

        for (const key of Object.keys(input)) {
            const property: string = key.trim().toLowerCase();
            const value: any = input[key];

            switch (property) {
                case 'tap':
                    card[property] = this.getCardAction(value);
                    break;
                case 'image':
                case 'images':
                    if (type === CardFactory.contentTypes.heroCard || type === CardFactory.contentTypes.thumbnailCard) {
                        if (!('images' in card)) {
                            card['images'] = [];
                        }

                        const imageList: string[] = this.normalizedToList(value).map((u): string => u.toString());
                        imageList.forEach( (u): any => card['images'].push({url : u}));
                    } else {
                        card['image'] = {url: value.toString()};
                    }
                    break;
                case 'media':
                    if (!('media' in card)) {
                        card['media'] = [];
                    }

                    const mediaList: string[] = this.normalizedToList(value).map((u): string => u.toString());
github microsoft / botbuilder-js / libraries / botbuilder-dialogs / src / prompts / oauthPrompt.ts View on Github external
            const cards: Attachment[] = msg.attachments.filter((a: Attachment) => a.contentType === CardFactory.contentTypes.oauthCard);
            if (cards.length === 0) {
github microsoft / botbuilder-js / libraries / botbuilder-lg / src / activityFactory.ts View on Github external
* Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License.
 */

import { Activity, SuggestedActions, Attachment, ActivityTypes, ActionTypes, CardAction } from 'botframework-schema';
import { MessageFactory, CardFactory } from 'botbuilder-core';
import { Diagnostic, DiagnosticSeverity } from './diagnostic';
import { ActivityChecker } from './activityChecker';
import { Evaluator } from './evaluator';

/**
 * The ActivityFactory
 * to generate text and then uses simple markdown semantics like chatdown to create Activity.
 */
export class ActivityFactory {
    private static adaptiveCardType: string = CardFactory.contentTypes.adaptiveCard;

    /**
     * Generate the activity.
     * @param lgResult string result from languageGenerator.
     */
    public static createActivity(lgResult: any): Partial {
        const diagnostics: Diagnostic[] = ActivityChecker.check(lgResult);
        const errors: Diagnostic[] = diagnostics.filter((u: Diagnostic): boolean => u.severity === DiagnosticSeverity.Error);
        if (errors !== undefined && errors.length > 0) {
            throw new Error(`${ errors.join('\n') }`);
        }

        if (typeof lgResult === 'string') {
            const structuredLGResult: any = this.parseStructuredLGResult(lgResult.trim());
            return structuredLGResult === undefined ?
                this.buildActivityFromText(lgResult.trim())