MS Teams + 图形 API 自适应卡可在按钮上发送响应

问题描述 投票:0回答:1

我正在从nodeJS服务器调用MS团队图形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
                }
            ]
        }

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

node.js microsoft-graph-api microsoft-teams
1个回答
0
投票

这是设计使然。 “imBack”或“messageBack”调用无法通过 Graph API 进行。

只有“openUrl”才有效。

© www.soinside.com 2019 - 2024. All rights reserved.