您好我正在使用api.ai或者对话框流程在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 question和api.ai link,但到目前为止它没有用。
答案 0 :(得分:1)
好吧,如果我这样做了,在API.ai在线控制台上创建响应是可行的,但是当你从webhook生成json时它会失败吗?
仅供参考,测试可能有点困难,但在在线控制台中,您可以单击右侧的“默认响应”,您可以在其中测试您的意图“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在某些情况下也是一个带有无证功能的黑盒子......