# Workflow variable and action nodes

> Create, read, write, and route values owned by a workflow, and define Workflow Action entry points other controls can trigger.

These nodes are listed under **Workflow** in the Node Pool. Use them to keep values in a workflow, share them with other workflows or positions, and expose value routing.

## Choose a node

- [Workflow Variable](#workflow-variable): create a named value owned by the current workflow
- [Workflow Variable Read](#workflow-variable-read): read a variable from this workflow or another workflow
- [Workflow Variable Write](#workflow-variable-write): update a variable in this workflow or another workflow
- [Value Router](#value-router): expose workflow values as routable sources and destinations on the Router UIs
- [Workflow Action](#workflow-action): define an action entry point with typed options for other controls or workflows to trigger

## Workflow Variable

Create a named value owned by the current workflow.

### What you see in the editor

![The workflow Variable node card with Write and Read connections, the current value, and a Details section holding Name, Type, Persist Value, and Initial Value](https://bitfocus.io/api/docs-media/file/workflow-variable.png?prefix=docs-media)

- Set **Variable Key** and **Type**. Set **Initial Value** for a fresh node's starting value: this field disappears once **Persist Value** is on, since the last persisted value is used instead. The **Name** field shown in the card's **Details** section is a read-only echo of **Variable Key**, not a separate display name.
- Enable **Persist Value** only when the last value should return after the workflow reloads. The card shows **Current Value** while the workflow runs.

### Connections

| Kind | Label | What it provides |
| --- | --- | --- |
| Editor control | **Current Value** | Change the variable while testing or operating the workflow. |
| Workflow value | The variable | Available to Workflow Variable Read nodes and to supported position controls. |

### Example

Create a Boolean variable named `automation-enabled`, then read it from another part of the workflow to open or close a gate.

## Workflow Variable Read

Read a variable from this workflow or another workflow.

### What you see in the editor

![The Variable Read node card with Workflow and Variable dropdowns and a Read output](https://bitfocus.io/api/docs-media/file/variable-read.png?prefix=docs-media)

- Choose **Workflow**, then choose **Variable**. The current value appears on the card.

### Connections

| Kind | Label | What it provides |
| --- | --- | --- |
| Output | **Value** | The selected variable’s current value. |

### Example

Read a shared `show-mode` variable and connect **Value** to **Case Switch** to choose the active branch.

## Workflow Variable Write

Update a variable in this workflow or another workflow.

### What you see in the editor

![The Variable Write node card with Workflow and Variable dropdowns and a Write input](https://bitfocus.io/api/docs-media/file/variable-write.png?prefix=docs-media)

- Choose **Workflow**, then choose **Variable**.

### Connections

| Kind | Label | What it provides |
| --- | --- | --- |
| Input | **Write** | Writes a new value to the selected variable when this input changes. |

### Example

Connect a result from **Event Switch** to **Write** so named events update a shared operating-mode variable.

## Value Router

Expose sources and destinations from this workflow on the Router UIs in the system, so the resulting routes can drive custom routing functionality.

### What you see in the editor

![The Value Router node card with Src 3, Dst 3 and Lvls 1, three source inputs labelled A Src 1 to A Src 3 on the left, and three destination outputs on the right showing the current routes Src 3 to Dst 1A, Src 1 to Dst 2A and Src 2 to Dst 3A](https://bitfocus.io/api/docs-media/file/value-router.png?prefix=docs-media)

- Set **Src** and **Dst** to the number of source and destination ports to generate: each is a count from 2 to 200 (default 10), not a list of named entries. Set **Lvls** (1–10, default 1) to add that many sub-ports to every Src and Dst port, labeled **A**, **B**, **C**, and so on.
- The card lists one row per port: an input handle labeled **A Src \*N** *on the left (then **B Src \*N**\*, **C Src \*N**\*, and so on for further levels) and an output handle labeled \*\*Dst \*N*A **(then *\*Dst \*N*B**, and so on) on the right. The level letter is shown even when **Lvls** is 1.
- Each destination row also shows which source is currently routed to it, such as **Src 3 → Dst 1A**.
- The generated ports appear in Buttons routing views (for example **Routing → Ports**) under a Connection entry named after this workflow, with each port's User Label following the same **Src \*N**\* / **Dst \*N**\* pattern: confirmed live, no naming controls exist for them beyond the port count.
- Use this node when a workflow value must participate in routing. Use normal workflow connections when the value stays inside one workflow.

### Connections

| Kind | Label | What it provides |
| --- | --- | --- |
| Inputs | **Src \*N**\* handles (one per source port and level) | A workflow value to publish as a routable source. |
| Outputs | **Dst \*N**\* handles (one per destination port and level) | The value currently routed to that destination, delivered into the workflow. |

### Example

Feed a workflow-generated value into a **Src** handle to publish it as a routable source, then route it to a **Dst** handle elsewhere (on this workflow or another) to deliver it as an output. Build the actual route from the Routing views, not from this node.

## Workflow Action

Define an action entry point with typed options for other controls or workflows to trigger.

### What you see in the editor

![The Workflow Action node card titled Set Mode, with a Mode option output handle plus States, Timestamp, and Event outputs](https://bitfocus.io/api/docs-media/file/workflow-action.png?prefix=docs-media)

The card only shows the options you've already added, as output handles: **Title**, **Description**, and **Add Option** aren't on the card. Select the node to open its **Configuration** panel, which is where this node is actually built:

![The Workflow Action node's Configuration panel, showing Title set to "Set Mode", Description, and an Options list with one Dropdown option named "Mode" and its two configured choices](https://bitfocus.io/api/docs-media/file/workflow-action-inspector.png?prefix=docs-media)

- Set an optional **Title** to identify this action wherever it can be triggered from, and a **Description** shown alongside it there.
- Use **Add Option** to define a typed input the caller fills in: **Text**, **Number**, **True/False**, **Dropdown**, or **Multi Dropdown**. Each option gets a **Label** and a **Default** value; **Dropdown** and **Multi Dropdown** also need a list of choices, each with an **ID** and a **Value**.
- Every configured option appears as its own output handle on the card, carrying the value supplied the last time the action ran. **States** outputs every option's value together as one object, **Timestamp** outputs when it last ran, and **Event** fires each time it runs. All outputs are empty until the action has run at least once.
- Trigger this node from outside its own workflow using the **Trigger Workflow Action** action, available on button and other control actions and from other workflows' **Internal Action** node: choose the **Workflow**, then this node by its **Title**, then fill in the same options configured here.

### Connections

| Kind | Label | What it provides |
| --- | --- | --- |
| Outputs | One per configured option, named as configured | That option's value from the last time the action ran. |
| Output | **States** | Every option's value together, as one object. |
| Output | **Timestamp** | When the action last ran. |
| Output event | **Event** | Fires each time the action runs, carrying the same values as its payload. |

### Example

Add a Workflow Action with a **Dropdown** option named **Mode**, then trigger it from a button's **Trigger Workflow Action** action to switch the workflow's behavior from outside it.

To trigger Workflow Actions from an encoder's **Left** and **Right** handlers, see [Control a workflow with an encoder](/docs/buttons/v1.10/workflows/control-a-workflow-with-an-encoder).
