gpt4 book ai didi

botframework - 在通知中发送英雄卡或自适应卡

转载 作者:行者123 更新时间:2023-12-04 10:29:55 27 4
gpt4 key购买 nike

我正在尝试发送 Teams notificationhero cardAdaptive Card .我可以发送一条简单的短信作为 notification .

我不知道如何包装 Hero cardAdaptive CardActivitySendToConversationAsync只接受 Activity .

最佳答案

这是您可以用来发送使用adaptivecard.io创建的任何卡的代码

const resultOutputCard = {
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type" : "TextBlock",
"text" : "Sample Text"
}
],
"actions": [
{
"type": "Action.OpenUrl",
"title": "Google Link",
"url": "www.google.com"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
};
const card = CardFactory.adaptiveCard(resultOutputCard);
await step.context.sendActivity({ attachments: [card] });

以下是您可以用来发送英雄卡的代码
const { MessageFactory, CardFactory } = require('botbuilder');

const card = CardFactory.heroCard(
'White T-Shirt',
['https://example.com/whiteShirt.jpg'],
['buy']
);
const message = MessageFactory.attachment(card);
await context.sendActivity(message);

以下是您可以找到上述示例的链接。

https://docs.microsoft.com/en-us/javascript/api/botbuilder-core/cardfactory?view=botbuilder-ts-latest

关于botframework - 在通知中发送英雄卡或自适应卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60462491/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com