Message Formats

# Text

say "His palms are sweaty, knees weak, arms are heavy" // short form
say Text("There's vomit on his sweater already, mom's spaghetti") // long form
The Text component of the Webapp channel also supports some basic Markdown:
say "He's _nervous_, but **on the surface** he looks [calm and ready](https://www.youtube.com/watch?v=_Yhyp-_hX2s)"

# Typing, Wait

say Typing(1000)
Obviously, Wait is also supported (it simply does not display a typing indicator or anything for the given duration).

# Image

say Image("https://images.unsplash.com/photo-1560114928-40f1f1eb26a0")

# Question, Button

say Question(
"Hi! My name is:", // equivalent to title="Hi! My name is:",
buttons=[Button("What?"), Button("Who?")]
)
If you need to retrieve a specific data when clicking on either button, use the payload argument of the Button component:
say Question(
"Hi! My name is:",
buttons=[
]
)
hold
say "user clicked on button with the {{event}} payload"
The Webapp channel also supports single Button components. However, as cross-channel support for single buttons is not guaranteed, we encourage you to use the standard Question component instead, with a title.

Quick replies are similar to Questions, where the buttons are removed from view once the user has selected one of them. In a majority of scenarios, you should prefer QuickReplies over regular questions, especially when you don't want the user to be able to scroll up and select one of the buttons after they have made a first choice. Questions should be used when a button is used as a trigger to a given flow (as configured in the bot's AI Rules).
"Do you like cheese?",
buttons=[Button("Yes 🧀"), Button("Also yes 🫕")]
)

# UserInput

In some cases it may be desirable to temporarily disable the user input to force the user to select one of the options without letting them type anything.
say UserInput(false) // disables the user input
say UserInput(true) // reenables the user input
Please note that if the page is refreshed, the user input will go back to being enabled by default even if it was first disabled.

# Video, Audio

The Video component supports links to mp4 files, as well as Youtube, Vimeo and Dailymotion URLs. The Audio component supports links to mp3 files, as well as Spotify, Soundcloud and Deezer URLs.
say Audio("https://open.spotify.com/track/1xB3YT8Rakvnfcc1dp2kzJ")
Standard limitations apply: if the end user is not logged in to a valid spotify/deezer/soundcloud account, only 30s will be playable in the audio component.
For full control over the clip, prefer using a standard mp3 file URL.

# Url

The Url component will automatically retrieve the target's favicon if available. If a text parameter is present, it will be used as the component's title.
say Url("https://www.wikipedia.org/", text="Visit Wikipedia")
// if you don't want to display the URL itself, making it harder
// to identify that it is a link and not just an action button, add hide_url=true
say Url("https://www.wikipedia.org/", text="Visit Wikipedia", hide_url=true)

# Carousel, Card

A Carousel is essentially a collection of Card elements A single Card will display as a Carousel of 1 element. Each Card can have a maximum of 2 Button elements.
do card1 = Card(
"The Marshall Mathers LP",
subtitle="Release date: May 23, 2000",
)
do card2 = Card(
subtitle="Release date: February 23, 1999",
)
do card3 = Card(
"The Marshall Mathers LP 2",
subtitle="Release date: November 5, 2013",
)
say Carousel(cards=[card1, card2, card3])
The cards themselves can be made clickable by adding an optional default_action Url() parameter:
do card = Card(
"The Marshall Mathers LP",
subtitle="Release date: May 23, 2000",
default_action=Url("https://en.wikipedia.org/wiki/Eminem"),
)
The carousel can also automatically navigate horizontaly by adding the optional autoplay parameter (which defaults to false):
say Carousel([ card1, card2, card3 ], autoplay=true)

# Calendar

This component will display a rich calendar in the webapp. By default, when passed with no argument, a simple single-date datepicker will appear:
say Calendar()
single mode
Optional parameters allow to set a min_date and/or max_date (by unix timestamp, in milliseconds) or an input_mode to accept single (the default) multiple or range inputs by the user:
say Calendar(
min_date=1617494400000, // April 4th, 2021
max_date=1623974400000, // June 18th, 2021
input_mode="range" // can also be "multiple" or "single"
)
range mode
multiple mode
The event value of a Calendar input will be comma-separated values of all user inputs. Also, event.input_mode will be set to the mode of the requested calendar, so that you can differenciate between single, multiple and range modes when receiving values.
// given this sample CSML code
say Calendar(...)
hold
say "{{event.get_content()}}"
// example single mode
{
"input_mode":"single",
}
// example multiple mode
{
"input_mode":"multiple",
}
// example range mode
{
"input_mode":"range",
}

# Input

To gain some control over what a user can enter in a form (for example, if you need to make sure they only enter an email address or a valid number when required), you can also use the Input component.
There are several variants of input fields: email, text, textarea, number and password. By default, inputs are type="text". All parameters are optional, and the basic usage is as follows:
say Input(
type="text", // default
title="What is this field?",
description="Some details about what is expected",
minlength=0, // for text/email/textarea inputs only
maxlength=100, // for text/email/textarea inputs only
required=false,
placeholder="This is an input",
default_value="This is set by default",
submit_label="Submit" // the text for the validation button, defaults to OK
)
You can check this reference about the minlength and maxlength parameters: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text#additional_attributes
A completely bare say Input() component will result in this simple, empty text input:
Inputs with type="number" can have some different parameters, just like HTML inputs (all are optional as well):
say Input(
type="number",
title="Enter a number",
min=-14.3,
max=42,
// the other parameters from the previous example also apply
)
You can check this reference about the min and max parameters: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input/number#additional_attributes.
To learn more about the inputs with type="password", read the documentation about secure inputs (hold_secure): https://docs.csml.dev/language/standard-library/keywords#hold_secure

// Mandatory
options = [
],
// Optional fields:
description="You can only pick one!",
selected = "yummy", // Preselect a value
)

# Multiselect, Checkbox

If you want to let users select multiple options, the Multiselect() or Checkbox() components are a great solution. Users will be able to select any number of options in the given list. You can force a min and max number of choices, or if required=true, it means that at least one option must be selected to continue.
Both the Multiselect and Checkbox components work exactly the same, only the display will be different. Try both to find out which one suits you best!
// A list of options that are highlighted as you select them
say Multiselect(
title="Why do you like CSML?",
description="Select all options that apply!",
min=2,
submit_label="Yes, that's it!",
options=[
Button("The mascot 🦜 is cool", payload="pako"),
]
)
// The same component also works as a simple checkbox list
say Checkbox(
title="Why do you like CSML?",
description="Select all options that apply!",
min=2,
submit_label="Yes, that's it!",
options=[
Button("The mascot 🦜 is cool", payload="pako"),
]
)
Multiselect example
Checkbox example
When several options are selected, you will receive a comma-separated list of the corresponding payloads (not necessarily the button's title!), in the order they were selected by the user. In the case above, you would receive:

# Dropdown

Like the Radio component, the Dropdown lets users pick an option from a list:
say Dropdown(
// Mandatory list of options
options=[
Button("The mascot 🦜 is cool", payload="pako"),
],
// Optional parameters
title="Why do you like CSML?",
description="Select the principal reason!",
placeholder="They are all good reasons...",
selected="easy", // value selected by default
submit_label="Yes, that's it!",
)

# LaTeX

LaTeX is a popular language that lets you write (among other things) complex math formulas. The webapp and chatbox include KaTeX to support this language natively with a custom component:
start:
say LaTeX(
"$$x^2 + y^2 = z^2$$",
// If the user has "audio mode" enabled the tts parameter
// will be used as the basis for the speech synthesis
tts="This is the Pythagorean theorem!",
)
say LaTeX("\\def\\arraystretch{1.5}
\\begin{array}{c:c:c}
a & b & c \\\\ \\hline
d & e & f \\\\
\\hdashline
g & h & i
\\end{array}")
You can find more examples of supported formats on the KaTeX documentation: https://katex.org/docs/supported.html. Please keep in mind that backslashes (\) must be escaped properly in your code!
You can also add LaTeX inline in any standard text like by encapsulating it inside {latex}...{/latex} tags:
say "This equation {latex} $$x^2 + y^2 = z^2$$ {/latex} is super cool"

# Signature

You can display a simple signature field i.e to collect user consent and receive it as a png file.
// Display a simple signature field
say Signature()
// The field can be customized (all parameters are optional)
say Signature(
submit_label="I consent"
)
Signature field with all parameters

# OAuthRequest

You can use the OAuthRequest component as specified here:
Export as PDF
Text
Typing, Wait
Image
Question, Button