首页 文章

Skype机器人没有显示来自webhook的响应,但显示了api ai中嵌入式自定义有效负载的正确结果

提问于
浏览
0

您好我正在使用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 questionapi.ai link,但到目前为止它没用 .

1 回答

  • 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也是一个黑盒子,在某些情况下还有未记录的功能......

相关问题