【问题标题】:Typeahead support adaptivecardsTypeahead 支持自适应卡片
【发布时间】:2021-10-23 21:44:56
【问题描述】:

只是想问一下微软团队是否已经支持此功能? 我已经在这个网站上检查过: https://blog.botframework.com/2019/07/02/using-adaptive-cards-with-the-microsoft-bot-framework/ 自适应卡版本已更新至 1.3。但是当我实现了提前类型支持时,它就不起作用了。如果我遗漏了什么,请告诉我:

我正在使用 AdaptiveCardTemplate 来渲染卡片:

{
""type"": ""AdaptiveCard"",
""body"": [
    {
        ""type"": ""TextBlock"",
        ""size"": ""Large"",
        ""weight"": ""Bolder"",
        ""text"": ""Hey ${sender.first}!"",
        ""wrap"": true
    },
    {
        ""type"": ""TextBlock"",
        ""text"": ""I am not sure what you mean by '${text}'. You can ask me for **help** if you are not sure how to interact with me."",
        ""wrap"": true,
        ""$when"": ""${showProperty}""            
    },
    {
        ""type"": ""TextBlock"",
        ""text"": ""I'm sorry, I didn't quite understand what you wanted.  Can I help you with something or are you looking to get an update on one of your requests?"",
        ""wrap"": true,
        ""$when"": ""${!showProperty}""            
    },
    {
        ""type"": ""Image"",
        ""url"": ""https://picsum.photos/200/200?image=110"",
        ""msTeams"": {
          ""allowExpand"": true
        }
     },
     {
        ""type"": ""Input.ChoiceSet"",
        ""placeholder"": ""Select one or more options"",
        ""isMultiSelect"": false,
        ""choices"": [
           {  ""title"": ""user 1"", ""value"": ""user1"" },
           {  ""title"": ""user 2"", ""value"": ""user2"" }
        ],
        ""style"": ""filtered"",
        ""id"": ""changePriorityOptionsTest2"",
    }
],
""actions"": [
    {
        ""type"": ""Action.ShowCard"",
        ""title"": ""Make a request"",
        ""card"": {
            ""type"": ""AdaptiveCard"",
            ""body"": [
                {
                    ""type"": ""TextBlock"",
                    ""text"": ""Request"",
                    ""weight"": ""Bolder"",
                    ""wrap"": true
                },
                {
                    ""type"": ""TextBlock"",
                    ""text"": ""Maximum 500 characters"",
                    ""wrap"": true,
                    ""size"": ""Small"",
                    ""weight"": ""Lighter""
                },
                {
                    ""type"": ""Input.Text"",
                    ""id"": ""title"",
                    ""value"": ""${text}"",
                    ""placeholder"": ""Add a title"",
                    ""isMultiline"": true,
                    ""spacing"": ""none""
                },
                {
                    ""type"": ""TextBlock"",
                    ""text"": ""Priority"",
                    ""weight"": ""Bolder"",
                    ""wrap"": true,
                },
                {
                    ""type"": ""Input.ChoiceSet"",
                    ""isMultiSelect"": true,
                    ""choices"": [
                        {
                            ""$data"": ""${priorityOptions}"",
                            ""title"": ""${Value}"",
                            ""value"": ""${Id}""
                        }
                    ],
                    ""value"": ""${priorityId}"",
                    ""id"": ""changePriorityOptions"",
                    ""style"": ""compact"",
                }
            ],
            ""actions"": [
                {
                    ""type"": ""Action.Submit"",
                    ""title"": ""Submit"",
                    ""id"": ""CreateTicket"",
                    ""data"": { ""title"": ""${title}"", ""commandId"": ""CreateTicket"" }
                }
            ],
            ""$schema"": ""http://adaptivecards.io/schemas/adaptive-card.json""
        },
        ""$when"": ""${!showProperty}""
    },
    {
        ""type"": ""Action.Submit"",
        ""title"": ""Status of my requests"",
        ""id"": ""MyTickets"",
        ""data"": { ""text"": ""${text}"", ""commandId"": ""MyTickets"" },
        ""$when"": ""${!showProperty}""
    }
],
""$schema"": ""http://adaptivecards.io/schemas/adaptive-card.json"",
""version"": ""1.2"",
""msteams"": {
    ""width"": ""Full""
},

}

【问题讨论】:

    标签: microsoft-teams adaptive-cards


    【解决方案1】:

    是的,Microsoft Teams 已支持 Typeahead 支持(通过在用户键入输入时缩小或过滤输入选择集来简化输入选择)。尝试使用 1.1、1.2 和 1.3 版本的自适应卡,每种情况都运行良好。附上我的自适应卡片示例以供参考。

    {
      "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
      "type": "AdaptiveCard",
      "version": "1.3",
      "body": [
        {
          "speak": "Tom's Pie is a pizza restaurant which is rated 9.3 by customers.",
          "type": "ColumnSet",
          "columns": [
            {
              "type": "Column",
              "width": 2,
              "items": [
                {
                  "type": "TextBlock",
                  "text": "PIZZA"
                },
                {
                  "type": "TextBlock",
                  "text": "Tom's Pie",
                  "weight": "bolder",
                  "size": "extraLarge",
                  "spacing": "none"
                },
                {
                  "type": "TextBlock",
                  "text": "4.2 ★★★☆ (93) · $$",
                  "isSubtle": true,
                  "spacing": "none"
                },
                {
                  "type": "TextBlock",
                  "text": "**Matt H. said** \"I'm compelled to give this place 5 stars due to the number of times I've chosen to eat here this past year!\"",
                  "size": "small",
                  "wrap": true
                },
                {
                  "type": "Input.ChoiceSet",
                  "label": "Select a user",
                  "isMultiSelect": false,
                  "choices": [
                    {
                      "title": "User 1",
                      "value": "User1"
                    },
                    {
                      "title": "User 2",
                      "value": "User2"
                    },
                    {
                      "title": "User 3",
                      "value": "User3"
                    },
                    {
                      "title": "User 4",
                      "value": "User4"
                    },
                    {
                      "title": "User 5",
                      "value": "User5"
                    }
                  ],
                  "style": "filtered"
                }
              ]
            },
            {
              "type": "Column",
              "width": 1,
              "items": [
                {
                  "type": "Image",
                  "url": "https://picsum.photos/300?image=882",
                  "size": "auto"
                }
              ]
            }
          ]
        }
      ],
      "actions": [
        {
          "type": "Action.OpenUrl",
          "title": "More Info",
          "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
        }
      ]
    }
    

    【讨论】:

    • 你是怎么做到的?我基本上将版本更新到 1.4,但我仍然没有反映预输入功能。我的自适应卡扩展也更新了。你能告诉我你还有什么其他配置吗?谢谢。
    • 我使用了与自适应卡答案部分中提到的相同的 json。将该自适应卡片发送到 Teams 频道并能够过滤输入选择
    猜你喜欢
    • 1970-01-01
    • 2019-01-18
    • 2020-08-15
    • 1970-01-01
    • 2014-09-10
    • 2020-07-07
    • 2021-02-06
    • 2021-11-14
    • 2020-07-29
    相关资源
    最近更新 更多