CSML Reference
  • Introduction
  • Installing CSML
  • Sending and Receiving Messages
    • Message Payloads
    • Custom Components
  • The Event
  • Memory
    • Using Variables in Messages
    • Temporary and Long-Term variables
    • Global variables
  • Navigating in a CSML Bot
  • Conditional Logic
  • External Code Execution
  • Native CSML Functions
  • Value Types
  • Automatic Type Inference
  • 📑CSML Studio Documentation
  • Standard Library
    • Keywords
    • Built-in Functions
    • HTTP Client
    • SMTP Client
    • Crypto Utilities
      • JWT
      • Hash, HMAC
      • Base64, Hex
    • String methods
    • Array methods
    • Object methods
    • Number methods
    • Generic methods
Powered by GitBook
On this page

Was this helpful?

Edit on Git
Export as PDF

Conditional Logic

PreviousNavigating in a CSML BotNextExternal Code Execution

Last updated 3 years ago

Was this helpful?

As in any 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

do btn = Button("yes")
do num = 1987
do batman = "Bruce Wayne"

if ("Hello!" match btn) {
  say "Not at all"
}
// for shorter code you can also use this shorthand version
if (54 < num) say "Absolutely true!"

if (3 >= 2 && batman != "Robin") say "Correct"

if (username.match(batman)) say "I'm Batman"
else if (username.to_lowercase() == "robin") say "I'm Robin"
else {
  say "I'm apparently neither Batman nor Robin"
}
turing-complete