> ## Documentation Index
> Fetch the complete documentation index at: https://botpress-charmenta-pr-705.mintlify.site/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

<Steps titleSize="h3">
  <Step title="Setup your input variable">
    1. In your sub-Workflow (the one you want to pass the variable to), [create a new Workflow variable](/studio/concepts/variables/overview/#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.
    </Note>

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

    <Frame>
      <img alt="Toggle input variable" className="block dark:hidden" src="https://mintcdn.com/botpress-charmenta-pr-705/b7UTf6Z3o4Ynfrz3/studio/concepts/variables/assets/toggle-input-variable.png?fit=max&auto=format&n=b7UTf6Z3o4Ynfrz3&q=85&s=942afdb98f03055ba183e10c447a514f" width="1426" height="578" data-path="studio/concepts/variables/assets/toggle-input-variable.png" />

      <img alt="Toggle input variable" className="hidden dark:block" src="https://mintcdn.com/botpress-charmenta-pr-705/b7UTf6Z3o4Ynfrz3/studio/concepts/variables/assets/toggle-input-variable-dark.png?fit=max&auto=format&n=b7UTf6Z3o4Ynfrz3&q=85&s=8e7be868db89b5fb27cf23a6a87c2ffd" width="1426" height="578" data-path="studio/concepts/variables/assets/toggle-input-variable-dark.png" />
    </Frame>

    This tells the parent Workflow that your sub-Workflow is expecting some input.
  </Step>

  <Step title="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:

    <Frame>
      <img alt="Input variable field" className="block dark:hidden" src="https://mintcdn.com/botpress-charmenta-pr-705/b7UTf6Z3o4Ynfrz3/studio/concepts/variables/assets/input-var-field.png?fit=max&auto=format&n=b7UTf6Z3o4Ynfrz3&q=85&s=499420aa141b14a72df9a3e961270747" width="1346" height="660" data-path="studio/concepts/variables/assets/input-var-field.png" />

      <img alt="Input variable field" className="hidden dark:block" src="https://mintcdn.com/botpress-charmenta-pr-705/b7UTf6Z3o4Ynfrz3/studio/concepts/variables/assets/input-var-field-dark.png?fit=max&auto=format&n=b7UTf6Z3o4Ynfrz3&q=85&s=991efa8b140d6d178b1fc6ce2e5f5363" width="1346" height="660" data-path="studio/concepts/variables/assets/input-var-field-dark.png" />
    </Frame>

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

    <Check>
      Now, whatever value you pass from your parent Workflow will be available in your sub-Workflow as a Workflow variable.
    </Check>
  </Step>
</Steps>

## From a sub-Workflow to a parent Workflow

<Steps titleSize="h3">
  <Step title="Pass your output variable">
    1. Select your sub-Workflow's [Exit Node](/studio/concepts/nodes/introduction/#exit-node).
    2. Under **Toggle Variables**, select the variable you want to pass:

    <Frame>
      <img alt="Toggle output variable" className="block dark:hidden" src="https://mintcdn.com/botpress-charmenta-pr-705/b7UTf6Z3o4Ynfrz3/studio/concepts/variables/assets/toggle-output-variable.png?fit=max&auto=format&n=b7UTf6Z3o4Ynfrz3&q=85&s=2b4a5ccca2f94f5510d60b4037ce4111" width="1312" height="262" data-path="studio/concepts/variables/assets/toggle-output-variable.png" />

      <img alt="Toggle output variable" className="hidden dark:block" src="https://mintcdn.com/botpress-charmenta-pr-705/b7UTf6Z3o4Ynfrz3/studio/concepts/variables/assets/toggle-output-variable-dark.png?fit=max&auto=format&n=b7UTf6Z3o4Ynfrz3&q=85&s=0761639231674f4d9ba26895631d2255" width="1312" height="262" data-path="studio/concepts/variables/assets/toggle-output-variable-dark.png" />
    </Frame>

    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.
    </Note>
  </Step>

  <Step title="Configure the sub-Workflow Card">
    1. In the parent Workflow, select the Card that transitions to the sub-Workflow:

    <Frame>
      <img alt="Workflow Card" className="block dark:hidden" src="https://mintcdn.com/botpress-charmenta-pr-705/b7UTf6Z3o4Ynfrz3/studio/concepts/variables/assets/workflow-card.png?fit=max&auto=format&n=b7UTf6Z3o4Ynfrz3&q=85&s=99351dcdbe0e7590cabb0b3233e28788" width="1312" height="586" data-path="studio/concepts/variables/assets/workflow-card.png" />

      <img alt="Workflow Card" className="hidden dark:block" src="https://mintcdn.com/botpress-charmenta-pr-705/b7UTf6Z3o4Ynfrz3/studio/concepts/variables/assets/workflow-card-dark.png?fit=max&auto=format&n=b7UTf6Z3o4Ynfrz3&q=85&s=b5bc627617006a39ec4ba3cd6584815e" width="1312" height="586" data-path="studio/concepts/variables/assets/workflow-card-dark.png" />
    </Frame>

    2. Make sure the **Exit Nodes** option is selected.
  </Step>

  <Step title="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>`

    <Frame>
      <img alt="Read output variable" className="block dark:hidden" src="https://mintcdn.com/botpress-charmenta-pr-705/b7UTf6Z3o4Ynfrz3/studio/concepts/variables/assets/read-variable.png?fit=max&auto=format&n=b7UTf6Z3o4Ynfrz3&q=85&s=9fa68e100479b5cd3ab687266dd92ed9" width="1288" height="520" data-path="studio/concepts/variables/assets/read-variable.png" />

      <img alt="Read output variable" className="hidden dark:block" src="https://mintcdn.com/botpress-charmenta-pr-705/b7UTf6Z3o4Ynfrz3/studio/concepts/variables/assets/read-variable-dark.png?fit=max&auto=format&n=b7UTf6Z3o4Ynfrz3&q=85&s=c74f14836b16f79602c43aff21953e0f" width="1288" height="520" data-path="studio/concepts/variables/assets/read-variable-dark.png" />
    </Frame>

    <Check>
      Your parent Workflow now has access to its sub-Workflow's variable.
    </Check>
  </Step>
</Steps>
