Chat Message Specification¶
Over the Websocket and through the Chat REST API, various types of messages are sent. Each of these messages corresponds to a certain media type, e.g. a text utterance, a break, a typing indicator, an image, et cetera.
Common message fields¶
Each chat message has the following fields:
Parameter | Type | Description |
---|---|---|
type |
string | The type of message. See "message types" below. |
payload |
anything | The type-specific payload of this message. See "message types" below. |
delay |
integer or "infinity" | The delay (in milliseconds) that should be added after displaying the current message. When "infinity", it should not display subsequent messages. |
time |
string | ISO timestamp of the time this message was created |
as |
object | When this message was created as if it was sent by another identity, this object is filled with information about that identity. |
Message types¶
type: "text"
¶
Shows a text message that is sent from the bot to the user. The
payload
consists of a {"message": "the actual message"}
object.
The text can contain Markdown markup tags; before being displayed, the
Markdown should be converted into HTML or stripped from the text when
HTML is not applicable.
type: "typing"
¶
Instruction to show or hide the typing indicator for the bot. The
payload
will be a boolean which is either true
to show the typing
indicator, or false
to hide it.
type: "location"
¶
Shows a location marker. The payload
will be a JSON object with a
lat
and a lon
field to show the actual coordinate of the location
marker.
type: "media"
¶
Shows a media item. The payload
will be a JSON object with a url
to the URL of the media item, and a kind
field that is either
audio
, video
, image
or file
.
type: "emit"
¶
Indicates that an event has been emitted to the client, using
Bubblescript's emit
statement. The payload object will contain a
event
string with the name of the event, and (again) a payload
field with the payload that was sent with the event.