Message Payloads

Standard message components

CSML message components all have a matching message format for client use in regular JSON. They can be extended by adding additional properties to the content wrapper.

Text()

1
> Text()
2
{
3
"content": {
4
"text": "message"
5
},
6
"content_type": "text"
7
}
Copied!

Typing()

1
> Typing()
2
{
3
"content": {
4
"duration": 1000
5
},
6
"content_type": "typing"
7
}
Copied!

Wait()

1
> Wait()
2
{
3
"content": {
4
"duration": 1000
5
},
6
"content_type": "wait"
7
}
Copied!

Url()

1
> Url()
2
{
3
"content": {
4
"url": "https://example.com",
5
"title": "title",
6
"text": "text"
7
},
8
"content_type": "url"
9
}
Copied!

Image()

1
> Image()
2
{
3
"content": {
4
"url": "https://example.com/image.jpg",
5
},
6
"content_type": "image"
7
}
Copied!

Audio()

1
> Audio()
2
{
3
"content": {
4
"url": "https://example.com/audio.mp3",
5
},
6
"content_type": "audio"
7
}
Copied!

Video()

1
> Video()
2
{
3
"content": {
4
"url": "https://example.com/video.mp4",
5
},
6
"content_type": "video"
7
}
Copied!

File()

1
> File()
2
{
3
"content": {
4
"url": "https://example.com/video.mp4",
5
},
6
"content_type": "file"
7
}
Copied!

Button()

1
> Button()
2
{
3
"content": {
4
"title": "Button title",
5
"payload": "Button payload"
6
},
7
"content_type": "button"
8
}
Copied!

Payload()

1
> Payload()
2
{
3
"content": {
4
"payload": "Custom payload"
5
},
6
"content_type": "payload"
7
}
Copied!

Question()

1
> Question()
2
{
3
"content": {
4
"title": "Question",
5
"buttons": [Button]
6
},
7
"content_type": "question"
8
}
Copied!

Child components

Component payloads can be included into one another seamlessly. For example:
1
// CSML
2
say Question(
3
"Where is Brian",
4
buttons = [
5
Button("In the kitchen"),
6
Button("Somewhere else"),
7
]
8
)
9
10
// JSON output
11
{
12
"content": {
13
"title": "Where is Brian",
14
"buttons": [
15
{
16
"content_type": "button",
17
"content": {
18
"title": "In the kitchen",
19
}
20
},
21
{
22
"content_type": "button",
23
"content": {
24
"title": "Somewhere else",
25
}
26
},
27
],
28
},
29
"content_type": "question"
30
}
Copied!
Last modified 1yr ago