我通过机器人框架为团队创建了一个机器人(nodejs
服务器)。
我正在尝试发送通过以下方式创建的自适应卡:adaptive cards designer
我收到错误消息:
{"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
}
]
}
]
}
希望获得帮助
答案 0 :(得分:2)
添加附件时,您需要设置附件对象的contentType
和content
属性。
{
"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
}
]
}
}
]
}
答案 1 :(得分:0)
根据上面的评论,这是一条主动消息,但是使用Bot Framework库比尝试直接调用bot端点要好得多(我想知道,“ REST”是否意味着Bot框架端点或Graph Api,但无论哪种情况,Bot框架都更易于处理主动消息。
有关如何在Node中执行此操作,请具体参见this sample。