> ## Documentation Index
> Fetch the complete documentation index at: https://botpress.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Pass variables between Workflows

You can pass variables between Workflows. This is useful if you want to use a previously created variable within the scope of a single Workflow. For example:

* You want to collect user information in one Workflow, then validate it in a sub-Workflow.
* You have a Workflow that stores items in a virtual shopping cart, and you want to process payment for those items in a sub-Workflow.
* You have some condition in one Workflow, and you want a sub-Workflow to behave differently based on that condition.

## From a parent Workflow to a sub-Workflow

### 1. Setup your input variable

1. In your sub-Workflow (the one you want to pass the variable to), [create a new Workflow variable](https://botpress.com/docs/studio/concepts/variables/overview.md#create-a-variable).

> [!NOTE]
>
> You can pass any kind of variable from your parent Workflow, but your sub-Workflow needs to treat it as a Workflow variable.

2. Select your sub-Workflow's [Entry Node](https://botpress.com/docs/studio/concepts/nodes/introduction.md#entry-node).
3. Under **Toggle Variables**, select the variable you just created:

![Toggle input variable](https://mintcdn.com/botpress/RWKQxTh1qL1DGc-R/studio/concepts/variables/assets/toggle-input-variable.png?fit=max\&auto=format\&n=RWKQxTh1qL1DGc-R\&q=85\&s=ec6ad0d1b53e529f0d1540e533ae6268)

This tells the parent Workflow that your sub-Workflow is expecting some input.

### 2. Pass the variable to the sub-Workflow

In your parent Workflow, select the Card that transitions to the sub-Workflow. It should display the input variable you just created:

![Input variable field](https://mintcdn.com/botpress/Lpe_dNeJOVvCwnlo/studio/concepts/variables/assets/input-var-field.png?fit=max\&auto=format\&n=Lpe_dNeJOVvCwnlo\&q=85\&s=09057f2f5850d3915c0bfa1d0db8f35b)

You can manually enter a value to pass to the sub-Workflow, or use a previously created variable from your parent Workflow.

> [!TIP]
>
> Now, whatever value you pass from your parent Workflow will be available in your sub-Workflow as a Workflow variable.

## From a sub-Workflow to a parent Workflow

### 1. Pass your output variable

1. Select your sub-Workflow's [Exit Node](https://botpress.com/docs/studio/concepts/nodes/introduction.md#exit-node).
2. Under **Toggle Variables**, select the variable you want to pass:

![Toggle output variable](https://mintcdn.com/botpress/RWKQxTh1qL1DGc-R/studio/concepts/variables/assets/toggle-output-variable.png?fit=max\&auto=format\&n=RWKQxTh1qL1DGc-R\&q=85\&s=c996f15699c51c0c2403683ce1388525)

This tells the parent Workflow to expect some output from the sub-Workflow.

> [!NOTE]
>
> You can only pass Workflow variables from a sub-Workflow to a parent Workflow.

### 2. Configure the sub-Workflow Card

1. In the parent Workflow, select the Card that transitions to the sub-Workflow:

![Workflow Card](https://mintcdn.com/botpress/RWKQxTh1qL1DGc-R/studio/concepts/variables/assets/workflow-card.png?fit=max\&auto=format\&n=RWKQxTh1qL1DGc-R\&q=85\&s=cad37d7ac7c2ade9890a0787ac2bec87)

2. Make sure the **Exit Nodes** option is selected.

### 3. Read the output variable in the parent Workflow

To access the sub-Workflow's output variable from within the parent Workflow, read:

`workflow.<cardName>.<variableName>`

![Read output variable](https://mintcdn.com/botpress/RWKQxTh1qL1DGc-R/studio/concepts/variables/assets/read-variable.png?fit=max\&auto=format\&n=RWKQxTh1qL1DGc-R\&q=85\&s=951d3562295eb382fe48f02506ac9380)

> [!TIP]
>
> Your parent Workflow now has access to its sub-Workflow's variable.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.