【问题标题】:AdaptiveCard not rendering in Bot Framework Emulator / Web ChatAdaptiveCard 未在 Bot Framework Emulator / Web Chat 中呈现
【发布时间】:2021-01-18 04:29:08
【问题描述】:

真的希望有人能帮忙解决这个问题。

我正在尝试实现 - 使用 QnAMaker.ai 和 Azure Bot Services 和 AdaptiveCards 来提供丰富内容的无代码聊天机器人。

我设置并发布了一个知识库,我在 Azure 中设置了一个机器人来提供该内容,并且在第一阶段它似乎可以正常工作。

现在我正在尝试添加 AdaptiveCards 在 VSCode 中打开和编辑解决方案 - 我真的希望将所有这些都包含在无代码解决方案中。

我在 Google 上搜索了如何添加自定义卡片/内容,发现 this post by LiveTiles - 非常好 - 我想,我可以添加缩小的 JSON,它会呈现我想要的 - 可爱的东西!

但是;尽管 LiveTiles 网站上有实时输出渲染,但当我使用该 JSON 时,我无法通过 Web Chat 或 Bot Framework Emulator 渲染它。

我试过了……

  • 将原始 JSON 复制/粘贴到 QnAPair
{
    "contentType": "application/vnd.microsoft.card.adaptive",
    "content": {
        "type": "AdaptiveCard",
        "version": "1.0",
        "body": [
            {
                "type": "Image",
                "url": "",
                "size": "stretch",
                "selectAction": {
                    "type": "Action.OpenUrl",
                    "title": "Test",
                    "url": "https://www.livetiles.nyc/"
                }
            },
            {
                "type": "TextBlock",
                "text": "This is an adaptive card - if this renders it means it's worked!",
                "wrap": true
            }
        ],
        "actions": [
            {
                "type": "Action.Submit",
                "title": "Let's get started!",
                "url": "Let's get started!"
            }
        ]
    }
}
  • 将缩小的 JSON 复制/粘贴到 QnAPair
{"contentType":"application/vnd.microsoft.card.adaptive","content":{"type":"AdaptiveCard","version":"1.0","body":[{"type":"Image","url":"","size":"stretch","selectAction":{"type":"Action.OpenUrl","title":"Test","url":"https://www.livetiles.nyc/"}},{"type":"TextBlock","text":"This is an adaptive card - if this renders it means it's worked!","wrap":true}],"actions":[{"type":"Action.Submit","title":"Let's get started!","url":"Let's get started!"}]}}

  • 制作源 Excel 文件(包括 JSON)并将其添加到知识库中

当我问它时,我所有的尝试都以机器人向我吐出实际的 JSON 告终。不是我想要的可爱的渲染卡片。

LiveTiles 网站上的渲染:

不在模拟器上渲染

或在网上聊天

在 QnAMaker.ai 测试函数中

真的希望有人可以对此提供一些见解或建议。

【问题讨论】:

  • 在 QnA 门户中使用测试时会发生什么?
  • 当我使用实际的 QnAMaker.ai 测试功能对其进行测试时,也会发生同样的事情。现在包括在内。
  • 您遗漏了从 QnA Maker 知识库创建机器人的部分。无代码解决方案是什么意思? (由于这个帖子里还有很多人,如果你想让我看到你的回复,你需要@提及我。)
  • @KyleDelaney - 感谢您的评论。该机器人是通过 QnAMaker 和 Microsoft Azure 使用按钮部署创建的。我在 QnAMaker 站点上创建了知识库——它让我了解了如何在 Azure 的认知服务中设置机器人。由于这是一个 PoC,而不是我想要继续前进的东西,我希望编码方面尽可能抽象。我不想打开解决方案来添加 AdaptiveCards,当它通过 QnAMaker 实现时它们应该可以工作。
  • @MikeSmith - 你的问题是什么?你会愿意接受一个说不可能的答案,还是只接受一个解释如何做的答案?

标签: botframework bots chatbot qnamaker


【解决方案1】:

请尝试下面的 json 它对我有用,

{
  //"contentType": "application/vnd.microsoft.card.adaptive",
  //"content": {
    "type": "AdaptiveCard",
    "version": "1.0",
    "body": [
      {
        "type": "Image",
        "url": "",
        "size": "stretch",
        "selectAction": {
          "type": "Action.OpenUrl",
          "title": "Test",
          "url": "https://www.livetiles.nyc/"
        }
      },
      {
        "type": "TextBlock",
        "text": "This is an adaptive card - if this renders it means it's worked!",
        "wrap": true
      }
    ],
    "actions": [
      {
        "type": "Action.Submit",
        "title": "Let's get started!",
        "url": "Let's get started!"
      }
    ]
  //}
}

我在下面添加了一个截图,请检查

code for send card as an attachment :
 var cardAttachment = Common.CreateAdaptiveCardAttachment();
                await turnContext.SendActivityAsync(MessageFactory.Attachment(cardAttachment), cancellationToken);

【讨论】:

  • 你如何将它添加到机器人中?通过 QnAMaker?你能通过屏幕截图给我看吗?
  • 那么这是在 Visual Studio 中的实际解决方案中吗?我以为这是通过 QnAMaker 网站。
  • 是的,我们使用 Visual Studio 来制作机器人应用程序。
猜你喜欢
  • 2023-01-26
  • 2020-09-06
  • 1970-01-01
  • 2019-10-12
  • 1970-01-01
  • 2018-04-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多