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

# Set local variables step

> Set, update or clear variables at a point in your flow with a Set local variables step: names, types, values, Keep in sync, and what happens on a call.

A Set local variables step sets values that later steps can use, then moves straight on. The caller doesn't hear anything. Use it for flags, counters, defaults and values worked out from other variables.

## When to use it

* To set a flag that a [Router step](https://docs.tryhamsa.com/agents/flow/steps/router.md) checks later, such as `verified` set to `True` after a successful lookup.
* To give a variable a default before a step that may or may not fill it.
* To build a value from others, such as a full name from a first and last name.
* To clear a value before the caller tries again.

Every step type can also set local variables in its own **Variables** section, when the call reaches it. Use a separate Set local variables step when the values belong to a point in the flow rather than to a step.

## Add a Set local variables step

**1. Add the step**

On the canvas, click **Add node** and choose **Set local variables** ("Set local variables for use in subsequent nodes").

**2. Add variables**

Click **Add variable** for each value, and fill in its **Name**, **Type** and **Value**.

**3. Connect Auto-advance**

Connect the step's **Auto-advance** transition to the next step.

The panel explains: "This node sets local variables and automatically advances to the next node. Variables are available to all downstream nodes."

![A Set local variables step with one variable, verified, of type Boolean set to True](https://mintcdn.com/hamsa-452fa79a/Rl78D_qJIpinmg19/images/agents/flow/steps/set-variables-step-light.webp?fit=max\&auto=format\&n=Rl78D_qJIpinmg19\&q=85\&s=b96f25ead56652a76707ca3a4c2cb76c)

## Fields

Each variable has:

| Field | What it does | Rules |
| - | - | - |
| **Name** | The variable's name, used as `{{name}}` in later steps. | snake\_case ("Use snake\_case format"), up to 50 characters, unique within the step ("Duplicate variable name"). |
| **Type** | **String**, **Number**, **Boolean**, **Array (JSON)** or **Object (JSON)**. | Default **String**. |
| **Value** | The value to set. A **Boolean** is set with a **True** / **False** switch. | Can be empty: "Leave empty to clear the variable's value". |
| **Description** | A note about what the variable is for. | Optional. |
| **Keep in sync** | Off: "Set once, as the call reaches this step." On: "Worked out again from the other variables each time it's used." | Off. Only useful for values that contain `{{...}}`. |

Values can include other variables and [Jinja](https://docs.tryhamsa.com/agents/variables/jinja.md), for example `{{first_name}} {{last_name}}`. This works for **String** values. In **Array (JSON)** and **Object (JSON)** values, `{{...}}` isn't filled in: the JSON is stored as written.

### Keep in sync

With **Keep in sync** off, the value is worked out once, when the call reaches the step. If `first_name` changes later, `full_name` keeps the old value.

With it on, the variable stays a formula: every time a step reads it, it's worked out again from the current values. A step whose transitions depend on it (such as **When a live variable matches**) also reacts when its inputs change. The step shows "In sync" on the variable.

* If the value has no `{{...}}`, there's nothing to keep in sync, and the panel says so.
* If the variable reads itself, directly or through other variables, the panel warns that "the call sets it once instead", and it's set once.
* If a later step sets the same variable, the new value replaces the formula.

## Transitions

| Transition | Taken when |
| - | - |
| **Auto-advance** | Always, as soon as the variables are set. |

**Auto-advance** is created with the step and can't be removed.

You can also add **Skip if** to this step: when its conditions already hold as the call arrives, the call goes straight to its target and the step doesn't run. See [Skip if](https://docs.tryhamsa.com/agents/flow/transitions.md#skip-if).

## How it works on a call

1. Each variable is set in the order listed. A variable with no value at all is skipped; an empty value clears the variable.
2. The call moves on through **Auto-advance** right away. Nothing is spoken.

All variables are stored as text on a call. A **Boolean** reads `True` or `False`, and a number reads as written, so compare them that way in a Router step.

## Good to know

* Local variables are available to every later step on the call, not only to the next one.
* The step has a **Global** section, without **Confirm before proceeding**.

## Related

> [card] [Static and local variables](https://docs.tryhamsa.com/agents/variables/local-variables.md)
>
> More on local values and where they can be used.

> [card] [Jinja syntax](https://docs.tryhamsa.com/agents/variables/jinja.md)
>
> Build values from other variables.

> [card] [Router step](https://docs.tryhamsa.com/agents/flow/steps/router.md)
>
> Branch on the values you set.

> [card] [Variables](https://docs.tryhamsa.com/agents/variables/overview.md)
>
> Every kind of variable in a flow.


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