dify-workflow-skills by mango-svip/dify-workflow-skills
npx skills add https://github.com/mango-svip/dify-workflow-skills --skill dify-workflow-skills构建、编辑和验证 Dify 工作流 DSL(领域特定语言)文件,用于创建 AI 驱动的自动化工作流。
此技能基于 Dify 开源平台的工作流引擎,该引擎通过基于 React Flow 的可视化编辑器为工作流应用和高级聊天应用提供支持。
Dify 工作流采用基于队列、事件驱动的架构,包含:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
sendBeaconisWorkflowDataLoaded 标志跟踪加载状态节点类型 : 完整列表请参见 references/node_types.md,包括:
边类型与连接 : 关于以下内容,请参见 references/edge_types.md:
节点定位 : 关于以下内容,请参见 references/node_positioning.md:
通用节点属性 : 所有节点都支持这些内部属性(以 _ 为前缀):
_runningStatus: 当前执行状态(running, succeeded, failed)_connectedSourceHandleIds/_connectedTargetHandleIds: 连接跟踪_isSingleRun: 用于调试的单次执行模式_isCandidate: 连接拖动期间的幻影节点_children: 容器类型(iteration, loop)的子节点_iterationLength/_iterationIndex: 迭代状态跟踪_loopLength/_loopIndex: 循环状态跟踪_retryIndex: 当前重试尝试次数_waitingRun: 排队等待执行,human-input工作流结构 : 完整的 DSL 格式请参见 references/workflow_structure.md
边类型 : 连接模式和连接点类型请参见 references/edge_types.md
节点定位 : 布局指南请参见 references/node_positioning.md
模板 : 示例工作流请查看 assets/
询问用户:
规划工作流结构:
使用 scripts/generate_id.py 创建唯一的节点 ID:
python3 scripts/generate_id.py 5 # 生成 5 个唯一 ID
或者在 Python/JavaScript 中生成:
# Python
import time
node_id = str(int(time.time() * 1000))
// JavaScript (在 Dify 前端使用)
const nodeId = `${Date.now()}`
容器节点的特殊 ID 模式 :
${parentNodeId}start1736668800000,其开始节点 ID 是 1736668800000start创建完整的 YAML 结构,包含:
使用的模板 : 对于基本流程,从 assets/simple_llm_workflow.yml 开始
检查工作流结构是否存在常见问题:
{{#node_id.field#}}开始 → LLM → 结束
使用场景 : 基本问答、文本生成
模板 : assets/simple_llm_workflow.yml
开始 → 代码(带 fail-branch)→ [成功 → 聚合器] / [失败 → LLM 恢复 → 重试 → 聚合器] → 结束
使用场景 : 具有错误恢复功能的稳健数据处理
模板 : assets/error_handling_workflow.yml
关键点 :
error_strategy: fail-brancherror_message 和 error_type 变量开始 → If-Else → [True → 处理器 A] / [False → 处理器 B] → 聚合器 → 结束
使用场景 : 根据内容/类型路由请求
模板 : assets/conditional_workflow.yml
关键点 :
true 和 false 源连接点开始 → 循环 → [处理项目] → 循环结束 → 结束
使用场景 : 带有中断条件的迭代处理
关键点 :
loop_count 以限制最大迭代次数break_conditions 以提前退出workflow.graph.nodes 数组,包含:
workflow.graph.edges 以连接新节点workflow.graph.nodes 中移除节点source、target、sourceHandle 或 targetHandledata.sourceType 和 data.targetType 以匹配实际的节点类型id 以遵循命名约定:{source_id}-{handle}-{target_id}-target变量在集中的 VariablePool 中管理,并使用格式:{{#node_id.field_name#}}
Dify 支持这些变量类型,用于类型安全的数据流:
基本类型 :
string: 文本数据number: 浮点数integer: 整数boolean: true/false 值secret: 加密的敏感数据(API 密钥、密码)复杂类型 :
object: JSON 对象file: 单个文件引用array: 通用数组array[string]: 字符串数组array[number]: 数字数组array[object]: 对象数组array[boolean]: 布尔值数组array[file]: 文件数组array[any]: 混合类型数组any: 任何类型(谨慎使用)特殊类型 :
contexts: 知识检索结果iterator: 迭代输入变量loop: 循环输入变量当使用文件输入类型(file、files、file-list)时,可以配置上传设置:
默认文件上传设置 :
allowed_file_upload_methods: ['local_file', 'remote_url']
max_length: 5 # 最大文件数量
allowed_file_types: ['image'] # 选项:image, document, audio, video, custom
allowed_file_extensions: [] # 例如,['.pdf', '.docx']
上传方法 :
local_file: 从本地系统直接上传文件remote_url: 从 URL 上传文件文件类型类别 :
image: 图像文件(JPG, PNG, GIF 等)document: 文档文件(PDF, DOCX, TXT 等)audio: 音频文件(MP3, WAV 等)video: 视频文件(MP4, AVI 等)custom: 自定义文件类型(指定扩展名)开始节点使用这些输入类型来定义面向用户的变量:
text-input: 单行文本输入paragraph: 多行文本输入select: 下拉选择number: 数字输入checkbox: 布尔复选框url: URL 输入(带验证)files: 多文件上传file: 单文件上传file-list: 多文件列表json: JSON 输入(对象或数组)json_object: JSON 对象(带模式验证)contexts: 知识检索上下文iterator: 迭代变量loop: 循环变量变量模式正则表达式:{{#[a-zA-Z0-9_]{1,50}(?:\.[a-zA-Z_][a-zA-Z0-9_]{0,29}){1,10}#}}
选择器结构 : [node_id, variable_name, ...optional_nested_keys]
ValueSelector : DSL 中使用的数组格式(例如,['1732007415808', 'text'])
value_selector: ['node_id', 'field_name']{{#node_id.field_name#}}通过 sys 节点 ID 可用:
{{#sys.query#}} - 用户查询/输入{{#sys.files#}} - 上传的文件{{#sys.conversation_id#}} - 当前对话 ID{{#sys.user_id#}} - 用户标识符{{#sys.dialogue_count#}} - 对话轮数{{#sys.app_id#}} - 应用 ID{{#sys.workflow_id#}} - 工作流 ID{{#sys.workflow_run_id#}} - 当前执行 ID{{#sys.timestamp#}} - 当前时间戳LLM 节点 :
{{#node_id.text#}} - 生成的文本响应(类型:string){{#node_id.usage#}} - Token 使用信息(类型:object){{#node_id.reasoning_content#}} - 模型推理(如果启用)(类型:string)Agent 节点 :
{{#node_id.usage#}} - Token 使用信息(类型:object)Code 节点 :
{{#node_id.output_name#}} - 节点配置中定义的命名输出{{#node_id.error_message#}} - 错误消息(仅限 fail-branch)(类型:string){{#node_id.error_type#}} - 错误类型(仅限 fail-branch)(类型:string)Start 节点 :
{{#node_id.variable_name#}} - 开始节点中定义的输入变量If-Else 节点 :
{{#node_id.condition_result#}} - 布尔条件结果Loop 节点 :
{{#node_id.output#}} - 循环输出数组{{#node_id.iteration#}} - 当前迭代次数HTTP Request 节点 :
{{#node_id.body#}} - 响应体(类型:string){{#node_id.status_code#}} - HTTP 状态码(类型:number){{#node_id.headers#}} - 响应头(类型:object){{#node_id.files#}} - 如果响应是文件,则为下载的文件(类型:array[file])Tool 节点 :
{{#node_id.text#}} - 工具输出文本(类型:string){{#node_id.files#}} - 工具输出文件(类型:array[file]){{#node_id.json#}} - 工具输出 JSON(类型:array[object])Knowledge Retrieval 节点 :
{{#node_id.result#}} - 检索到的知识片段(类型:array[object])Template Transform 节点 :
{{#node_id.output#}} - 转换后的输出(类型:string)Question Classifier 节点 :
{{#node_id.class_name#}} - 分类结果(类型:string){{#node_id.usage#}} - Token 使用信息(类型:object)Parameter Extractor 节点 :
{{#node_id.__is_success#}} - 提取成功指示器(类型:number){{#node_id.__reason#}} - 提取失败原因(类型:string){{#node_id.__usage#}} - Token 使用信息(类型:object)Variable Aggregator :
{{#node_id.output#}} - 从合并分支聚合的输出文件对象结构(当使用文件类型时):
name - 文件名(类型:string)size - 文件大小(字节)(类型:number)type - 文件类型类别(类型:string)extension - 文件扩展名(类型:string)mime_type - MIME 类型(类型:string)transfer_method - 使用的传输方法(类型:string)url - 文件 URL(类型:string)related_id - 相关资源 ID(类型:string)知识检索结果结构 :
{
"content": "",
"title": "",
"url": "",
"icon": "",
"metadata": {
"dataset_id": "",
"dataset_name": "",
"document_id": [],
"document_name": "",
"document_data_source_type": "",
"segment_id": "",
"segment_position": "",
"segment_word_count": "",
"segment_hit_count": "",
"segment_index_node_hash": "",
"score": ""
}
}
环境变量(在应用级别定义):
env 访问{{#env.API_KEY#}}对话变量(会话状态):
conversation 访问{{#conversation.user_context#}}# 在 LLM 提示词模板中
prompt_template:
- role: system
text: "You are a helpful assistant."
- role: user
text: "Process this input: {{#1732007415808.user_input#}}"
# 在代码节点中
variables:
- ["1732007415808", "user_input"]
- ["1732007420123", "processed_data"]
# 访问嵌套对象字段
text: "File name: {{#upload_node.files.name#}}"
text: "API response status: {{#http_node.status_code#}}"
在画布上定位节点以实现视觉清晰度:
布局常量(来自 Dify 前端):
NODE_WIDTH: 240 像素X_OFFSET: 60 像素(水平间距)NODE_WIDTH_X_OFFSET: 300 像素(节点宽度 + 间距)Y_OFFSET: 39 像素START_INITIAL_POSITION: { x: 80, y: 282 }NODE_LAYOUT_HORIZONTAL_PADDING: 60 像素NODE_LAYOUT_VERTICAL_PADDING: 60 像素NODE_LAYOUT_MIN_DISTANCE: 100 像素容器节点内边距 :
水平间距 : 连接的节点之间 300-400 像素 垂直间距 :
示例位置 :
Start: x=80, y=282 # 初始位置
LLM: x=380, y=282 # Start + NODE_WIDTH_X_OFFSET
Code: x=680, y=282
End: x=980, y=282
对于分支:
If-else: x=380, y=300
True branch: x=680, y=200
False branch: x=680, y=450
Aggregator: x=980, y=300
容器节点(迭代/循环) :
parentId 为容器 ID详细的布局模式和公式请参见 references/node_positioning.md。
您创建的 DSL 将在使用 React Flow 构建的 Dify 可视化工作流编辑器中呈现。
节点 → 画布上的可视块,包含:
type 和 title 字段)边 → 连接节点的贝塞尔曲线,包含:
视口 → 画布视图设置:
viewport:
x: 0 # 平移偏移 X
y: 0 # 平移偏移 Y
zoom: 1.0 # 缩放级别(0.1 到 2.0)
当您的 DSL 加载到编辑器中时:
这些仅限 UI 的属性由前端管理(不要包含在 DSL 中):
_hovering, _connectedNodeIsHovering: 鼠标交互状态_connectedSourceHandleIds, _connectedTargetHandleIds: 根据边计算得出_runningStatus, _singleRunningStatus: 运行时执行状态_isCandidate: 连接拖动期间的临时幻影节点selected: 节点选中状态重要 : 在您的 DSL 中仅包含持久性属性(id, type, title, position, configuration)。运行时 UI 状态由编辑器计算。
Dify 支持在节点配置中定义的多种错误处理策略:
1. fail-branch(推荐用于代码/HTTP 节点):
error_message 和 error_type 变量sourceHandle: "fail-branch"sourceHandle: "success-branch"2. default-value :
3. abort(默认):
4. retry :
retry_config 部分定义重试配置结构 :
retry_config:
max_retries: 3 # 最大重试尝试次数(默认:3)
retry_interval: 100 # 重试间隔(毫秒)(默认:100)
在节点配置中:
error_strategy: fail-branch
在边数组中:
# 成功路径
- id: code_node-success-branch-next_node-target
source: code_node_id
target: aggregator_id
sourceHandle: success-branch
targetHandle: target
# 失败路径
- id: code_node-fail-branch-error_handler-target
source: code_node_id
target: error_handler_id
sourceHandle: fail-branch
targetHandle: target
失败分支中可用的错误变量 :
{{#node_id.error_message#}} - 人类可读的错误描述{{#node_id.error_type#}} - 错误类型分类在最终确定工作流之前,请验证:
sourceHandle 值与节点类型匹配:
"source"(默认)"true"、"false" 或分类标签"success-branch" 或 "fail-branch""loop" 用于继续targetHandle 对于大多数节点通常是 "target"data.sourceType 与实际源节点类型匹配data.targetType 与实际目标节点类型匹配error_strategy: fail-branch 时,存在 fail-branch 边{{#node_id.field#}}sys 前缀:{{#sys.query#}}env 前缀error_strategy: fail-branch 的节点同时具有成功和失败边error_strategy: default-value 时,提供了默认值loop_count 和中断条件Dify 根据节点的执行行为对节点进行分类。理解这些类型有助于设计正确的工作流:
执行逻辑并产生输出。最常见的节点类型。
"source"(或带错误处理的 "success-branch"/"fail-branch")根据条件在多个路径之间选择来控制流程。
"true", "false"通过迭代或循环管理嵌套的执行上下文。
"loop" 用于迭代/循环继续实时向用户流式传输输出。
作为工作流的入口点。
以下节点类型可以产生其他节点可以引用的输出变量:
注意 : 不在此列表中的节点(如 if-else, end, answer)通常不产生可重用的输出变量,尽管有些可能具有有限的内部状态。
边在执行期间可以处于三种状态:
工作流通过这些状态进行:
各个节点使用这些状态跟踪其执行状态:
重要的 UI 状态属性(仅限运行时,不在 DSL 中):
_runningStatus: 当前执行状态_singleRunningStatus: 运行单个节点时的状态_waitingRun: 节点已排队等待执行_retryIndex: 当前重试尝试次数_isSingleRun: 节点处于单次运行调试模式Build, edit, and validate Dify workflow DSL (Domain-Specific Language) files for creating AI-powered automation workflows.
This skill is based on the Dify open-source platform's workflow engine, which powers both Workflow apps and Advanced Chat apps with a React Flow-based visual editor.
Dify workflows use a queue-based, event-driven architecture with:
sendBeacon for safety
isWorkflowDataLoaded flagNode Types : See references/node_types.md for complete list including:
Edge Types and Connections : See references/edge_types.md for:
Node Positioning : See references/node_positioning.md for:
Common Node Properties : All nodes support these internal properties (prefixed with _):
_runningStatus: Current execution status (running, succeeded, failed)_connectedSourceHandleIds/_connectedTargetHandleIds: Connection tracking_isSingleRun: Single execution mode for debugging_isCandidate: Phantom node during connection drag_children: Child nodes for container types (iteration, loop)_iterationLength/_iterationIndex: Iteration state tracking_loopLength/_loopIndex: Loop state trackingWorkflow Structure : See references/workflow_structure.md for complete DSL format
Edge Types : See references/edge_types.md for connection patterns and handle types
Node Positioning : See references/node_positioning.md for layout guidelines
Templates : Check assets/ for example workflows
Ask the user:
Plan the workflow structure:
Use scripts/generate_id.py to create unique node IDs:
python3 scripts/generate_id.py 5 # Generate 5 unique IDs
Or generate in Python/JavaScript:
# Python
import time
node_id = str(int(time.time() * 1000))
// JavaScript (used in Dify frontend)
const nodeId = `${Date.now()}`
Special ID patterns for container nodes :
${parentNodeId}start1736668800000, its start node ID is 1736668800000startCreate the complete YAML structure with:
Template to use : Start from assets/simple_llm_workflow.yml for basic flows
Check the workflow structure for common issues:
{{#node_id.field#}}Start → LLM → End
Use case : Basic question answering, text generation
Template : assets/simple_llm_workflow.yml
Start → Code (with fail-branch) → [Success → Aggregator] / [Fail → LLM Recovery → Retry → Aggregator] → End
Use case : Robust data processing with error recovery
Template : assets/error_handling_workflow.yml
Key points :
error_strategy: fail-branch on code nodeerror_message and error_type variablesStart → If-Else → [True → Handler A] / [False → Handler B] → Aggregator → End
Use case : Route requests based on content/type
Template : assets/conditional_workflow.yml
Key points :
true and false sourceHandlesStart → Loop → [Process Items] → Loop End → End
Use case : Iterative processing with break conditions
Key points :
loop_count for maximum iterationsbreak_conditions to exit earlyworkflow.graph.nodes array with:
workflow.graph.edges connecting the new nodeworkflow.graph.nodessource, target, sourceHandle, or targetHandledata.sourceType and data.targetType to match actual node typesid to follow naming convention: {source_id}-{handle}-{target_id}-targetVariables are managed in a centralized VariablePool and use the format: {{#node_id.field_name#}}
Dify supports these variable types for type-safe data flow:
Primitive Types :
string: Text datanumber: Floating-point numbersinteger: Whole numbersboolean: true/false valuessecret: Encrypted sensitive data (API keys, passwords)Complex Types :
object: JSON objectsfile: Single file referencearray: Generic arrayarray[string]: Array of stringsarray[number]: Array of numbersarray[object]: Array of objectsarray[boolean]: Array of booleansarray[file]: Array of filesarray[any]: Array of mixed typesany: Any type (use sparingly)Special Types :
contexts: Knowledge retrieval resultsiterator: Iteration input variableloop: Loop input variableWhen using file input types (file, files, file-list), you can configure upload settings:
Default File Upload Settings :
allowed_file_upload_methods: ['local_file', 'remote_url']
max_length: 5 # Maximum number of files
allowed_file_types: ['image'] # Options: image, document, audio, video, custom
allowed_file_extensions: [] # e.g., ['.pdf', '.docx']
Upload Methods :
local_file: Direct file upload from local systemremote_url: Upload file from URLFile Type Categories :
image: Image files (JPG, PNG, GIF, etc.)document: Document files (PDF, DOCX, TXT, etc.)audio: Audio files (MP3, WAV, etc.)video: Video files (MP4, AVI, etc.)custom: Custom file types (specify extensions)Start nodes use these input types for user-facing variables:
text-input: Single-line text inputparagraph: Multi-line text inputselect: Dropdown selectionnumber: Numeric inputcheckbox: Boolean checkboxurl: URL input with validationfiles: Multiple file uploadfile: Single file uploadfile-list: Multiple file listjson: JSON input (object or array)The variable pattern regex: {{#[a-zA-Z0-9_]{1,50}(?:\.[a-zA-Z_][a-zA-Z0-9_]{0,29}){1,10}#}}
Selector structure : [node_id, variable_name, ...optional_nested_keys]
ValueSelector : Array format used in DSL (e.g., ['1732007415808', 'text'])
value_selector: ['node_id', 'field_name']{{#node_id.field_name#}}Available via sys node ID:
{{#sys.query#}} - User query/input{{#sys.files#}} - Uploaded files{{#sys.conversation_id#}} - Current conversation ID{{#sys.user_id#}} - User identifier{{#sys.dialogue_count#}} - Number of dialogue turns{{#sys.app_id#}} - Application ID{{#sys.workflow_id#}} - Workflow ID{{#sys.workflow_run_id#}} - Current execution ID{{#sys.timestamp#}} - Current timestampLLM Node :
{{#node_id.text#}} - Generated text response (type: string){{#node_id.usage#}} - Token usage information (type: object){{#node_id.reasoning_content#}} - Model reasoning (if enabled) (type: string)Agent Node :
{{#node_id.usage#}} - Token usage information (type: object)Code Node :
{{#node_id.output_name#}} - Named outputs defined in node config{{#node_id.error_message#}} - Error message (fail-branch only) (type: string){{#node_id.error_type#}} - Error type (fail-branch only) (type: string)Start Node :
{{#node_id.variable_name#}} - Input variables defined in start nodeIf-Else Node :
{{#node_id.condition_result#}} - Boolean condition resultLoop Node :
{{#node_id.output#}} - Loop output array{{#node_id.iteration#}} - Current iteration numberHTTP Request Node :
{{#node_id.body#}} - Response body (type: string){{#node_id.status_code#}} - HTTP status code (type: number){{#node_id.headers#}} - Response headers (type: object){{#node_id.files#}} - Downloaded files if response is file (type: array[file])Tool Node :
{{#node_id.text#}} - Tool output text (type: string){{#node_id.files#}} - Tool output files (type: array[file]){{#node_id.json#}} - Tool output JSON (type: array[object])Knowledge Retrieval Node :
{{#node_id.result#}} - Retrieved knowledge segments (type: array[object])Template Transform Node :
{{#node_id.output#}} - Transformed output (type: string)Question Classifier Node :
{{#node_id.class_name#}} - Classification result (type: string){{#node_id.usage#}} - Token usage information (type: object)Parameter Extractor Node :
{{#node_id.__is_success#}} - Extraction success indicator (type: number){{#node_id.__reason#}} - Extraction failure reason (type: string){{#node_id.__usage#}} - Token usage information (type: object)Variable Aggregator :
{{#node_id.output#}} - Aggregated output from merged branchesFile Object Structure (when file type is used):
name - File name (type: string)size - File size in bytes (type: number)type - File type category (type: string)extension - File extension (type: string)mime_type - MIME type (type: string)transfer_method - Transfer method used (type: string)url - File URL (type: string)related_id - Related resource ID (type: string)Knowledge Retrieval Result Structure :
{
"content": "",
"title": "",
"url": "",
"icon": "",
"metadata": {
"dataset_id": "",
"dataset_name": "",
"document_id": [],
"document_name": "",
"document_data_source_type": "",
"segment_id": "",
"segment_position": "",
"segment_word_count": "",
"segment_hit_count": "",
"segment_index_node_hash": "",
"score": ""
}
}
Environment variables (defined at app level):
env{{#env.API_KEY#}}Conversation variables (session state):
conversation{{#conversation.user_context#}}# In LLM prompt template
prompt_template:
- role: system
text: "You are a helpful assistant."
- role: user
text: "Process this input: {{#1732007415808.user_input#}}"
# In code node
variables:
- ["1732007415808", "user_input"]
- ["1732007420123", "processed_data"]
# Accessing nested object fields
text: "File name: {{#upload_node.files.name#}}"
text: "API response status: {{#http_node.status_code#}}"
Position nodes on the canvas for visual clarity:
Layout Constants (from Dify frontend):
NODE_WIDTH: 240 pixelsX_OFFSET: 60 pixels (horizontal spacing)NODE_WIDTH_X_OFFSET: 300 pixels (node width + spacing)Y_OFFSET: 39 pixelsSTART_INITIAL_POSITION: { x: 80, y: 282 }NODE_LAYOUT_HORIZONTAL_PADDING: 60 pixelsNODE_LAYOUT_VERTICAL_PADDING: 60 pixelsNODE_LAYOUT_MIN_DISTANCE: 100 pixelsContainer Node Padding :
Horizontal spacing : 300-400 pixels between connected nodes Vertical spacing :
Example positions :
Start: x=80, y=282 # Initial position
LLM: x=380, y=282 # Start + NODE_WIDTH_X_OFFSET
Code: x=680, y=282
End: x=980, y=282
For branching:
If-else: x=380, y=300
True branch: x=680, y=200
False branch: x=680, y=450
Aggregator: x=980, y=300
Container nodes (Iteration/Loop) :
parentId set to container IDSee references/node_positioning.md for detailed layout patterns and formulas.
The DSL you create is rendered in the Dify visual workflow editor built with React Flow.
Nodes → Visual blocks on canvas with:
type and title fields)Edges → Bezier curves connecting nodes with:
Viewport → Canvas view settings:
viewport:
x: 0 # Pan offset X
y: 0 # Pan offset Y
zoom: 1.0 # Zoom level (0.1 to 2.0)
When your DSL is loaded into the editor:
These UI-only properties are managed by the frontend (don't include in DSL):
_hovering, _connectedNodeIsHovering: Mouse interaction state_connectedSourceHandleIds, _connectedTargetHandleIds: Computed from edges_runningStatus, _singleRunningStatus: Runtime execution state_isCandidate: Temporary phantom node during connection dragselected: Node selection stateImportant : Only include persistent properties in your DSL (id, type, title, position, configuration). Runtime UI state is computed by the editor.
Dify supports multiple error handling strategies defined in the node configuration:
1. fail-branch (recommended for code/http nodes):
error_message and error_type variablessourceHandle: "fail-branch" in edge configurationsourceHandle: "success-branch"2. default-value :
3. abort (default):
4. retry :
retry_config sectionRetry Configuration Structure :
retry_config:
max_retries: 3 # Maximum retry attempts (default: 3)
retry_interval: 100 # Interval between retries in ms (default: 100)
In node configuration:
error_strategy: fail-branch
In edges array:
# Success path
- id: code_node-success-branch-next_node-target
source: code_node_id
target: aggregator_id
sourceHandle: success-branch
targetHandle: target
# Failure path
- id: code_node-fail-branch-error_handler-target
source: code_node_id
target: error_handler_id
sourceHandle: fail-branch
targetHandle: target
Available error variables in fail-branch:
{{#node_id.error_message#}} - Human-readable error description{{#node_id.error_type#}} - Error type classificationBefore finalizing a workflow, verify:
sourceHandle values match node types:
"source" (default)"true", "false", or classification label"success-branch" or "fail-branch""loop" for continuationtargetHandle is typically "target" for most nodesdata.sourceType matches the actual source node type{{#node_id.field#}}sys prefix: {{#sys.query#}}env prefix if needederror_strategy: fail-branch have both success and fail edgeserror_strategy: default-valueloop_count and break conditionsDify categorizes nodes by their execution behavior. Understanding these types helps design correct workflows:
Execute logic and produce outputs. Most common node type.
"source" (or "success-branch"/"fail-branch" with error handling)Control flow by choosing between multiple paths based on conditions.
"true", "false"Manage nested execution contexts with iterations or loops.
"loop" for iteration/loop continuationStream outputs to users in real-time.
Serve as workflow entry points.
The following node types can produce output variables that other nodes can reference:
Note : Nodes not in this list (like if-else, end, answer) typically don't produce reusable output variables, though some may have limited internal state.
Edges can be in three states during execution:
Workflows progress through these states:
Individual nodes track their execution state with these statuses:
Important UI State Properties (runtime only, not in DSL):
_runningStatus: Current execution status_singleRunningStatus: Status when running single node_waitingRun: Node is queued for execution_retryIndex: Current retry attempt number_isSingleRun: Node is in single-run debug modeloop_count limits and clear break conditionsgenerate_id.py - Generate unique node IDs for workflowsvalidate_workflow.py - Validate workflow DSL syntax (requires PyYAML)node_types.md - Complete reference of all Dify node types with examplesworkflow_structure.md - Detailed DSL structure and format specificationsimple_llm_workflow.yml - Basic start→LLM→end templateerror_handling_workflow.yml - Template with fail-branch error handlingconditional_workflow.yml - Template with if-else branchingWeekly Installs
86
Repository
GitHub Stars
1
First Seen
Jan 23, 2026
Security Audits
Gen Agent Trust HubFailSocketPassSnykWarn
Installed on
opencode81
gemini-cli76
codex76
github-copilot71
cursor69
amp62
AI Elements:基于shadcn/ui的AI原生应用组件库,快速构建对话界面
69,600 周安装
Umbraco单元测试指南:使用@open-wc/testing测试后台扩展与Lit元素
72 周安装
OpenClaw沙盒防护配置生成器 - 安全隔离不受信技能的Docker沙盒方案
195 周安装
LLM错误分析指南:如何系统化诊断和分类AI流水线故障
194 周安装
Nansen 持币者分析工具:评估代币持有者质量,识别聪明钱与散户信号
195 周安装
Symfony端到端测试工具:Panther与Playwright集成,实现自动化E2E测试与TDD开发
198 周安装
Microsoft Agent Framework:开源AI智能体与工作流平台,支持Python/C#跨平台开发
195 周安装
_retryIndex: Current retry attempt_waitingRun: Queued for execution, human-inputjson_object: JSON object with schema validationcontexts: Knowledge retrieval contextiterator: Iteration variableloop: Loop variabledata.targetType matches the actual target node typeerror_strategy: fail-branch is used