Conditional Logic
As in any turing-complete programming language, CSML is able to handle any type of logic, in the form of loops and if/else statements.
As a CSML developer, you can easily implement any logic based on any variable or event, and very expressively decide how your conversation should be handled. Own of the main advantages of CSML is its descriptive textual interface, making it easy for anyone to understand the logic. It just makes sense and hides all the complexity of decision trees behind the simple concepts that every developer knows and uses.
A large part of developing CSML flows is about finding out whether an event matches a value in order to redirect the user to one step or another. The language comes with a number of helpers and operators:
  • comparison operators ==, !=, <, >, <=, >=
  • match keyword
  • && and || operators
  • if, else if, else keywords
1
do btn = Button("yes")
2
do num = 1987
3
do batman = "Bruce Wayne"
4
5
if ("Hello!" match btn) {
6
say "Not at all"
7
}
8
// for shorter code you can also use this shorthand version
9
if (54 < num) say "Absolutely true!"
10
11
if (3 >= 2 && batman != "Robin") say "Correct"
12
13
if (username.match(batman)) say "I'm Batman"
14
else if (username.to_lowercase() == "robin") say "I'm Robin"
15
else {
16
say "I'm apparently neither Batman nor Robin"
17
}
Copied!
Last modified 11d ago
Export as PDF
Copy link