Version History

VersionAuthorUpdateDate
1.0Yuchen GaoInitial draft12/31/2019
1.1Yuchen GaoUpdated text format to support potential multiple text records12/31/2019
1.2Yuchen GaoSplits video and audio01/12/2020
1.3Yuchen GaoAdded downloadable rich response type.
Add “isError” field in text response type
01/30/2020
1.4Yuchen GaoAdded a new rich response type: link03/05/2020

Introduction

This document introduces the rich response format for the platform. Rich responses enables the creation of responses of various types, including but not limited to text, images, videos, audios, cards, etc.

See the figure below for an example:

Supported Types

First Of All: Stages

A list named stage is returned for each user query. An example is shown below.

{
"stage": [
{
"text": {
"text": ["Hello", "Howdy", "Hola"]
}
},
{
"image": {
"title": "Image Title",
"url": "https://www.sample.com/hello.png",
"alt": "Some image."
}
}
]
}

All elements in this list must be of one of the following response types: text, image, video, audio, link, cards, quick reply and downloadable.

Text

{
"text": {
"text": ["Response 1", "Response 2", "Response 3"],
"isError": false
}
}
NameTypeRequiredDescription
textListYesResponse in text. Randomly return one of the elements
isErrorBooleanNoIf set to true, indicates that this text represents an error message

Image

{
"image": {
"title": "Image Title",
"url": "https://www.sample.com/img.png",
"alt": "Some image."
}
}
NameTypeRequiredDescription
titleStringNoDisplay title for the image
urlStringYesURL of the image
altStringNoAlt tags if the image fails to load

Video

{
"video": {
"title": "Video Title",
"url": "https://www.sample.com/video.flv",
"alt": "Some video."
}
}
NameTypeRequiredDescription
titleStringNoDisplay the title for the video
urlStringYesURL of the video
altStringNoAlt tags if the video fails to load

Audio

{
"audio": {
"title": "Audio Title",
"url": "https://www.sample.com/music.mp3",
"alt": "Some audio."
}
}
NameTypeRequiredDescription
titleStringNoDisplay the title for the audio
urlStringYesURL of the audio
altStringNoAlt tags if the audio fail to load

Cards

Some example cards:

  • The first example shows two messages, each containing a single card with multiple buttons, clicking on each button sends back a text to the chat window.

  • The second example (from facebook generic template example) shows that 3 cards (each with subtitles and two buttons) are displayed vertically, each with two buttons.

Here’s the formal definition for the card type:

{
"cards":{
"type":"horizontal",
"cards":[
{
"title":"Card Title",
"subtitle":"Card subtitles",
"imageUrl":"http://www.sample.com/img.png",
"imageAlt":"Card image here.",
"buttons":[
{
"text":"button text",
"postback":"https://qingyu.rsvp.ai/"
},
{
"text":"button text",
"postback":"send back text"
}
]
}
{
...
}
]
}
}
NameTypeRequiredDescription
typeEnum String (horizontal/vertical)YesWhether multiple cards (if applicable) are displayed horizontally or vertically. Defaults to horizontal
cardsListYesA list of cards to be displayed in the response
--titleStringNoDisplay title for each card
--subtitleStringNoDisplay subtitles for each card
--imageUrlStringNoURL of the image in a card
--imageAltStringNoAlt tags if the card image fail to load
--buttonsListNoA list of buttons for each card
----textStringYesText to be displayed on the button
----postbackStringYesA URL to open or the text to send back to chat

Quick Reply

Quick replies are shortcut buttons shown usually beneath a response message, see the example below:

{
"quickReplies": {
"quickReplies": [
{
"text": "button text",
"postback": "https://qingyu.rsvp.ai/"
},
{
"text": "button text",
"postback": "Send back text"
}
]
}
}
NameTypeRequiredDescription
quickRepliesListYesURL of the image in a card
--textStringYesText to be displayed on the label
--postbackStringYesA URL to open or the text to send back to chat

Downloadable

A downloadable response type sends a response with a file that users can download.

{
"downloadable": {
"title": "Downloadable Title",
"url": "https://www.sample.com/form.csv"
}
}
NameTypeRequiredDescription
titleStringNoDisplay the title for the downloadable file
urlStringYesURL of the downloadable file

A link response redirects users to a new web tab when clicked.

{
"link": {
"title": "Link Title",
"text": "Click me!",
"url": "https://www.sample.com"
}
}
NameTypeRequiredDescription
titleStringNoDisplay the title for the link
textStringYesDisplayed text for the link
urlStringYesURL of the link