Version History

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

Introduction

In this document we introduce the rich response format for our platform. Rich responses enables us to create 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 per 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 response types among: text, image, video, audio, link, cards, quick reply and downloadable. Each response type will be explained in detail below.

Text

{
"text": {
"text": ["Response 1", "Response 2", "Response 3"],
"isError": false
}
}
NameTypeRequiredDescription
textListYesResponse in text. Randomly returning 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
titleStringNoOptionally display title for the image.
urlStringYesUrl of the image.
altStringNoReplacement text should the image fail to load.

Video

{
"video": {
"title": "Video Title",
"url": "https://www.sample.com/video.flv",
"alt": "Some video."
}
}
NameTypeRequiredDescription
titleStringNoOptionally display the title for the video.
urlStringYesUrl of the video.
altStringNoReplacement text should the video fail to load.

Audio

{
"audio": {
"title": "Audio Title",
"url": "https://www.sample.com/music.mp3",
"alt": "Some audio."
}
}
NameTypeRequiredDescription
titleStringNoOptionally display the title for the audio.
urlStringYesUrl of the audio.
altStringNoReplacement text should the audio fail to load.

Cards

Let’s first see couple examples:

  • 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) should be displayed horizontally or vertically. Defaults to horizontal.
cardsListYesA list of cards to be displayed in the response.
--titleStringNoOptionally display title for each card.
--subtitleStringNoOptionally display subtitles for each card.
--imageUrlStringNoUrl of the image in a card.
--imageAltStringNoReplacement text should the card image fail to load.
--buttonsListNoA list of buttons to 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
titleStringNoOptionally display 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
titleStringNoOptionally display the title for the link.
textStringYesDisplayed text for the link.
urlStringYesUrl of the link.