Menu

Run Subflow

Studio uses Widgets to represent various parts of Twilio's functionality 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 Run Subflow Widget allows you to invoke a Subflow from a parent Flow.

Subflow Widget

Required Configuration for Run Subflow

The Run Subflow Widget requires several pieces of information to function properly. The Studio Flow where the Subflow is located must be specified along with the revision.

Name Description Example Default
Flow The Studio Flow that contains the Subflow. My first flow N/A
Revision The revision of the Subflow to use at runtime. Select "Latest Draft" or "Latest Published" to have Studio dynamically select the correct revision at runtime. Latest Published Revision N/A

Multiple references to the same Subflow within a parent Flow must all target the same Flow Revision.

Optional Configuration for Run Subflow

The Run Subflow Widget also accepts parameters you can configure to be passed into the Subflow.

Name Description Example Default
Parameters Key-value pairs that will be passed into the Subflow. Key: response, Value: {{trigger.message.Body}} N/A

Run Subflow Transitions

These events trigger transitions from this Widget to another Widget in your Flow. For more information on working with Studio transitions, see this guide.

Name Description
Completed The Subflow reached the end of its widgets.
Failed The Subflow could not be loaded or executed.

Run Subflow Variables

Variables can be returned from the Subflow to the parent Flow using the Set Variables Widget. The variables stored when using a Set Variables Widget in a Subflow are not found in {{flow.variables.<key>}} after returning from the Subflow. Instead, these variables can be accessed from the Run Subflow Widget.

For example, if you use Set Variables in the Subflow to set foo=bar, that variable can be referenced in the parent as {{widgets.subflow_widget.foo}}.

Example: Message Navigation

This example shows the Run Subflow Widget being invoked to show a navigation message to the user. Since this navigation menu may be shown to the user more than once, having the procedure stored within a Subflow cuts down on possible duplication and provides oppotunity for use outside the current Flow.

When an incoming message triggers the Studio Flow, the Run Subflow Widget will run the Subflow that shows a navigation message. Once a response is received, the Set Variables Widget will store it and the Subflow will end execution. The main Flow continues and outputs the navigation selection back to the user. Notice that the response variable was stored within the Run Subflow Widget.

Twilio Studio Run Subflow Widget Example

Widget Configuration

In this case, the Run Subflow Widget is using the Subflow attached to its parent Flow rather than from another Flow.

Twilio Studio Run Subflow Widget Configuration Example

Learn More

Now that you know the basics of the Run Subflow Widget, why not learn more about Subflows within Studio?

We can't wait to see what you build!

Rate this page:

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 by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

Thank you for your feedback!

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!

Step 1

Get link

Get a free personal referral link here

Step 2

Give $10

Your user signs up and upgrade using link

Step 3

Get $10

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