Split Based On...
Description:
Split Based On... allows you to split your Flow and connect to specific Widgets based on user conditions. Use this Widget to deal with conditions like a user replying “YES” to a SMS, or pressing “1” on their keypad while on a call.
Note: Studio conditions are not case-sensitive and automatically trim leading and trailing spaces of the values.
Required Configuration:
Name |
Description |
Example |
Default |
Variable To Test |
The value (or expression) that is being tested. For example, if you want to branch on message body, the Input would be the variable you stored the message in. Select a predefined variable from the drop-down, or type a dynamic variable directly with curly braces: |
|
N/A |
Transitions:
You’ll define the event(s) that trigger transitions from this Widget. You get No Match for free once you set a branch.
Name |
Description |
Default |
Condition Matches |
Example: “YES” for when text matches “YES” |
NEW TRANSITION |
No Match |
Input does not match any of the user-defined conditions |
NO MATCH |
Conditions take the form: subject predicate [value] and can be set in the right-side panel.
subject:
the configuration parameter defined as Input.
predicate:
the operator to use -- equals, greater than, etc.
[value]:
the value you are comparing against. Constants, variables, and expressions are supported. Value can be null for certain conditions, such as “is blank” or “has any value”
In the following example, we have asked the user if they would like to receive reminders. Following the Send & Wait For Reply Widget is a Split Based On... Widget that evaluates the user’s response.
We have three conditions:
- The user enters Y (YES) when prompted
- The user enters N (NO) when prompted
- The user enters another value (NO MATCH)
Subject |
Predicate |
Value |
|
Equals |
Y |
|
Equals |
N |
The YES condition Transitions to a Send SMS Widget called REMINDERS_CONFIRM, while the NO and NO MATCH conditions Transition to a Send SMS Widget called REMINDERS_OPTOUT
Here are some usage examples of other conditions:
Subject |
Predicate |
Value |
|
Is After Date |
2017-09-04 |
|
Is Before Time | 16:35 |
|
Greater Than |
1000 |
|
Is Blank |
|
|
Matches Any Of | yes,yeah,yup |
|
Regex |
[1-5]
Note: Omit leading and trailing slashes. Matching is case-insensitive, and will only match if the provided regular expression matches the entire string. |
Need some help?
We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.