Sending Rich Content (Images, Audio, Video, Files)

To train a bot you need to create a text file with sample questions and matching answers. The system will then learn how to select or generate textual responses to textual questions on a one-to-one basis.

The Facebook platform supports a few varieties of rich content that can be sent to the user in response to a question instead of plain text. Bots cannot learn how to create anything other than text, so it is not possible for a bot to be trained to generate rich-content. Webhooks, however, can deliver multiple formats of data in their payload and the system will deliver whichever format is most suitable to the originating caller.

Here's a sample webhook payload with rich-content.

             "text":"non-Facebook users will see this text",
                      "url":"<img src="">"

Notice that the text field is still present at the upper level. This is necessary because chat requests may or may not have come from Facebook, so we need a text response to fall back on in the case that they did not. After this comes the Facebook-specific rich-content node imaginatively called facebook.

When a chat request comes in and a webhook is called both of these fields will be validated. If the bot is integrated with Facebook and the chat request actually came from Facebook then the rich-content from the facebook node will be sent as a response. Otherwise the rich-content will be discarded and the text field will be sent back.

The following raw content types are supported:

  • Images
  • Audio
  • Video
  • Files

The following templates are supported for rich-content delivery:

  • Button Templates
  • Generic Templates
  • List Templates

Alternatively, quick-replies can be used to present options to the user.

How did we do?