botframeworkwebhooksdialogflow-esskype-bots

Skype bot not showing response from webhook but shows correct result for embedded custom payload in api ai


Hello I'm building a bot in skype using api.ai, or dialogflow, as it is called now. Anyway, this is my custom payload:

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

And here is my webhook response:

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

Now, if I embed this response I get the result as a carousel of cards on skype. but when I try the same with my webhook, no message is displayed. Can someone tell me what I'm doing wrong? Already check this Stackoverflow question and this api.ai link , but it's been of no use so far.


Solution

  • Alright, so if I get this correctly, creating the response on the API.ai online console works, but when you generate the json from your webhook it fails?

    Just for reference, it's maybe a bit difficult to test but in the online console you can click the "default response" on the right where you'd test your intents to "skype". This way, you could look at the error message at the bottom to see if there's any error and why.

    Now that that's cleared out of the way, even if the documentation says you should embed custom payloads from the webhook in the data field, I simply don't. I simply follow the exact same way API.ai generates the response by overriding the message field in the webhook response. As examples say more than words, I'll give you the full webhook response that creates a couple of lists of richcards for one of my chatbot intents. As you notice, I put everything in the message field of the 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"
                      }
                    ]
                  }
                }
              ]
            }
          }
        }
      ]
    }
    

    Do note however that API.ai will simply override the messages this way and passes it along to skype. For more information about richcards you could read: https://learn.microsoft.com/en-us/bot-framework/rest-api/bot-framework-rest-connector-add-rich-cards and use the Json structure in your api.ai webhook.

    I've given the full example as it's very difficult for me to test your setup the way you provided your question, also API.ai is a blackbox in some cases with undocumented features...