Keywords

Keywords, or commands, are part of the syntax of statements in the Snippet language. They're pre-defined terms that are reserved for specific uses in scripts. The compiler recognizes the keyword and performs the behavior associated with it. For example, when the compiler sees the ASSIGN keyword, it creates a new variable with the name and value specified after the keyword. For example: ASSIGN varName = 1

Because keywords are reserved terms, these words cannot be used as identifiers for objects or variables in your scripts.

Many of the keywords also have Studio actionsClosed Performs a process within a Studio script, such as collecting customer data, playing a message or music, or routing a contact to an agent. with the same name. For example, there is an IF keyword and an IF action. Both accomplish the same behavior in your script. You can use Snippet actions with custom code to reduce the number of actions in your scripts.

Keywords in Snippet

Snippet supports the following keywords. Each keyword has a specific use. There are several categories for the kind of behavior the keywords perform. Each keyword is described in detail in the sections that follow.

Declaration Keywords

These keywords allow you to declare, or create, new variables, objects, and functions.

Selection Keywords

These keywords allow you to have the script select a statement to perform based on the conditions you specify. You can use them to control the linear flow of what happens in your script.

  • IF: This statement selects a statement to execute based on the value of a Boolean expression.
  • SELECT: This statement executes the first in a series of CASE statements that evaluates to true.
  • SWITCH: This statement compares the value of a variable to the defined CASE statements. It executes the matching CASE.

The following keywords are never used on their own. They're always used with a selection keyword. 

  • ELSE: This statement defines the action the script takes if the Boolean expression evaluates to false. Used with IF.
  • CASE: This statement defines one of a set of possible statements to be executed. Used with SWITCH or SELECT.
  • DEFAULT: This statement defines the statement that's executed if none of the other cases can be executed. Used with SWITCH or SELECT.

Looping Keywords

Looping keywords allow you to execute a statement or series of statements repeatedly until the specified ending condition is met.

The following keyword is never used on its own. It's an optional part of a looping statement code block: 

BREAK: This statement terminates a loop statement.

Other Keywords

These keywords have very specific applications within Studio scripts:

Keyword Syntax

A keyword must appear as the first word or command on the line. It's then followed by other words or code that define what the keyword does and how it does it. For example, the ASSIGN keyword, which creates a new variable and assigns a value to it, must be followed by the name of the new variable and the value you want it to have: 

ASSIGN var1 = "my value"

Keywords are not case sensitive. For example: FOREACH is the same as foreach to the compiler.

Some keywords required embedded code to work. See the online help page for the keyword you're using for information about these requirements.

Keywords in the Snippet Editor

The Snippet editor window in the Snippet action has two tabs. Both tabs allow you to create the same kinds of code. You can switch back and forth between the tabs and edit your code in either place. The tabs are: 

  • The Text View tab. This is a free-form text field where you can type your code out manually.
  • The Tree View tab. This is a graphical interface you can use to build your code. This tab has a list you can select keywords from to add statements to the snippet.