---
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. 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 Variables">
    **Overwrite** - Replace the entire string value with new content
    
    **Clear** - Empty the variable, setting it to null or blank
    
    **Set** - Manually type in a fixed value
  </Tab>
  
  <Tab title="Number Variables">
    **Overwrite** - Replace the number value completely
    
    **Clear** - Set to null or empty state
    
    **Set** - Manually enter a specific number value
    
    **Arithmetic** - Add, subtract, multiply, or divide the current value
  </Tab>
  
  <Tab title="Object Variables">
    **Overwrite** - Replace the entire object with new data
    
    **Clear** - Empty the object, removing all properties
    
    **Set** - Manually define object structure and values
  </Tab>
  
  <Tab title="Array Variables">
    **Overwrite** - Replace the entire array with new data
    
    **Clear** - Empty the array, removing all elements
    
    **Append** - Add one item to the end of the array
    
    **Extend** - Add multiple items from another array
    
    **Remove** - Delete items from first or last position
  </Tab>
</Tabs>

Array operations are particularly powerful for building memory systems, checklists, and conversation histories that grow over time.

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

## Best Practices

**Choose Appropriate Data Types** - Use arrays for growing collections, objects for structured data, and simple types for single values.

**Use Descriptive Variable Names** - Name conversation variables clearly to indicate their purpose and contents.

**Handle Data Growth** - Monitor array and object sizes to prevent excessive memory usage in long conversations.

**Initialize Variables** - Set initial values for conversation variables to prevent undefined behavior.

**Clear When Appropriate** - Use clear operations to reset variables when starting new processes or sessions.