MS Teams 上的自适应卡片

问题描述 投票:0回答:1

我用 Botpress 创建了一个机器人,并通过 Azure 将它连接到 MS Teams。据此,扩展应该与自适应卡一起使用,对吗?不幸的是,我在聊天中只看到一张空卡片。有没有人曾经在 Botpress 上使用过自适应卡,并且可以告诉我他们是如何进行的?我是聊天机器人的新手,Microsoft 文档非常详细但也很混乱。如果有任何帮助,我将不胜感激。

我尝试通过 Botpress 中的一个动作来实现卡片并实现了库。

const { CardFactory} = require('botbuilder')

const myAction = async () =\> {
const card = CardFactory.adaptiveCard({
$schema: 'http://adaptivecards.io/schemas/1.4.0/adaptive-card.json',
type: 'adaptive-card',
version: '1.4',
markdown: true,
body: \[
{
type: 'text',
text: 'AD User erstellen'
}
\]
})

    // Send the message to the user (note the array, since you can send multiple payloads in the same reply)
    const payloads = await bp.cms.renderElement('adaptive-card', { items: card }, event)
    return await bp.events.replyToEvent(event, payloads)

}

return myAction()\`
azure botframework microsoft-teams adaptive-cards botpress
1个回答
0
投票

我在 MS Teams 机器人中使用自适应卡片厌倦了下面的代码。

示例 Javascript 代码:-

const  card = {
"$schema":  "http://adaptivecards.io/schemas/adaptive-card.json",
"version":  "1.4",
"type":  "AdaptiveCard",
"body": [
{
"type":  "TextBlock",
"text":  "Hello, world!",
"size":  "large"
}
]
};
const  message = {
type:  "message",
text:  "Here's an adaptive card:",
attachments: [CardFactory.adaptiveCard(card)]
};
await  context.sendActivity(message);
break;

  • 另一种实现自适应卡片的方法是创建一个 Json 文件。

enter image description here

enter image description here

输出:

enter image description here

参考:

© www.soinside.com 2019 - 2024. All rights reserved.