团队中的自适应卡无法工作 - REST API。

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

我创建了一个机器人(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
        }
      ]
    }
  ]
}

我将感谢帮助

node.js rest botframework microsoft-teams adaptive-cards
1个回答
2
投票

当添加附件时,你会想要设置附件中的 contentTypecontent 附件对象的属性。

https:/docs.microsoft.comen-usazurebot-servicerest-apibot-framework-rest-connector-api-reference?view=azure-bot-service-4.0#附件对象的属性。

{
    "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
                    }
                ]
            }
        }
    ]
}

0
投票

根据上面的评论,这是一个主动式消息,但使用Bot Framework库是一个比直接调用僵尸端点更好的方法(我想知道,你说的 "REST "是指Bot Framework端点还是Graph Api,但无论哪种情况,Bot Framework对于主动式消息都更容易操作)。

具体请看 本样本 以了解如何在Node中做到这一点。

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