Skype bot 未显示来自 webhook 的响应,但在 api ai 中显示了嵌入式自定义负载的正确结果
Skype bot not showing response from webhook but shows correct result for embedded custom payload in api ai
你好,我正在使用 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 进行同样的尝试时,没有显示任何消息。有人可以告诉我我做错了什么吗?已经检查过这个 Whosebug question and this api.ai link ,但到目前为止没有用。
好吧,如果我理解正确,在 API.ai 在线控制台上创建响应是可行的,但是当您从 webhook 生成 json 时它会失败?
仅供参考,测试起来可能有点困难,但在在线控制台中,您可以单击右侧的 "default response" 来测试您对 "skype" 的意图。这样,您可以查看底部的错误消息,看看是否有任何错误以及原因。
既然已经清除了障碍,即使文档说您应该在数据字段中嵌入来自 webhook 的自定义有效负载,我也不会这样做。我只是按照完全相同的方式 API.ai 通过覆盖 webhook 响应中的消息字段来生成响应。示例胜于雄辩,我将为您提供完整的 webhook 响应,该响应为我的一个聊天机器人意图创建了几个 richcards 列表。如您所见,我将所有内容都放在 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。有关 richcards 的更多信息,您可以阅读:https://docs.microsoft.com/en-us/bot-framework/rest-api/bot-framework-rest-connector-add-rich-cards 并在 api.ai webhook 中使用 Json 结构。
我已经给出了完整的示例,因为我很难按照您提供问题的方式测试您的设置,而且 API.ai 在某些情况下是一个黑匣子,具有未记录的功能...
你好,我正在使用 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 进行同样的尝试时,没有显示任何消息。有人可以告诉我我做错了什么吗?已经检查过这个 Whosebug question and this api.ai link ,但到目前为止没有用。
好吧,如果我理解正确,在 API.ai 在线控制台上创建响应是可行的,但是当您从 webhook 生成 json 时它会失败?
仅供参考,测试起来可能有点困难,但在在线控制台中,您可以单击右侧的 "default response" 来测试您对 "skype" 的意图。这样,您可以查看底部的错误消息,看看是否有任何错误以及原因。
既然已经清除了障碍,即使文档说您应该在数据字段中嵌入来自 webhook 的自定义有效负载,我也不会这样做。我只是按照完全相同的方式 API.ai 通过覆盖 webhook 响应中的消息字段来生成响应。示例胜于雄辩,我将为您提供完整的 webhook 响应,该响应为我的一个聊天机器人意图创建了几个 richcards 列表。如您所见,我将所有内容都放在 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。有关 richcards 的更多信息,您可以阅读:https://docs.microsoft.com/en-us/bot-framework/rest-api/bot-framework-rest-connector-add-rich-cards 并在 api.ai webhook 中使用 Json 结构。
我已经给出了完整的示例,因为我很难按照您提供问题的方式测试您的设置,而且 API.ai 在某些情况下是一个黑匣子,具有未记录的功能...