我正在关注Add Outgoing Webhooks以显示带有文本提示的自适应卡片:
{
"type": "message",
"attachments": [
{
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.3",
"body": [
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": " Input.Text elements",
"horizontalAlignment": "Center",
"wrap": true
},
{
"type": "TextBlock",
"text": "Comments",
"wrap": true
},
{
"type": "Input.Text",
"isMultiline": true,
"id": "MultiLineVal"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Submit",
"data": {
"id": "1234567890"
}
},
{
"type": "Action.ShowCard",
"title": "Show Card",
"card": {
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"text": "Enter comment",
"wrap": true
},
{
"type": "Input.Text",
"id": "CommentVal"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "OK"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
}
]
}
}
]
}
卡片 json 是从https://adaptivecards.io/designer/上的标准输入模板生成的
该机器人配置了https://teamsbot.free.beeceptor.com/test4作为传出 webhook:
向机器人发送消息,我在https://beeceptor.com/console/teamsbot上看到了请求,它返回了模拟,我得到了在团队中显示的卡片。
当我单击“提交”时,Something went wrong. Please try again.
出现错误:
beeceptor 上没有新请求,我在 chrome devtools 中看到 2 个连续的 400 错误:
curl 'https://uk.ng.msg.teams.microsoft.com/v1/agents/f9f5e125-xxxx-xxxx-xxxx-9a9a8dcb1824/invoke' \
-H 'authority: uk.ng.msg.teams.microsoft.com' \
... many irrelevant headers ...
-H 'accept: json' \
-H 'x-ms-client-version: 1415/1.0.0.2022020411' \
-H 'x-ms-user-type: null' \
-H 'authentication: skypetoken=eyJhbGciOiJSUzI...very long token ... zZy_S4a0zp8m_a72SMuew' \
-H 'origin: https://teams.microsoft.com' \
-H 'referer: https://teams.microsoft.com/' \
--data-raw '{"value":{"id":"1234567890"},"conversation":{"id":"19:F32YIP...long id...@thread.tacv2;messageid=1644066509347"},"clientMessageId":"3673456194497933931","serverMessageId":"1644067693444","messageType":"RichText/Media_Card","name":"messageback","imdisplayname":"Azure Admin","complianceData":{"action":{"type":"Action.Submit","title":"Submit"}}}'
结果为 400 响应,正文如下:
{"errorCode":201,"message":"The resource URL agentMri is misformatted."}
该请求之后是非常相似的请求:
curl 'https://uk.ng.msg.teams.microsoft.com/v1/agents/f9f5e125-xxxx-xxxx-xxxx-9a9a8dcb1824/invoke' \
-H 'authority: uk.ng.msg.teams.microsoft.com' \
... same irrelevant headers ...
-H 'accept: json' \
-H 'x-ms-client-version: 1415/1.0.0.2022020411' \
-H 'x-ms-user-type: null' \
-H 'authentication: skypetoken=eyJhbGciOiJSUz ... same token ...tzZy_S4a0zp8m_a72SMuew' \
-H 'origin: https://teams.microsoft.com' \
-H 'referer: https://teams.microsoft.com/' \
--data-raw '{"value":{"id":"1234567890","MultiLineVal":"My comment"},"conversation":{"id":"19:F32YIP...same id..1@thread.tacv2;messageid=1644066509347"},"clientMessageId":"3673456194497933931","serverMessageId":"1644067693444","messageType":"RichText/Media_Card","name":"messageback","imdisplayname":"Azure Admin","complianceData":{"action":{"type":"Action.Submit","title":"Submit"}}}'
响应是相同的 400:
{"errorCode":201,"message":"The resource URL agentMri is misformatted."}
我能发现的唯一区别是--data-raw '{"value":{"id":"1234567890","MultiLineVal":"My comment"},"
零件。第二个请求有"MultiLineVal":"My comment"
. 这正是我希望在 beeceptor 方面看到的,但它从未到达 API。
目前还不太清楚什么是agentMri
,它在哪里以及如何被错误格式化,以及在自适应卡中进行哪些更改以使表单提交到同一个 webhook 域。我不确定这个 agentMri “格式错误”是否相关,但它是来自 Teams 的唯一一个包含我在自适应卡中输入的字符串的 http 请求。