自适应卡中的Action.OpenUrl,用于打开URl的确认

时间:2019-11-20 12:16:46

标签: botframework chat bots chatbot azure-bot-service

我正在使用Microsoft Bot框架,我要求单击按钮后打开URL。我已经通过使用自适应卡实现了。单击按钮打开URL。 我需要实现确认选项,当用户单击按钮时,弹出窗口应该出现,并要求您确认打开URL。 我试过了它在仿真器中工作,但是在网络上却不工作。它只是打开URL而无需询问确认。

我的机器人将用于网络。

我已推荐https://adaptivecards.io/samples/

下面是我的自适应卡代码

"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
        "type": "AdaptiveCard",
        "version": "1.0",

        "actions": [
            {
                "type": "Action.OpenUrl",
                "title": "Action.OpenUrl",
                "url": "https://adaptivecards.io"
            }
        ]

enter image description here

谢谢 Sanjeev Gautam

1 个答案:

答案 0 :(得分:1)

这仅在本地仿真器中发生

要使这种情况在浏览器中发生,您需要采取不同的处理方式,您可以使用相同的自适应卡来实现此目的,我在下面提到了一个示例供您参考

{
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "type": "AdaptiveCard",
    "version": "1.0",
    "body": [
        {
            "type": "TextBlock",
            "text": "This is Vinay Jayaram Helping you to open a URL"
        }
    ],
    "actions": [
        {
            "type": "Action.ShowCard",
            "title": "https://adaptivecards.io",
            "card": {
                "type": "AdaptiveCard",
                "body": [
                    {
                        "type": "TextBlock",
                        "text": "Are You sure you want to open this link?"
                    }
                ],
                 "actions": [

            {
                "type": "Action.OpenUrl",
                "title": "YES",
                "url": "https://adaptivecards.io"
            }
        ],
                "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
            }
        }
    ]
}

看起来像这样:

enter image description here

Onclick:

enter image description here

参考:https://adaptivecards.io/explorer/Action.ShowCard.html

让我知道这是否适合您。快乐编码