首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >自适应卡没有在Bot仿真程序v4.14.1上呈现

自适应卡没有在Bot仿真程序v4.14.1上呈现
EN

Stack Overflow用户
提问于 2022-07-21 05:07:37
回答 1查看 198关注 0票数 0

我已经使用VS代码的Toolkit扩展创建了一个新的Bot,当我在Bot模拟器中运行代码进行本地测试时,卡片是不可见的。即使我运行默认代码,卡片也不会呈现。如何解决这个问题并在本地测试机器人?

teamsBot.js

代码语言:javascript
复制
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

代码语言:javascript
复制
{
  "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仿真程序输出:

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-07-21 09:10:59

Bot框架支持自适应卡版本1.3

将版本1.4更改为1.3

代码语言:javascript
复制
 "version": "1.3"

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73060966

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档