# Conditional Logic

As in any [turing-complete](https://en.wikipedia.org/wiki/Turing_completeness) 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

```cpp
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"
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.csml.dev/language/conditional-logic.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
