Files
dify-docs/en/guides/workflow/variables.mdx
Riskey 53c4c93b1e add docs for trigger (#504)
* draft

* draft

* draft

* refine dev docs

* almost

* update

* remove sys.file and sys.query; add sys.timestamp

* update the end node to output

* modify the introduction section of variable

* fix typo

* adjust image size

* remove unnecessary list

* feedback fix

* remove example

* feedback fix & add en/ja dev docs

* correct description

* fix typos

* replace UI text

* refinements & add zh-ja translation

* feedback fixes

* fix punctuation

* refine heading-reference

* typo

* adjust casing & remove sys.timestamp from chatflow

* Docs tools: 2 succeeded, some failed

Rename operation failed: - Lang 'zh': File 'dify-docs/plugin-dev-zh/0211-getting-started-dify-tool.mdx' - Renaming error: Unexpected error: 'str' object has no attribute 'get'
- Lang 'zh': File 'dify-docs/plugin-dev-zh/0222-datasource-plugin.mdx' - Skipped (non-compliant):
Missing/empty critical frontmatter fields for renaming: dimensions.type.primary, dimensions.type.detail, dimensions.level, standard_title, language (expected for metadata, though not used in filename suffix anymore).
- Lang 'zh': File 'dify-docs/plugin-dev-zh/0222-tool-oauth.mdx' - Skipped (non-compliant):
Missing/empty critical frontmatter fields for renaming: dimensions.type.primary, dimensions.type.detail, dimensions.level, standard_title, language (expected for metadata, though not used in filename suffix anymore).
- Lang 'zh': File 'dify-docs/plugin-dev-zh/0222-trigger-plugin.mdx' - Skipped (non-compliant):
Missing/empty critical frontmatter fields for renaming: dimensions.type.primary, dimensions.type.detail, dimensions.level, standard_title, language (expected for metadata, though not used in filename suffix anymore).
- Lang 'en': File 'dify-docs/plugin-dev-en/0211-getting-started-dify-tool.mdx' - Renaming error: Unexpected error: 'str' object has no attribute 'get'
- Lang 'en': File 'dify-docs/plugin-dev-en/0222-datasource-plugin.mdx' - Skipped (non-compliant):
Missing/empty critical frontmatter fields for renaming: dimensions.type.primary, dimensions.type.detail, dimensions.level, standard_title, language (expected for metadata, though not used in filename suffix anymore).
- Lang 'en': File 'dify-docs/plugin-dev-en/0222-tool-oauth.mdx' - Skipped (non-compliant):
Missing/empty critical frontmatter fields for renaming: dimensions.type.primary, dimensions.type.detail, dimensions.level, standard_title, language (expected for metadata, though not used in filename suffix anymore).
- Lang 'en': File 'dify-docs/plugin-dev-en/0222-trigger-plugin.mdx' - Skipped (non-compliant):
Missing/empty critical frontmatter fields for renaming: dimensions.type.primary, dimensions.type.detail, dimensions.level, standard_title, language (expected for metadata, though not used in filename suffix anymore).
- Lang 'ja': File 'dify-docs/plugin-dev-ja/0211-getting-started-dify-tool.mdx' - Renaming error: Unexpected error: 'str' object has no attribute 'get'
- Lang 'ja': File 'dify-docs/plugin-dev-ja/0222-datasource-plugin.mdx' - Skipped (non-compliant):
Missing/empty critical frontmatter fields for renaming: dimensions.type.primary, dimensions.type.detail, dimensions.level, standard_title, language (expected for metadata, though not used in filename suffix anymore).
- Lang 'ja': File 'dify-docs/plugin-dev-ja/0222-trigger-plugin.mdx' - Skipped (non-compliant):
Missing/empty critical frontmatter fields for renaming: dimensions.type.primary, dimensions.type.detail, dimensions.level, standard_title, language (expected for metadata, though not used in filename suffix anymore).

---------

Co-authored-by: Riskey <riskey47@dify.ai>
Co-authored-by: alterxyz <88554920+alterxyz@users.noreply.github.com>
2025-10-30 21:11:33 +08:00

113 lines
7.1 KiB
Plaintext

---
title: Variables
---
## Introduction
A variable is a labeled container that stores information in your workflow or chatflow. Each variable holds a piece of data—whether it's user input, system-generated values, or outputs from previous nodes. When you need to use this information later, you simply reference it by its name.
When building a workflow or chatflow, you'll work with different types of variables, each serving a specific purpose in your application's data flow.
## Variable Types
### System Variable
System variables are pre-set, system-level parameters that are globally available.
<Tabs>
<Tab title="Workflow">
| Variable Name | <div style={{width: '70px'}}>Data Type</div> | Description | Notes |
|:----------------|:-----------|:-------------|:--------|
| `sys.user_id` | String | User ID: A unique identifier automatically assigned by the system to each user when they use a workflow application. It is used to distinguish different users. | |
| `sys.app_id` | String | App ID: A unique identifier automatically assigned by the system to each App. This parameter is used to record the basic information of the current application. | This parameter is used to differentiate and locate distinct Workflow applications for users with development capabilities. |
| `sys.workflow_id` | String | Workflow ID: This parameter records information about all nodes information in the current Workflow application. | This parameter can be used by users with development capabilities to track and record information about the nodes contained within a Workflow. |
| `sys.workflow_run_id` | String | Workflow Run ID: Used to record the runtime status and execution logs of a Workflow application. | This parameter can be used by users with development capabilities to track the application's historical execution records. |
| `sys.timestamp` | String | The start time of each workflow execution. | |
</Tab>
<Tab title="Chatflow">
| Variable Name | <div style={{width: '70px'}}>Data Type</div> | Description | Notes |
|:----------------|:-----------|:-------------|:--------|
| `sys.conversation_id` | String | A unique ID for the chatting box interaction session, grouping all related messages into the same conversation, ensuring that the LLM continues the chatting on the same topic and context. | |
| `sys.dialogue_count` | Number | The number of conversations turns during the user's interaction with a Chatflow application. The count automatically increases by one after each chat round and can be combined with if-else nodes to create rich branching logic.<br /><br />For example, LLM will review the conversation history at the X conversation turn and automatically provide an analysis. | |
| `sys.user_id` | String | A unique ID is assigned for each application user to distinguish different conversation users. | The Service API does not share conversations created by the WebApp. This means users with the same ID will have separate conversation histories between API and WebApp interfaces. |
| `sys.app_id` | String | App ID: A unique identifier automatically assigned by the system to each App. This parameter is used to record the basic information of the current application. | This parameter is used to differentiate and locate distinct Workflow applications for users with development capabilities. |
| `sys.workflow_id` | String | Workflow ID: This parameter records information about all nodes information in the current Workflow application. | This parameter can be used by users with development capabilities to track and record information about the nodes contained within a Workflow. |
| `sys.workflow_run_id` | String | Workflow Run ID: Used to record the runtime status and execution logs of a Workflow application. | This parameter can be used by users with development capabilities to track the application's historical execution records. |
</Tab>
</Tabs>
### Environment Variables
**Environment variables are used to protect sensitive information involved in workflows**, such as API keys and database passwords used when running workflows. They are stored in the workflow rather than in the code, allowing them to be shared across different environments.
![Environment Variables](https://assets-docs.dify.ai/dify-enterprise-mintlify/en/guides/workflow/475c2b9a04b8c9ab16b7d3dba21755f3.png)
Supports the following 3 data types:
* String
* Number
* Secret
Environmental variables have the following characteristics:
* Environment variables can be globally referenced within most nodes;
* Environment variable names cannot be duplicated;
* Output variables of nodes are generally read-only and cannot be written to.
![](https://assets-docs.dify.ai/2025/06/8d9342615b3623ef4ce526a583a8de76.png)
***
### Conversation Variables
> Conversation variables are only applicable to [Chatflow](/en/guides/workflow/key-concepts#chatflow-and-workflow) App.
**Conversation variables allow application developers to specify particular information that needs to be temporarily stored within the same Chatflow session, ensuring that this information can be referenced across multiple rounds of chatting within the current chatflow**. This can include context, files uploaded to the chatting box(coming soon), user preferences input during the conversation, etc. It's like providing a "memo" for the LLM that can be checked at any time, avoiding information bias caused by LLM memory errors.
For example, you can store the language preference input by the user in the first round of chatting in a conversation variable. The LLM will refer to the information in the conversation variable when answering and use the specified language to reply to the user in subsequent chats.
![Conversation Variable](https://assets-docs.dify.ai/dify-enterprise-mintlify/en/guides/workflow/c04285fec92f13a20ccbd3e21361a30d.png)
**Conversation variables** support the following eight data types:
* String
* Number
* Object
* Boolean
* Array\[string]
* Array\[number]
* Array\[object]
* Array\[boolean]
**Conversation variables** have the following features:
* Conversation variables can be referenced globally within most nodes in the same Chatflow App;
* Writing to conversation variables requires using the [Variable Assigner](/en/guides/workflow/node/variable-assigner) node;
* Conversation variables are read-write variables;
About how to use conversation variables with the Variable Assigner node, please refer to the [Variable Assigner](/en/guides/workflow/node/variable-assigner).
To track changes in conversation variable values during debugging the application, click the conversation variable icon at the top of the Chatflow application preview page.
![](https://assets-docs.dify.ai/2024/11/cc8067fa4c96436f037f8210ebe3f65c.png)
## Notice
* To avoid variable name duplication, node naming must not be repeated
* The output variables of nodes are generally fixed variables and cannot be edited
{/*
Contributing Section
DO NOT edit this section!
It will be automatically generated by the script.
*/}
---
[Edit this page](https://github.com/langgenius/dify-docs/edit/main/en/guides/workflow/variables.mdx) | [Report an issue](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml)