Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Split Based On... Widget


Studio uses Widgets to represent various parts of Twilio's API that can then be stitched together in your Studio Flow to build out robust applications that require no coding on your part.

(information)

Info

New to Twilio Studio? Check out our Getting Started guide!

The Split Based On... Widget 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.

Reminders Split Based On Widget.

Required Configuration for Split Based On

required-configuration-for-split-based-on page anchor

The Split Based On... Widget requires a Variable to Test to function properly. The Variable to Test is the value that is tested to determine what happens next in your Flow when a certain condition is met.

NameDescriptionExampleDefault
Variable to TestThe 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: {{widgets.http_1.parsed.foo}}{{widgets.send_msg.incoming.Body}}None

Split Based On... Transitions

split-based-on-transitions page anchor

You can add Transitions to the Split Based On... Widget that trigger another Widget in your Flow. Transitions can be triggered by a variety of conditions that you can configure. For more information on working with Studio transitions, see this guide.

NameDescription
Condition MatchesExample: "YES" for when text matches "YES"
No MatchInput does not match any of the user-defined conditions

Conditions take the form: Subject, Predicate, [value] and can be set in the Widget configuration menu in the right-side panel on the Canvas.

  • subject: The configuration parameter defined as Input.
  • predicate: The operator to use. For example: equals, greater than, less than and more.
  • [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".
(warning)

Warning

In order to save the Conditions you set for the Split Based On... Widget, you must click the red Save button at the bottom of the Widget. Conditions are not auto-saved, and will not persist unless saved.


Predicates are operators used by the Split Based On... Widget to evaluate the given value against a comparison value and determine what transition should be used.

(information)

Info

Studio conditions are not case-sensitive and automatically trim leading and trailing whitespace characters.

Equal To

The values are equivalent.

Not Equal To

The values are not equivalent.

Matches Any Of

Value is equivalent to any of the values in the given list.

Does Not Match Any Of

Value is not equivalent to any of the values in the given list.

Is Blank

Value contains only white-space characters or is blank.

Is Not Blank

Value contains characters that are not white-space characters.

Regex

Value matches the regex pattern specified. For more information on regular expressions and how to use them, view this cheatsheet(link takes you to an external page).

(warning)

Warning

Omit leading and trailing slashes with the Regex Predicate. Matching is case insensitive, and will only match if the provided regular expression matches the entire string.

Contains

Value contains the value given. For example, "aab" contains "aa" and "A".

Does Not Contain

Value does not contain the value given.

Starts With

Value starts with the given value. For example, " Hoot" starts with "hoo".

Does Not Start With

Value does not start with the value given.

Less Than

Value is less than the number provided. Operator does not perform comparisons on letters.

Greater Than

Value is greater than the number provided. Operator does not perform comparisons on letters.

Is Before Time

Value is before the time provided. Times must be in 24-hour notation (HH:MM) where single digit values are written with a leading 0.

Is After Time

Value is after the time provided. Times must be in 24-hour notation (HH:MM) where single digit values are written with a leading 0.

Is Before Date

Value is before the date provided. Dates must be in the format YYYY-MM-DD where single digit values are written with a leading 0.

Is After Date

Value is after the date provided. Dates must be in the format YYYY-MM-DD where single digit values are written with a leading 0.


Here are some usage examples for predicates.

SubjectSubject ValuePredicateValueOutput
{{flow.data.appointment_date}}2019-08-12Is After Date2017-09-04True
{{flow.data.appointment_time}}17:00Is Before Time16:35False
{{flow.data.reward_points}}900Greater Than1000False
{{flow.data.first_name}}TwilioIs BlankN/AFalse
{{trigger.message.Body}}YESMatches Any Ofyes,yeah,yupTrue
{{flow.data.survey_result}}6Regex[1-5]False

Example: an SMS Reminders Flow

example-an-sms-reminders-flow page anchor

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:

  1. The user enters Y (YES) when prompted.
  2. The user enters N (NO) when prompted.
  3. The user enters another value that is not Y or N (NO MATCH) .
SubjectPredicateValueTransition
{{widgets.reminders_response.inbound.Body}}EqualsYREMINDERS_CONFIRM
{{widgets.reminders_response.inbound.Body}}EqualsNREMINDERS_OPTOUT
{{widgets.reminders_response.inbound.Body}}Equals123 (NO MATCH)REMINDERS_OPTOUT

The following screenshot outlines the example SMS Reminders Flow. The YES condition Transitions to a Send SMS Widget called REMINDERS_CONFIRM, while the NO and NO CONDITION MATCHES conditions Transition to a Send SMS Widget called REMINDERS_OPTOUT.

Reminders Split Example Flow.

Now that you know the basics of the Split Based On... Widget, you may want to take a look at the Transitions documentation to learn more about how Transitions help power the Split Based On... Widget.

Happy building!


Rate this page: