团队中的自适应卡片不起作用 - REST API



我通过机器人框架为团队创建了一个机器人(nodejs服务器(。

我正在尝试发送我通过以下方式创建的自适应卡片:自适应卡片设计器

我得到错误:

{"code":"BadArgument","message":"ContentType of an attachment is not set"}

请求正文 :

{
"type": "message",
"from": {
"id": "xxxxxx"
},
"conversation": {
"id": "xxxxxx"
},
"recipient": {
"id": "xxxxx"
},
"replyToId": "xxxxx",
"text": "some text",
"attachments": [
{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"text": "some text"
},
{
"type": "Input.Date",
"separator": true
}
]
}
]
}

我将不胜感激

添加附件时,需要设置附件对象的contentTypecontent属性。

https://learn.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-connector-api-reference?view=azure-bot-service-4.0#attachment-object

{
"type": "message",
"from": {
"id": "xxxxxx"
},
"conversation": {
"id": "xxxxxx"
},
"recipient": {
"id": "xxxxx"
},
"replyToId": "xxxxx",
"text": "some text",
"attachments": [
{
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.2",
"body": [
{
"type": "TextBlock",
"text": "some text"
},
{
"type": "Input.Date",
"separator": true
}
]
}
}
]
}

根据上面的评论,这是一个主动消息,但使用机器人框架库比尝试直接调用机器人终结点要好得多(我想知道,"REST"是指机器人框架终结点还是图形 API,但在这两种情况下,机器人框架都更容易用于主动消息(。

请具体参阅此示例,了解如何在 Node 中执行此操作。

最新更新