NodeJS MS Teams +图形API自适应卡,用于在按钮上发送响应

iaqfqrcu  于 2023-08-04  发布在  Node.js
关注(0)|答案(1)|浏览(96)

我正在从nodeJS服务器调用MS teams graph API

const response = await axios({
            url: `${GRAPH_ENDPOINT}/v1.0/chats/${chatId}/messages`,
            method: 'POST',
            headers: {
                Authorization: `Bearer ${access_token}`,
                'Content-Type': 'application/json',
            },
            data
        });

字符串
其中data如下:

{
            "subject": null, //very important, it starts to send message from ms teams mobile app but not from windows app
            "body": {
                "contentType": "html",
                "content": "<attachment id=\"a1b2\"></attachment>"
            },
            "attachments": [
                {
                    "id": "a1b2",
                    "contentType": "application/vnd.microsoft.card.adaptive",
                    "contentUrl": null,
                    "content": JSON.stringify({
                        "type": "AdaptiveCard",
                        "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
                        "version": "1.2",
                        "actions": [
                            {
                                "type": "Action.Submit",
                                "title": "Submit",
                                "data": {
                                    "msteams": {
                                        "type": "imBack",
                                        "value": "Text to reply in chat"
                                    }
                                }
                            }
                        ]
                    }),
                    "name": null,
                    "thumbnailUrl": null
                }
            ]
        }


但是点击提交按钮不会在聊天中发送回复。我做错什么了?

wydwbb8l

wydwbb8l1#

这是故意的。'imBack'或'messageBack'调用将无法通过Graph API工作。
只有'openUrl'才能工作。

相关问题