> For the complete documentation index, see [llms.txt](https://documentation.proto.cx/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.proto.cx/docs/modules/ai-agents/workflows-and-actions/set-variable.md).

# Set variable

`Action` — Creates or modifies a [chat variable](/docs/developers/chat-variables.md) for use by subsequent actions in the same session.

## What it does

Stores or transforms a value mid-chat, making it available to downstream actions as a named variable.

## When to use it

To set a flag, build a string from other variables, or calculate a value to use later in the flow — without asking the person for it directly.

## Settings

| Setting           | Description                                                                                                                                                              |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Variable name** | The name of a new or existing variable, including default system variables. Must start with a letter and contain only letters (a–z, A–Z), numbers (0–9), or underscores. |
| **Chat script**   | A [Python expression](/docs/developers/chat-scripts.md) that sets the variable's value.                                                                                  |

Press **Save** to confirm edits.

## Example

```
Set variable
• Variable name: complaint_ref
• Chat script:   financial_institution + "-" + ticket_number
```

## Related

{% content-ref url="/pages/yRuISyntS8UJxaE5kgNX" %}
[Branch](/docs/modules/ai-agents/workflows-and-actions/branch.md)
{% endcontent-ref %}

{% content-ref url="/pages/KpQiIGAmCVTGp5hdcACQ" %}
[Ask survey](/docs/modules/ai-agents/workflows-and-actions/ask-survey.md)
{% endcontent-ref %}
