我用 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()\`
我在 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;
输出:
参考: