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

# Set Variable

> The Set Variable action block lets you assign a specific value to a variable during a conversation flow. As the name suggests, you can define or update a variable with a new value at any point in the chat.

![Image](https://mintcdn.com/wotnot/YfQKl2QOkXpO0Wk_/images/image-56.png?fit=max\&auto=format\&n=YfQKl2QOkXpO0Wk_\&q=85\&s=1207a1bb6efd9bd2eaa15851bf3e8a28)

> [!NOTE]
>
> **Available on all channels.** The Set Variable block does not render anything to the user.

The **Set Variable** blocks lets you set a value into a variable. Useful when you are performing mathematical operations in your chatbot flow.

## Using the Set Variable block

Use the **Set variable** block when you need to:

* Set a default value
* Reset a variable
* Store a value for later use
* Set a flag for a condition
* Update a counter
* Modify an existing value
* Prepare a value for an API request
* Set multiple variables at once

**1. Add the block**

Drag the **Set variable** block onto the canvas and connect it to the next block in your flow.

**2. Select a variable**

Under **Variable**, select the variable you want to update.

**3. Enter a value**

Under **Value**, enter the value that you want to assign to the selected variable.

The value can be a static value, another variable, or an expression where supported.

> [!TIP]
>
> Use **Set variable** when the value is determined by the flow. Use **Collect input** when the value needs to come from the user, and **Set AI** when the value needs to be generated using AI.

## Configurations

| Field | Description |
| - | - |
| **Variable** | Select the variable that you want to update. |
| **Value** | Enter the value to assign to the variable. This can be a static value, another variable, or an expression where supported. |
| **Operations** | Modify the value using a supported arithmetic or string operation. |
| **Multiple assignments** | Set multiple variables in the same block. |

### Variable

Select the variable that you want to update.

For example:

```text theme={null}
customer_type
```

The selected variable is updated with the value configured in the **Value** field.

### Value

Specify the value that you want to assign to the selected variable.

> [tab] Static value
>
> Assign a fixed value.
>
> ```text theme={null}
> customer_type = Premium
> ```

> [tab] Another variable
>
> Use the value stored in another variable.
>
> ```text theme={null}
> customer_type = selected_plan
> ```

> [tab] Expression
>
> Use an expression to calculate or build a value where supported.
>
> ```text theme={null}
> total = price + tax
> ```

### Operations

Use operations to modify a value before assigning it to a variable.

For example, increment a counter:

```text theme={null}
retry_count = retry_count + 1
```

Or concatenate text values:

```text theme={null}
full_name = first_name + " " + last_name
```

> [!NOTE]
>
> The operations available depend on the variable type and the options supported in the Set variable configuration.

### Multiple assignments

Use multiple assignments when you need to update several variables in the same block.

For example:

```text theme={null}
customer_type = Premium
retry_count = 0
is_verified = true
```

This is useful when you need to initialize or reset multiple variables at the same point in the flow.

## Some examples

Here are some examples on the use of **Set variable** block.

**Set a default value**: to assign a default value to a variable.

```text theme={null}
customer_type = Premium
```

The `customer_type` variable can then be used later in the flow.

**Reset counter**: to initialize or reset a counter.

```text theme={null}
retry_count = 0
```

You can later increment the counter when required:

```text theme={null}
retry_count = retry_count + 1
```

The updated value can then be used in a condition to control the flow.

**Set a flag**: Use a variable as a flag to control the flow.

```text theme={null}
is_verified = true
```

A later **Condition** block can check the value of `is_verified` and route the flow accordingly.

**Prepare a value for an API request**: to prepare a value before making an API request.

```text theme={null}
customer_type = Premium
```

The `customer_type` variable can then be used in the request payload or parameters of a subsequent API call.

## Output paths

The **Set variable** block has a single output path.

After the variables are assigned, the flow continues to the next connected block.

```text theme={null}
Set variable → Next block
```


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