Sending and Receiving Messages

CSML is able to handle many types of messages by default.

To send a message to the end user, simply use the keyword say followed by the message type you want to send.

  say "I'm a text message"
  say Wait(1500)
  say Text("I'm also a text message")
  say Typing(1500)
  say Url("")
  say Image("")
  say Video("")
  say Audio("")
  say Question(
    title = "What is love?",
    buttons = [
      Button("baby don't hurt me"),
      Button("don't hurt me"),
      Button("no more")
  say Carousel(
    cards = [
        subtitle="an optional description",
        buttons=[Button("click me!")]

Styling text

You can style text using Markdown. Some channels however only partially support Markdown (Messenger for example only allows bold, italic, strikethrough, but not tables), so don't get too fancy there.

Quick Markdown reference

# Title 1
## Title 2


[link text](

Message types

Below is a list of default valid message components, which are automatically converted to nicely formatted messages for the channel in which the user is talking with the bot.





Output a simple string (with no styling attached). This is also the default type, alias of say "string". This component supports Markdown on channels that allow text formatting.


Wait number milliseconds before sending the next message


Display a typing indicator for number milliseconds


Url(string, text="text", title="title")

Format string as the URL. Optionally, the text and title parameters can provide a way to make "nicer" links, where supported.



Display the image available at URL string



Display the video available at URL string. Supports Youtube, Dailymotion and Vimeo URLs, or mp4 and ogg.



Display the audio available at URL string. Supports Soundcloud embed links, or mp3, wav and ogg.



Display string inside a clickable button


Question(title = string(, buttons = [Button]))

Display a list of buttons with a header of string. Title parameter is optional.

Text(string) + list of buttons

Card(title="string", buttons=[Button], image_url="string")

Display nicely formatted content in a Carousel component (on supported channels). Only title is mandatory.

Question(title, buttons) or Text(title)


Display a list of Cardcomponents in a carousel (on supported channels). The cards parameter is mandatory.

Components may receive additional optional parameters to accommodate the needs of certain channels.

For example, in the Messenger channel you can add a button_type="quick_reply" parameter to the Question component to provide a different type of buttons.

Asking Questions

A conversation with a chatbot is not very different from a human-to-human dialogue: sometimes the user talks, sometimes the bot talks.

CSML provides a solution when you need the chatbot wait for the user's input: using the hold keyword, the chatbot will remember its position in the conversation and simply wait until the user says something, then continue from there.

  say Question("Do you like cheese?", buttons=[Button("yes"), Button("no")])

  if (event == "yes") say "I'm glad to know that you like cheese!"
  else say "Oh that's too bad!"

Receiving messages

When receiving an event from an end-user, the CSML interpreter will try to:

  1. match it with a new flow,

  2. or consume it in the existing conversation,

  3. or trigger the default flow as defined in the bot settings,

by order of priority.

CSML Events are made available in the script when a step is triggered by a user's input. The event object is a complex structure which contains a lot more than just the string that was typed by the user. It contains a lot of information that is used by the CSML interpreter, for example the custom button payload to match a list of choices offered to the user. This makes it easy to handle both a click on a "OK" button or the user typing the word "yes".

By default, events are only expected when:

  • the flow was just triggered, the current step being triggered is start

  • the bot asked something to the user, and is waiting for the user's input at the same step

In those cases, a local variable, event, is made available, with the content of the user request. When no event is available, event is set to NULL.

⚠️ Limitations

The maximum theoretical size of a say payload is 16KB. However, each channel will have different limitations depending on the type of component. For a Text component for example, most channels are limited to a few hundred characters.

Please refer to each channel's official documentation to find out the practical limitations of each component.

Last updated