How to use the botbuilder-core.MessageFactory.attachment 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 / src / dialogDebugger.ts View on Github external
"text": '🔍 ' + title
                    },
                    {
                        "type": "Container",
                        "items": []
                    }
                ]
            };

            // Render memory
            if (memory) {
                this.renderObject(memory, card.body[1] as any, '$');
            }

            // Send card
            const msg = MessageFactory.attachment(CardFactory.adaptiveCard(card));
            await this.dc.context.sendActivity(msg);
        }
    }
github microsoft / botbuilder-js / libraries / botbuilder-dialogs-adaptive / src / steps / sendAdaptiveCard.ts View on Github external
public async beginDialog(dc: DialogContext): Promise {
        if (!this.template) { throw new Error(`${this.id}: no adaptive card template assigned.`) }

        // Render card
        const memory = dc.state.toJSON();
        const data = this.dataProperty ? jsonpath.value(memory, this.dataProperty) || {} : memory;
        const card = this.template.render(data);

        // Send card as attachment
        const activity = MessageFactory.attachment(CardFactory.adaptiveCard(card));
        const result = await dc.context.sendActivity(activity);
        return await dc.endDialog(result);
    }
}
github microsoft / botbuilder-js / libraries / botbuilder-dialogs / src / choices / choiceFactory.ts View on Github external
public static heroCard(choices: (string | Choice)[] = [], text = '', speak = ''): Activity {
        const buttons: CardAction[] = ChoiceFactory.toChoices(choices).map(choice => ({
            title: choice.value,
            type: ActionTypes.ImBack,
            value: choice.value
        } as CardAction));
        const attachment = CardFactory.heroCard(null, text, null, buttons);

        return MessageFactory.attachment(attachment, null, speak, InputHints.ExpectingInput) as Activity;
    }
github microsoft / botbuilder-js / libraries / botbuilder-lg / src / activityFactory.ts View on Github external
private static buildActivityFromLGStructuredResult(lgValue: any): Partial {
        let activity: Partial = {};

        const type: string = this.getStructureType(lgValue);
        if (ActivityChecker.genericCardTypeMapping.has(type) || type === 'attachment') {
            activity = MessageFactory.attachment(this.getAttachment(lgValue));
        } else if (type === 'activity') {
            activity = this.buildActivity(lgValue);
        }

        return activity;
    }