0

您好,我正在使用 api.ai 或 dialogflow 在 Skype 中构建一个机器人,就像现在所说的那样。无论如何,这是我的自定义有效载荷:

{
"skype": {
"type": "",
"attachmentLayout": "",
"text": "",
"attachments": [
  {
    "contentType": "",
    "content": {
      "title": "",
      "images": [
        {
          "url": ""
        }
      ],
      "buttons": [
        {
          "type": "",
          "title": "",
          "value": ""
        }
      ]
    }
  }
]
}
}

这是我的 webhook 响应:

"data": {
    "skype": {
      "type": "message",
      "attachmentLayout": "carousel",
      "text": "Here you go!",
      "attachments": [
        {
          "contentType": "application/vnd.microsoft.card.hero",
          "content": {
            "title": "Italian Cassoulet (Italian Chili)",
            "images": [
              {
                "url": "http://img.food.boxspace.in/image/rbk_57139479f2705/hdpi.jpg"
              }
            ],
            "buttons": [
              {
                "type": "openUrl",
                "title": "View Recipe",
                "value": "http://recipebk.com/Share.html#url=rbk_57139479f2705"
              }
            ]
          }
        }
      ]
    }
  }
}

现在,如果我嵌入这个响应,我会在 Skype 上得到一个卡片轮播的结果。但是当我对我的 webhook 尝试相同的操作时,不会显示任何消息。有人可以告诉我我做错了什么吗?已经检查了这个Stackoverflow 问题和这个api.ai 链接,但到目前为止它没有用。

4

1 回答 1

1

好的,所以如果我理解正确,在 API.ai 在线控制台上创建响应是可行的,但是当你从你的 webhook 生成 json 时它会失败吗?

仅供参考,测试可能有点困难,但在在线控制台中,您可以单击右侧的“默认响应”,您可以在此处测试您的意图以“Skype”。这样,您可以查看底部的错误消息,看看是否有任何错误以及原因。

既然这已经被清除了,即使文档说您应该将 webhook 中的自定义有效负载嵌入数据字段中,我也根本不这样做。我只是按照与 API.ai 完全相同的方式通过覆盖 webhook 响应中的 message 字段来生成响应。举例来说,我会给你完整的 webhook 响应,它为我的聊天机器人意图创建了几个 Richcard 列表。如您所见,我将所有内容都放在了 Json 的消息字段中。

{
  "speech": "",
  "displayText": "",
  "data": {

  },
  "contextOut": [

  ],
  "source": "Webhook",
  "messages": [
    {
      "type": 4,
      "platform": "skype",
      "speech": "",
      "payload": {
        "skype": {
          "attachmentLayout": "list",
          "attachments": [
            {
              "contentType": "application\/vnd.microsoft.card.hero",
              "content": {
                "title": "Unit 2A",
                "subtitle": "",
                "text": "These timeslots are available for 2017-10-16",
                "images": [

                ],
                "buttons": [
                  {
                    "type": "imBack",
                    "title": "from 13:00 until 14:00 Unit 2A",
                    "value": "from 13:00 until 14:00 Unit 2A"
                  },
                  {
                    "type": "imBack",
                    "title": "from 14:00 until 15:00 Unit 2A",
                    "value": "from 14:00 until 15:00 Unit 2A"
                  },
                  {
                    "type": "imBack",
                    "title": "from 15:00 until 16:00 Unit 2A",
                    "value": "from 15:00 until 16:00 Unit 2A"
                  }
                ]
              }
            },
            {
              "contentType": "application\/vnd.microsoft.card.hero",
              "content": {
                "title": "Unit 1",
                "subtitle": "",
                "text": "These timeslots are available for 2017-10-16",
                "images": [

                ],
                "buttons": [
                  {
                    "type": "imBack",
                    "title": "from 13:00 until 14:00 Unit 1",
                    "value": "from 13:00 until 14:00 Unit 1"
                  },
                  {
                    "type": "imBack",
                    "title": "from 14:00 until 15:00 Unit 1",
                    "value": "from 14:00 until 15:00 Unit 1"
                  },
                  {
                    "type": "imBack",
                    "title": "from 15:00 until 16:00 Unit 1",
                    "value": "from 15:00 until 16:00 Unit 1"
                  },
                  {
                    "type": "imBack",
                    "title": "from 16:00 until 17:00 Unit 1",
                    "value": "from 16:00 until 17:00 Unit 1"
                  }
                ]
              }
            }
          ]
        }
      }
    }
  ]
}

但是请注意,API.ai 将简单地以这种方式覆盖消息并将其传递给Skype。有关丰富卡的更多信息,您可以阅读:https ://docs.microsoft.com/en-us/bot-framework/rest-api/bot-framework-rest-connector-add-rich-cards并使用 Json 结构你的 api.ai 网络钩子。

我已经给出了完整的示例,因为我很难以您提供问题的方式测试您的设置,而且 API.ai 在某些情况下是一个黑盒,具有未记录的功能......

于 2017-10-16T10:22:06.237 回答