MS 团队自适应卡在提交时不发送输入文本值

MS teams adaptive card not sending input text value on submit

我 500% 确定它曾经可以正常工作,但突然之间就坏了。获取输入的卡片不再将值传回给nodejs。

卡片如下所示:

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

在提交操作中,在我的 nodejs 中,我正在获取在数据字段中传递的值节点中的数据。但是,它不再附加 noteIdVal。 MS 方面有什么变化吗?

所以,可能对这里的其他人有用。我有两个展示卡,两个展示卡的内容都有一个具有相同 ID 名称“noteIdVal”的公共文本字段。因为它最终是一个单一的 json,因此是罪魁祸首。

教训,让所有字段都有唯一的id值,当你有多个展示卡时很容易错过

MS Teams 自适应卡需要特殊的 属性 名称 msteams 到对象中的对象提交操作的数据 属性 才能访问此功能。

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

类型属性是“messageBack”提交动作将表现得像一个messageBack卡片动作,就像是imBack和postBack的组合。

参考: Microsoft Docs for MS Teams Adaptive Card