Action.ShowCard 默认打开

Action.ShowCard open by default

我查看了有关 git 自适应卡的各种资源以及文档,这并不明显。

我想要一张默认展开的卡片,而不是关闭时切换为打开的卡片。

由于支持平台开发,我只需要利用 1.0 和 1.1 功能。

您不能在 < 1.2 中执行此操作。

一旦您能够使用 1.2,您就可以使用 Action.ToggleVisibility。这是一张卡片示例:

{
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "Container",
            "items": [
                {
                    "type": "TextBlock",
                    "text": "Everything in the blue container will stay when the button is clicked.",
                    "wrap": true
                }
            ],
            "spacing": "ExtraLarge",
            "separator": true,
            "style": "accent"
        },
        {
            "type": "Container",
            "items": [
                {
                    "type": "TextBlock",
                    "text": "Everything in the green container will hide when the button is clicked",
                    "wrap": true
                },
                {
                    "type": "Image",
                    "altText": "",
                    "url": "https://docs.botframework.com/static/devportal/client/images/bot-framework-default.png"
                }
            ],
            "spacing": "None",
            "horizontalAlignment": "Center",
            "style": "good",
            "selectAction": {
                "type": "Action.ToggleVisibility",
                "targetElements": [
                    "hide"
                ]
            },
            "id": "hide"
        },
        {
            "type": "ActionSet",
            "actions": [
                {
                    "type": "Action.ToggleVisibility",
                    "title": "Hide the Green Section",
                    "targetElements": [
                        "hide"
                    ]
                }
            ]
        }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.0"
}

你可以把那个JSON粘贴到Designer的"Card Payload Editor"里,然后点击"Preview Mode"试试看。

请注意,是否支持此功能取决于客户,而不仅仅是卡片架构。


由于您不能使用 1.2,替代方案可能是:

  1. 创建带有提交操作的卡片
  2. 单击“提交”操作后,让客户将卡片替换为不包含您要隐藏的部分的卡片。

在 Bot Framework 中,您将使用 UpdateActivity() 在支持它的渠道(通常是普通用户可以编辑消息的渠道)上完成 #2。

这并不理想,但这是您使用 < 1.2 可以做的所有事情。