You are viewing the documentation for Blueriq 14. Documentation for other versions is available in our documentation directory.

TSL IF ELSEIF statement

The IF ELSEIF statement enables you to selectively perform tasks within your TSL message, based on some criteria, which evaluate to TRUE or FALSE.

When TRUE executes the task specified in the IF part of the statement, the task specified in the ELSEIF part of the statement is only executed when the specified criteria are met.


Syntax

[[[IF expr1]]] message1 [[[ELSEIF expr2]]] message2 [[[/IF]]]


Inputs

  • expr1 and expr2: are expressions which evaluate to TRUE or FALSE

  • message1 and message2: are TSL messages, so they can contain plain text and other TSL conditions.


Example

Suppose you want to create a welcoming message after a user has logged in to your application. Then you could create the following TSL message:

[[[IF time.hour >= 0 AND time.hour < 6]]]Good night [[[ELSEIF time.hour >= 6 AND time.hour < 12]]]Good morning [[[ELSEIF time.hour >= 12 AND time.hour < 18]]]Good afternoon [[[ELSEIF time.hour >= 18 AND time.hour ⇐ 23]]]Good evening[[[/IF]]] [[[user.first_name]]] [[[user.last_name]]]

When user John Doe logged on at 8 o’clock am, the message shown in your application is: “Good morning John Doe”

When user John Doe logged on at 7 o’clock pm, the message shown in your application is: “Good evening John Doe”

make sure the entire time.hour range is covered, otherwise the message would simply say “John Doe”

Back to Top