0
votes

I have a problem where I am unable to retrieve values from the message card text input in Microsoft Teams, but the same JSON template actually works on Message Card Playground.

A brief overview of my Microsoft Card implementation. I have to use MessageCard as I am using connectors (incoming webhook) to send a card to Microsoft Teams. Thus, the input value substitution syntax is referred from Message Card Reference - {{<id of input>.value}}. I am not getting any value using this syntax in my Message Card when I am in TEAMS. E.g. User filled in a textbox, and the value is not being captured or cannot be retrieved with this syntax.

The card that I used is as followed:

{
"@type":  "MessageCard",
"@context":  "http://schema.org/extensions",
"themeColor":  "0076D7",
"summary":  "{{ctx.monitor.name}}",
"sections":  [
                 {
                     "activityTitle":  "![TestImage](https://47a92947.ngrok.io/Content/Images/default.png){{ctx.monitor.name}}",
                     "activitySubtitle":  "Alert",
                     "activityImage":  "https://teamsnodesample.azurewebsites.net/static/img/image5.png",
                     "facts":  [
                                   {
                                       "name":  "Assigned to",
                                       "value":  "Sam"
                                   }
                               ],
                     "markdown":  true
                 }
             ],
"potentialAction":  [
                        {
                            "@type": "ActionCard",
                            "name": "Add a comment",
                            "inputs": [
                                {
                                    "@type": "TextInput",
                                    "id": "comment",
                                    "title": "Enter your comment",
                                    "isMultiline": true
                                }
                            ],
                            "actions": [
                                {
                                    "@type": "HttpPOST",
                                    "name": "OK",
                                    "target": "https://webhook.site/ab592c11-4590-438d-90c2-57bc4bb4aa8a?serviceToken=d2l0cy1zYW06MXFhekBXU1g%3D",
                                    "body": "{{comment.value}}"
                                }
                            ]
                        }
                    ]
}

Note: You can see there is "summary": "{{ctx.monitor.name}}", it is a property from Kibana (a data visualization tool). This value works, but it is not our focus right here. My problem is I cannot get any value from {{comment.value}}, it is an empty string.

My questions are:

  1. Is this the limitation coming from MSFT Teams itself?
1
Currently web hook does not support Action card. Could you please check this docs for more info? Could you please try using adaptive card or message card instead of action card? try if that helps.Nikitha-MSFT
@Nikitha-MSFT I am confused by your message, referring to Message Card Reference, i am unable to use adaptive card as i am sending message via connector. I am using message card in my case. And action card is part of the actions from message card.csamleong
We are able to reproduce the issue at our end. Raised a bug.Nikitha-MSFT

1 Answers

0
votes

@csamleong could you please replace the "body": "comment ={{comment.value}}" so you will receive the comment value: card json:

{
"summary""Card \"Test card\"",
"themeColor""0078D7",
"@type":  "MessageCard",
"@context":  "http://schema.org/extensions",
"themeColor":  "0076D7",
"summary":  "{{ctx.monitor.name}}",
"sections":  [
                 {
                     "activityTitle":  "![TestImage](https://47a92947.ngrok.io/Content/Images/default.png){{ctx.monitor.name}}",
                     "activitySubtitle":  "Alert",
                     "activityImage":  "https://teamsnodesample.azurewebsites.net/static/img/image5.png",
                     "facts":  [
                                   {
                                       "name":  "Assigned to",
                                       "value":  "Sam"
                                   }
                               ],
                     "markdown":  true
                 }
             ],
"potentialAction":  [
                        {
                            "@type": "ActionCard",
                            "name": "Add a comment",
                            "inputs": [
                                {
                                    "@type": "TextInput",
                                    "id": "comment",
                                    "title": "Enter your comment",
                                    "isMultiline": true
                                }
                            ],
                            "actions": [
                                {
                                    "@type": "HttpPOST",
                                    "name": "OK",
                                    "target": "https://daf47bb241c6.ngrok.io//weatherforecast/Configure/Comment",
                                    "body": "comment={{comment.value}}"
                                }
                            ]
                        }
                    ]
}

Post Method:

[HttpPost]
        [Route("Configure/Comment")]
        public async Task<ActionResult> Comment()
        {
            string bodyStr;
            using (var reader = new StreamReader(this.Request.Body, Encoding.UTF8, true, 1024, true))
            {
                bodyStr = await reader.ReadToEndAsync();
            }
            string comment = string.IsNullOrWhiteSpace(bodyStr) ? string.Empty : bodyStr.Split('=')[1];
            Response.Headers.Add("CARD-UPDATE-IN-BODY", "true");
            return null;
        }

You will receive value in the comment varable.