Expression Builder
Use the Expression Builder to build string, mathematical, logical, and other expressions.
This page is organized as follows.
Opening the Expression Builder
Fields with a pencil icon inside have access to the Expression Builder.
Click the pencil to open the Expression Builder.
Using the Expression Builder
1. Select a function
Functions are organized by type as follows.
-
String
-
Mathematical
-
Logical
-
Premium
-
JSON
-
Other
Type the function name to filter the list of functions to the name you type.
2. Fill in the function fields
The fields to the right of the function depend on the function selected. Fill in the fields as appropriate.
To enter a variable, type two open curly brackets {{ and select from the list.
If you need more screen real estate, click the edit button to the right of the field.
To evaluate an expression, press the arrow to the right of the expression. If the expression includes variables, you are prompted to enter a temporary value for each variable.
3. Build complex expressions
To use an earlier expression as input, type two open curly brackets {{ and select from the expressions presented.
The selected expression is the last to be evaluated.
Renaming Expressions
As you build complex expressions, you may want to rename each expression to something meaningful.
Click the Expression field to rename the expression. The expression name must begin with the characters expr. The name cannot contain spaces and other special characters. Underscore characters are allowed.
When you rename the expression, Studio automatically renames all the places that call the expression.
Copy Expression List
Copy the contents of the Expression Builder and paste in another instance. For example, you may want to copy expressions from one variable value to another.
-
Complete at least one expression in the Expression Builder.
The Expression Builder copy expression list button is now visible.
-
Click the Expression Builder copy expression list button.
-
The Expression Builder paste/replace expression list button is visible since an expression is ready to paste.
-
Open another instance of the Expression Builder.
-
Click the Expression Builder paste/replace expression list button.
The copied expression is pasted into this instance of the Expression Builder and replaces all preexisting expressions in the instance.
An undo button displays briefly following the paste/replace action.
Clear all Content
Return to the place in the user interface where you opened the expression builder. Hover over the form field. If an expression exists for this field, the "x" symbol displays. Click the "x" symbol to clear all content from the expression.
Expression Builder Functions
String Operations
String function operations work only with English language characters.
Function |
Description |
||||||||
---|---|---|---|---|---|---|---|---|---|
Text Input |
Enter a text string. |
||||||||
Get String Length | Returns the length of the string in characters. | ||||||||
Convert to Uppercase |
Converts all alphabetic characters to uppercase. Other characters like punctuation, numeric, and umlaut-a (ä) do not change. |
||||||||
Convert to Lowercase |
Converts all alphabetic characters to lowercase. Other characters like punctuation, numeric, and umlaut-a (ä) do not change. |
||||||||
Trim String |
Strips white space from the beginning and end of a string. By default, Studio strips tabs, new lines, carriage returns, null bytes, and vertical tabs. You can customize this list. |
||||||||
Trim String from End |
Strips white space from the end of a string. |
||||||||
Trim String from Start |
Strips white space from the start of a string. |
||||||||
Get sub-string |
Returns the portion of value specified by the index and length parameters.
|
||||||||
Replace String |
Replaces all occurrences of the search string with a new string. Select if the search is to be case sensitive. |
||||||||
Search String |
Returns the position of the search string within the subject string. Select if the search is to be case sensitive. |
||||||||
Extract Email from String |
Extracts the first email address found in the string. |
||||||||
Extract Number (fixed) from String |
Extracts the first sequence of digits found in the string of a given fixed length. The length can be entered as an expression. |
||||||||
Extract Number (min-max) from String |
Extracts the first sequence of digits found in the string with at least the minimum number of digits and no more than the maximum number of digits. The lengths can be entered as expressions. |
||||||||
Extract Letter (fixed) from String |
Extracts the first sequence of alphabetic characters found in the string of a given fixed length. The length can be entered as an expression. |
||||||||
Extract Letter (min-max) from String |
Extracts the first sequence of alphabetic characters found in the string with at least the minimum number of characters and no more than the maximum number of characters. The lengths can be entered as expressions. |
||||||||
Custom Regex |
Extracts the first match or first matched group according to the regular expression. Access regular expression flags by clicking /im. |
Logical Operations
Where the input type is boolean, enter values as follows.
Boolean |
Numeric |
String |
---|---|---|
True | 1 |
Any string other than those translating to false. |
False |
0 |
"false" (case insensitive) Empty string |
Premium Operations
Use the Get Number function to detect the type of phone used to traverse the call flow. You may want to run Get Number on logged date.
JavaScript Functions
Select from content items of type JavaScript in the Studio account. See Functions.
JavaScript functions returning a boolean value, return true or false.
JSON
Select from the following nodes in the call flow.
Node |
Response data from the node in JSON format |
---|---|
Multiple transcriptions from the Google ASR. See Accessing Multiple Transcriptions. |
|
Up to 50 rows of data from the datastore. |
|
For custom forms, if the return value matches more than one grammar, as is the case in the sound of names John and Jon, Studio captures all matches in the confusables array. See Custom Form Confusables. |
|
Integration node responses. |
Response data from the node in JSON format is only available in the same task as the node. It is not available in linked tasks. See Link Task.
Date and Time Formats
The default date-time format is Y-m-d H:i:s.
All dates and times are at least two digits. For example, January 1st would be 01-01.
Special characters may also be added, but may affect text-to-speech.
Component |
Format |
Example |
Description |
---|---|---|---|
Default | Y-m-d H:i:s | 2018-01-24 15:34:56 | |
Year | Y | 2018 | Four digit year |
y | 18 | Two digit year | |
Month |
M |
Jan |
Abbreviated name of the month |
|
m |
01 |
Abbreviated month number |
Day |
D |
Wed |
Abbreviated day of the week |
|
d |
01 |
Day of the month |
|
S |
th |
Ordinal number suffix |
Hour |
H |
15 |
Hour in 24-hour notation |
|
h |
03 |
Hour in 12-hour notation |
Minute |
i |
34 |
Time in minutes |
Second |
s |
55 |
Time in seconds |
AM or PM |
A |
PM |
AM or PM in capitals |
|
a |
pm |
AM or PM in lower case |
Time Zone |
P |
-05:00 |
Time zone based on account settings |
Epoch Time |
U |
1516826095 |
Seconds since midnight Jan 1 1970 UTC |
Punctuation |
m/d/y |
01/26/18 |
American date format with slashes |
|
M ds, Y |
Jan 24th, 2018 |
American date format with ordinal notation |
|
h:i A |
03:34 PM |
Hours and minutes in 12 hour notation |