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

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

required-configuration-for-run-subflow page anchor

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.

FlowThe Studio Flow that contains the Subflow.My first flowN/A
RevisionThe 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 RevisionN/A


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

Optional Configuration for Run Subflow

optional-configuration-for-run-subflow page anchor

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

ParametersKey-value pairs that will be passed into the Subflow.Key: response, Value: {{trigger.message.Body}}N/A
Parse as JSON objectWhen passing a parameter, select this option when your parameter contains a JSON object. This allows the variable to be properly interpreted as a JSON object so you can reference its attributes in your flow.

When this box is checked, you can:
- Set or pass an existing JSON object and reference its members as variables
- Set a literal JSON string (using a Liquid reference to a JSON string, or a mixture of JSON and Liquid) and access it as an object

Note that by default, subflow parameters are parsed as strings.

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

CompletedThe Subflow reached the end of its widgets.
FailedThe Subflow could not be loaded or executed.

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

Example: Message Navigation

example-message-navigation page anchor

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

widget-configuration page anchor

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.

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

  • Learn all about Studio Subflows

We can't wait to see what you build!

Rate this page: