メニュー

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.

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...

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.

名前 概要 初期値
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: {{widgets.http_1.parsed.foo}} {{widgets.send_msg.incoming.Body}} なし

Split Based On... Transitions

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.

名前 概要
Condition Matches Example: "YES" for when text matches "YES"
noMatch 入力がユーザー定義の条件のどれとも一致しなかった

Condition Structure

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".

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.

Predicate Definitions

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.

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.

Omit leading and trailing slashes with the Regex Predicate.

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.

未満

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.

Predicate Examples

Here are some usage examples for predicates.

Subject (主語) Subject Value Predicate (述語) 出力
{{flow.data.appointment_date}} 2019-08-12 Is After Date 2017-09-04 true
{{flow.data.appointment_time}} 17:00 Is Before Time 16:35 false
{{flow.data.reward_points}} 900 Greater Than 1000 false
{{flow.data.first_name}} Twilio Is Blank 該当なし false
{{trigger.message.Body}} YES Matches Any Of yes,yeah,yup true
{{flow.data.survey_result}} 6 Regex [1-5] false

Example: an SMS Reminders Flow

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.

3つの条件があります:

  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).
Subject (主語) Predicate (述語) Transition
{{widgets.reminders_response.inbound.Body}} Equals Y REMINDERS_CONFIRM
{{widgets.reminders_response.inbound.Body}} Equals N REMINDERS_OPTOUT
{{widgets.reminders_response.inbound.Body}} Equals 123 (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 CONDITON 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.

楽しいプログラミングを!

ページを評価:

ヘルプが必要ですか?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

フィードバックくださりありがとうございます!

Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

Sending your feedback...
🎉 Thank you for your feedback!
Something went wrong. Please try again.

Thanks for your feedback!

Refer us and get $10 in 3 simple steps!

ステップ1

Get link

Get a free personal referral link here

ステップ2:

Give $10

Your user signs up and upgrade using link

ステップ3

Get $10

1,250 free SMSes
OR 1,000 free voice mins
OR 12,000 chats
OR more