# Run Subflow widget

Studio widgets represent various parts of Twilio's functionality that you can combine in your Studio Flow to build out robust applications that don't require you to do any coding.

> \[!NOTE]
>
> New to Twilio Studio? Check out our [Getting Started guide](/docs/studio/user-guide/get-started).

The Run Subflow widget allows you to invoke a [Subflow](/docs/studio/subflows) from a parent Flow.

![Subflow widget showing flow SID and revision with completed and failed status indicators.](https://docs-resources.prod.twilio.com/f13c2ee945f10ddac683816835a1e172b0dd668fcdf516faaf091fde6b89d7da.png)

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

> \[!WARNING]
>
> 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     |
| Parse as JSON object | When 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. <br /><br /> When this box is checked, you can: <br /> - Set or pass an existing JSON object and reference its members as variables <br /> - 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 <br /><br /> Note that by default, subflow parameters are parsed as strings. | N/A                                              | 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](/docs/studio/user-guide/get-started#define-widget-transitions).

| 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](/docs/studio/widget-library/set-variables). 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 opportunity 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 flow showing trigger, run subflow, send message, and set variables widgets.](https://docs-resources.prod.twilio.com/67978d8f0e3ee2d0881a4014580b3bf47b9fdfa0c1cee97224758afbeb1254f3.png)

### 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 with fields for widget name, flow, and revision.](https://docs-resources.prod.twilio.com/58830a06de36debc87d9e6e7f32cf76a47c3b3092c798384d4bd6be73fded49e.png)

## Learn More

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

* Learn all about Studio **[Subflows](/docs/studio/subflows)**

Let's build something amazing.
