> For the complete documentation index, see [llms.txt](https://docs.poweredbybackstage.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.poweredbybackstage.com/fundamentals/local-variables.md).

# Local Variables

Local Variables are variables which are local to the specific guest. Local Variables can be set using the Flow Controller, and can be used in other Flows to control behavior.

### Setting a Local Variable

To set a local variable, use the `Set Local Variable` listener.

![Set Local Variable Listener Node](https://2635135911-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9NyC60xfSabdCmQW0heP%2Fuploads%2FgV5EEocRB3MsMMQ1twSu%2Fimage.png?alt=media\&token=56c6bff5-1288-400a-9c04-a0f9a336ed5c)

The listener takes a `Key` and a `Value`. The key is the name of the variable, and the value is the new value you want to set that variable to.

### Reading a Local Variable

To read a local variable, and use it in a Flow, use the `Read Local Variable` value Node.

![Read Local Variable Value Node](https://2635135911-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9NyC60xfSabdCmQW0heP%2Fuploads%2FLevsWxiRnpx0Vx0WY1cw%2Fimage.png?alt=media\&token=e8e156e7-ab57-48c1-8769-7046dee21111)

The value node takes a `Key`. The key is the name of the variable you want to get the current value of. The `Value` output will send the current value of the Local Variable to the next node in the Flow.

### Example Usage

Say we want to keep track of whether the guest has a chat panel open. We can use a Local Variable to keep track of the local state of that panel.

![Toggle a panel using Local Variables](https://2635135911-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9NyC60xfSabdCmQW0heP%2Fuploads%2FO1orNwkXxjuyCNkG5dc3%2Fchat-toggle_AdobeExpress.gif?alt=media\&token=a8c6bcf6-df37-4caa-951a-1ccf2ee9c706)

{% hint style="info" %}
For a detailed look at Flows, check out the [Flows Fundamentals](/fundamentals/flows.md) page.
{% endhint %}

![Example Flow](https://2635135911-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9NyC60xfSabdCmQW0heP%2Fuploads%2FYc7QxDnhM5UEA5jLKcQz%2Fimage.png?alt=media\&token=31d4c746-fce5-497e-a3cf-0b60b915bbf6)

{% hint style="info" %}
This is just an example.

To create this yourself, you'll need to make the animation states on a Stacked module.
{% endhint %}

Here, we build a Flow from the `Button:on-click` Broadcaster. When this button is clicked, we pressurize an `Equals` Node.&#x20;

We pass the current value of `chatPanelOpen` into this Equals, and check if it's set to `TRUE`.

If the Local Variable is `TRUE` (meaning the panel is currently open), we set the animation state of the panel to `closed`, and set the Local Variable to `FALSE`.&#x20;

If the Local Variable is not `TRUE` (meaning the panel is currently closed), we set the animation state of the panel to `open`, and set the Local Variable to `TRUE`.
