> ## 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 Node

> Set variable values without conversation, then automatically advance to the next node

## Overview

Set Local Variables nodes assign values to variables without any conversation. They execute instantly and automatically advance to the next connected node. Use them to initialize data, transform values, or prepare variables before they're needed downstream.

**Key characteristic:** No conversation, no user interaction. The node sets variables and immediately moves on.

## When to Use

Use Set Local Variables nodes to:

* **Initialize variables** before a conversation or tool node needs them
* **Transform data** — reformat, combine, or compute values from existing variables
* **Set defaults** — provide fallback values for variables that may not be extracted yet
* **Prepare API parameters** — assemble values before a tool node call
* **Store computed results** — save derived data for later use in the flow

***

## Core Configuration

```typescript theme={null}
{
  type: "set_local_variables",
  label?: string,
  description?: string,

  // Variables to set
  staticVariables?: Array<{
    id: string,
    name: string,            // snake_case, 1-50 chars
    description?: string,
    dataType: "string" | "number" | "boolean" | "array" | "object",
    value: string | number | boolean | any[] | object | null
  }>,

  // Transition (automatic — cannot be modified)
  transitions: Transition[]  // Single auto-transition to next node
}
```

<Info>
  Variables set in this node are available to all downstream nodes in the flow.
</Info>

***

## Variable Configuration

Each variable has four fields:

| Field           | Required | Description                                                     |
| --------------- | -------- | --------------------------------------------------------------- |
| **Name**        | Yes      | Variable name in `snake_case` format                            |
| **Type**        | Yes      | Data type: String, Number, Boolean, Array (JSON), Object (JSON) |
| **Value**       | Yes      | The value to assign — static or `{{variable}}` reference        |
| **Description** | No       | Optional description for documentation                          |

### Value Input by Type

| Type        | Input                               | Example                      |
| ----------- | ----------------------------------- | ---------------------------- |
| **String**  | Text input with variable support    | `"hello"` or `{{user_name}}` |
| **Number**  | Numeric input with variable support | `42` or `{{order_total}}`    |
| **Boolean** | Toggle switch                       | `true` / `false`             |
| **Array**   | JSON editor                         | `["item1", "item2"]`         |
| **Object**  | JSON editor                         | `{"key": "value"}`           |

All value inputs support `{{variable}}` references, allowing you to set a variable based on another variable's value.

***

## Use Cases & Examples

### Example 1: Initialize Variables Before a Loop

```yaml theme={null}
Set Local Variables: Init_Counter
  variables:
    - name: attempt_count
      type: number
      value: 0
    - name: max_attempts
      type: number
      value: 3

  → Attempt_Action
```

### Example 2: Combine Variables

```yaml theme={null}
Set Local Variables: Build_Full_Name
  variables:
    - name: full_name
      type: string
      value: "{{first_name}} {{last_name}}"

  → Greet_Customer
```

### Example 3: Set Defaults

```yaml theme={null}
Set Local Variables: Set_Defaults
  variables:
    - name: language
      type: string
      value: "en"
    - name: priority
      type: string
      value: "normal"

  → Collect_Info
```

### Example 4: Prepare API Parameters

```yaml theme={null}
Set Local Variables: Prepare_Booking
  variables:
    - name: booking_payload
      type: object
      value: {"customer_id": "{{customer_id}}", "date": "{{selected_date}}", "time": "{{selected_time}}"}

  → Submit_Booking_Tool
```

***

## Transitions

Set Local Variables nodes use an **automatic transition** — they execute and immediately advance to the next connected node. You cannot add, remove, or edit transitions on this node type.

Connect the node's output to the next node in your flow. The connection is always unconditional.

***

## Flow Examples

### Pattern: Initialize → Collect → Process

```mermaid theme={null}
graph LR
    Init[Set Variables:<br/>Set Defaults]
    Collect[Conversation:<br/>Gather Info]
    Process[Tool:<br/>Submit Data]

    Init --> Collect --> Process
```

### Pattern: Transform Between Nodes

```mermaid theme={null}
graph LR
    Lookup[Tool:<br/>Customer Lookup]
    Transform[Set Variables:<br/>Format Data]
    Greet[Conversation:<br/>Personalized Greeting]

    Lookup --> Transform --> Greet
```

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Change Agent Settings" icon="sliders" href="./change-agent-settings-node">
    Override agent settings mid-flow
  </Card>

  <Card title="Variables" icon="code" href="/agents/variables/introduction">
    Learn about the variable system
  </Card>

  <Card title="Tool Node" icon="wrench" href="./tool-node">
    Execute tools with variable parameters
  </Card>

  <Card title="Router Node" icon="route" href="./router-node">
    Route based on variable values
  </Card>
</CardGroup>
