我已经使用VS代码的Toolkit扩展创建了一个新的Bot,当我在Bot模拟器中运行代码进行本地测试时,卡片是不可见的。即使我运行默认代码,卡片也不会呈现。如何解决这个问题并在本地测试机器人?
teamsBot.js
let txt = context.activity.text;
const removedMentionText = TurnContext.removeRecipientMention(context.activity);
if (removedMentionText) {
// Remove the line break
txt = removedMentionText.toLowerCase().replace(/\n|\r/g, "").trim();
}
// Trigger command by IM text
switch (txt) {
case "welcome": {
const card = cardTools.AdaptiveCards.declareWithoutData(rawWelcomeCard).render();
await context.sendActivity({ attachments: [CardFactory.adaptiveCard(card)] });
break;
}
case "learn": {
this.likeCountObj.likeCount = 0;
const card = cardTools.AdaptiveCards.declare(rawLearnCard).render(this.likeCountObj);
await context.sendActivity({ attachments: [CardFactory.adaptiveCard(card)] });
break;
}
/**
* case "yourCommand": {
* await context.sendActivity(`Add your response here!`);
* break;
* }
*/
}learn.json
{
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": "Learn Adaptive Card and Commands"
},
{
"type": "TextBlock",
"text": "Now you have triggered a command that sends this card! Go to documentations to learn more about Adaptive Card and Commands in Teams Bot. Click on \"I like this\" below if you think this is helpful.",
"wrap": true
},
{
"type": "FactSet",
"facts": [
{
"title": "Like Count:",
"value": "${likeCount}"
}
]
}
],
"actions": [
{
"type": "Action.Execute",
"title": "I Like This!",
"verb": "userlike",
"fallback": "Action.Submit"
},
{
"type": "Action.OpenUrl",
"title": "Adaptive Card Docs",
"url": "https://learn.microsoft.com/en-us/adaptive-cards/"
},
{
"type": "Action.OpenUrl",
"title": "Bot Command Docs",
"url": "https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/create-a-bot-commands-menu?tabs=desktop%2Cdotnet"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.4"
}

Bot仿真程序输出:

发布于 2022-07-21 09:10:59
Bot框架支持自适应卡版本1.3
将版本1.4更改为1.3
"version": "1.3"

https://stackoverflow.com/questions/73060966
复制相似问题