[英]Send a hero card or Adaptive card in notification
I am trying to send a Teams notification
with a hero card
or an Adaptive Card
.我正在尝试使用hero card
或Adaptive Card
发送Teams notification
。 I can send a simple text message as a notification
.我可以发送一条简单的短信作为notification
。
I don't know how to wrap a Hero card
or an Adaptive Card
in an Activity
as SendToConversationAsync
only accepts an Activity
.我不知道如何在Activity
包装Hero card
或Adaptive Card
,因为SendToConversationAsync
只接受Activity
。
Here is the code which you can use to send any card created using the adaptivecard.io这是您可以用来发送使用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] });
Below is the code which you can use to send hero 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);
Below is the link where you can find the above example.以下是您可以找到上述示例的链接。
https://docs.microsoft.com/en-us/javascript/api/botbuilder-core/cardfactory?view=botbuilder-ts-latest https://docs.microsoft.com/en-us/javascript/api/botbuilder-core/cardfactory?view=botbuilder-ts-latest
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.