Files
dify-docs/en/use-dify/nodes/variable-assigner.mdx
Riskey 2da02258f4 Update content for boolean, boolean array, and object data type support; refine user input page (#640)
* Update content for boolean, boolean array, and object data type support; refine user input page

* correct format descriptions

---------

Co-authored-by: Riskey <riskey47@dify.ai>
2025-12-24 22:51:00 +08:00

124 lines
4.7 KiB
Plaintext

---
title: "Variable Assigner"
description: "Manage persistent conversation variables in chatflow applications"
icon: "pen-to-square"
---
The Variable Assigner node manages persistent data in chatflow applications by writing to conversation variables (Understand the different types of variables [here](/en/use-dify/getting-started/key-concepts#variables)). Unlike regular workflow variables that reset with each execution, conversation variables persist throughout an entire chat session.
<Frame caption="Variable Assigner node configuration">
<img src="https://assets-docs.dify.ai/2024/11/83d0b9ef4c1fad947b124398d472d656.png" alt="Variable Assigner interface" />
</Frame>
## Conversation Variables vs Workflow Variables
**Workflow Variables** exist only during a single workflow execution and reset when the workflow completes.
**Conversation Variables** persist across multiple conversation turns within the same chat session, enabling stateful interactions and contextual memory.
This persistence enables contextual conversations, user personalization, stateful workflows, and progress tracking across multiple user interactions.
## Configuration
Configure which conversation variables to update and specify their source data. You can assign multiple variables in a single node.
<Frame caption="Variable assignment configuration interface">
<img src="https://assets-docs.dify.ai/2024/11/ee15dee864107ba5a93b459ebdfc32cf.png" alt="Variable assignment configuration" />
</Frame>
**Variable** - Select the conversation variable to write to
**Set Variable** - Choose the source data from upstream workflow nodes
**Operation Mode** - Determine how to update the variable (overwrite, append, clear, etc.)
## Operation Modes
Different variable types support different operations based on their data structure:
<Tabs>
<Tab title="String">
- **Overwrite** - Replace with another string variable
- **Clear** - Remove the current value
- **Set** - Manually assign a fixed value
</Tab>
<Tab title="Number">
- **Overwrite** - Replace with another number variable
- **Clear** - Remove the current value
- **Set** - Manually assign a fixed value
- **Arithmetic** - Add, subtract, multiply, or divide the current value by another number
</Tab>
<Tab title="Boolean">
- **Overwrite** - Replace with another boolean variable
- **Clear** - Remove the current value
- **Set** - Manually assign a fixed value
</Tab>
<Tab title="Object">
- **Overwrite** - Replace with another object variable
- **Clear** - Remove the current value
- **Set** - Manually define the object structure and values
</Tab>
<Tab title="Array">
- **Overwrite** - Replace with another array variable of the same type
- **Clear** - Remove all elements from the array
- **Append** - Add a single element to the end of the array
- **Extend** - Add all elements from another array of the same type
- **Remove First/Last** - Remove the first or last element from the array
<Tip>
Array operations are particularly powerful for building memory systems, checklists, and conversation histories that grow over time.
</Tip>
</Tab>
</Tabs>
## Common Implementation Patterns
### Smart Memory System
Build chatbots that automatically detect and store important information from conversations:
<Frame caption="Smart memory system workflow">
<img src="https://assets-docs.dify.ai/dify-enterprise-mintlify/en/guides/workflow/node/8d0492814b1515f50e87b2900ff400db.png" alt="Smart memory implementation" />
</Frame>
The system analyzes user input for memorable facts, extracts structured information, and appends it to a persistent memories array for future reference in conversations.
### User Preferences Storage
Store user preferences like language settings, notification preferences, or display options:
<Frame caption="User preferences management">
<img src="https://assets-docs.dify.ai/dify-enterprise-mintlify/en/guides/workflow/node/1867d608a7d009431b73377ed65b427b.png" alt="User preferences workflow" />
</Frame>
Use **Overwrite** mode to capture initial preferences from user input, then reference them in all subsequent LLM responses for personalized interactions.
### Progressive Checklists
Build guided workflows that track completion status across multiple conversation turns:
<Frame caption="Progressive checklist implementation">
<img src="https://assets-docs.dify.ai/dify-enterprise-mintlify/en/guides/workflow/node/c4362b01298b12e7d6fcd9e798f3165a.png" alt="Progressive checklist workflow" />
</Frame>
Use array conversation variables to track completed items. The Variable Assigner updates the checklist each turn, while the LLM references it to guide users through remaining tasks.