简体   繁体   中英

MS teams adaptive card not sending input text value on submit

I am 500% sure it used to work and all of a sudden this is broken. The card for getting input is no longer passing the value back to nodejs.

The card looks like below:

{
       "type": "AdaptiveCard",
       "body": [
           {
               "type": "TextBlock",
               "text": "Note text"
           },
           {
               "type": "Input.Text",
               "placeholder": "Type a note",
               "isMultiline":  true,
               "id": "noteIdVal"
           }
           
       ],
       "actions": [
           {
               "type": "Action.Submit",
               "title": "Save",
               "data": { "action" : "add_note", "objNumber": objId, "objType": objectType }
           },
           {
               "type": "Action.Submit",
               "title": "Cancel",
               "data" : {"action": "cancel"}
           }
       ],
       "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
   }

On the submit action, in my nodejs i am getting the data in the values node which are passed in the data field. However, it is no longer attaching noteIdVal. Did something changed from MS side?

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": {}
}
}

The type property is "messageBack" the submit action will behave like a messageBack card action, which is like a combination of imBack and postBack.

Reference: Microsoft Docs for MS Teams Adaptive Card

So, may be useful to other folks here. I have two showCards and the content of both the show cards has a common text field with same id name "noteIdVal". As ultimately it is a single json and hence was the culprit.

Lesson, have all fields unique id values which is easy to miss when you have multiple show cards

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