自适应卡未在 Microsoft BOT 框架中呈现

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

以下是我的代码:

> To learn more Adaptive Cards format, read the documentation at
> https://docs.microsoft.com/en-us/adaptive-cards/getting-started/bots
- ```{
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.2",
  "type": "AdaptiveCard",
  "body": [
              {
                  "type": "TextBlock",
                  "text": "Please input ClientId, RequestId, TimeStamp, name of your Team",
                  "weight": "bolder",
                  "size": "medium",
                  "style": "heading",
                  "wrap": true
              },
              {
                "type": "TextBlock",
                "text": "Please also upload the ESRP Logs and your build logs after creating ticket to the Portal.",
                "isSubtle": true,
                "wrap": true
              },
              {
                "type": "Input.Text",
                "label": "Your Onboarding ClientId",
                "id": "ClientId",
                "validation": "^[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$",
                "error": "Please enter your ClientId in the specified format",
                "isRequired": true                        
              },
              {
              "type": "Input.Text",
              "id": "RequestId",
              "label": "RequestId",
              "validation": "^[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$",
              "error": "Please enter a valid RequestId"
              },
              {
              "type": "Input.Text",
              "id": "TimeStamp",
              "label": "TimeStamp"   
              },
              {
              "type": "Input.Text",
              "id": "TeamName",
              "label": "TeamName"   
              }
            ],
  "actions": [
              {
                "type": "Action.Submit",
                "title": "Submit"
              }
            ]
}```

我正在使用 Microsoft Bot Framework 和自适应卡,想要创建一个表单来获取一些输入并解析它,想要验证输入然后提交到 API,但无论我如何尝试,它都无法在自适应卡中工作。我也从这里复制了代码 AdaptiveCardInputFormhttps://adaptivecards.io/samples/InputForm.html ,不确定我在渲染自适应卡时做错了什么。

由于某种原因,它永远不会在机器人中渲染。我通过格式化它来修复 json,它也像空白页面一样显示在 UI 上:

c# botframework adaptive-cards
1个回答
0
投票

经过多次来回尝试和失败后,我能够使该代码正常工作,但仍然无法对文本框进行验证。

> To learn more Adaptive Cards format, read the documentation at
> https://docs.microsoft.com/en-us/adaptive-cards/getting-started/bots
- ```{
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.2",
  "type": "AdaptiveCard",
  "body": [
              {
                  "type": "TextBlock",
                  "text": "Please input ClientId, RequestId, TimeStamp, name of your Team",
                  "weight": "bolder",
                  "size": "medium",
                  "style": "heading",
                  "wrap": true
              },
              {
                "type": "TextBlock",
                "text": "Please also upload the ESRP Logs and your build logs after creating ticket to the Portal.",
                "isSubtle": true,
                "wrap": true
              },
              {
                "type": "Input.Text",
                "placeholder": "Your ClientId (you can find this info at the https://aka.ms/esrpportal)",
                "id": "ClientId",
                "validation": {
                "errorMessage": "Please enter your ClientId in proper GUID format",
                "necessity": "required"
                }
              },
              {
                "type": "Input.Text",
                "placeholder": "RequestId",
                "id": "RequestId",
                "validation": {
                "errorMessage": "Please enter your RequestId in proper GUID format",
                "necessity": "required"
                }
              },
              {
                "type": "Input.Number",
                "placeholder": "What is the severity of your incident (Defaults to sev3)?",
                "id": "Severity"
              },
              {
              "type": "Input.Text",
              "id": "TimeStamp",
              "placeholder": "TimeStamp"
              },
              {
              "type": "Input.Text",
              "id": "TeamName",
              "placeholder": "TeamName"   
              }
          ],
  "actions": [
              {
                "type": "Action.Submit",
                "title": "Submit"
              }
            ]
}```
© www.soinside.com 2019 - 2024. All rights reserved.