简体   繁体   中英

Adaptive card are not showing in webchat where as showing in MS Teams

We are using the below code to display the adaptive card in Webchat and Teams. Its working correctly in Teams and in Webchat its displaying as a line.

在此处输入图像描述

在此处输入图像描述

Adaptive card is showing up in MS teams

在此处输入图像描述

Adaptive card is showing up in Webchat

在此处输入图像描述

Webchat and msteam are different channels so it's required additional properties for rendering actions in the bot framework.

The MS Teams Adaptive card required special property with the name msteams to the object in an object submit action's data property in order to access this functionality.

{
"type": "Action.Submit",
"title": "Click me for messageBack",
"data": {
"msteams": {
"type": "messageBack",
"displayText": "I clicked this button",
"text": "text to bots",
"value": "{\"bfKey\": \"bfVal\", \"conflictKey\": \"from value\"}"
},
"extraData": {}
}
}

As per your card "id" property is missing in the "AdaptiveSubmitAction" and need to differentiate both channel property Data values in the implementation.

Replace the "AdaptiveActionSet" code with the below one.

new AdaptiveActionSet() {
Actions = new List < AdaptiveAction > () {
    new AdaptiveSubmitAction() {
        Title = ResourceString.SubmitText,
            Id = ResourceString.SubmitText,
            if (turnContext != null && turnContext.Activity.ChannelId == Channels.Msteams) {
                Data = new Jobject {
                    {
                        "msteams",
                        new JObject {
                            {
                                "type",
                                "messageBack"
                            }, {
                                "displayText",
                                "Hello"
                            }, {
                                "text",
                                "Hello"
                            }
                        }
                    }
                }
            }
        else {
            Data = new JObject {
                {
                    "type",
                    "messageBack"
                }, {
                    "displayText",
                    "Hello"
                }, {
                    "text",
                    "Hello"
                }
            }
        }
    }
}
}

Microsoft Docs: MS Team Docs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM