A professional Dify workflow DSL/YML file automatic generation tool, based on deep learning from 86+ real workflow cases, capable of automatically generating complete workflow configuration files that comply with the Dify specification according to user business requirements.
Core Features
- ✅ Complete DSL Generation: Automatically generate complete YML files containing app, dependencies, workflow
- ✅ Multi-node Support: Supports all node types such as start, llm, answer, code, http-request, if-else, tool, etc.
- ✅ Intelligent Connections: Automatically generate edges connection relationships between nodes
- ✅ Parameter Configuration: Intelligently recommend model parameters and prompt configurations
- ✅ Plugin Integration: Automatically identify and configure required Dify plugin dependencies
- ✅ Standardized Format: Strictly follow the Dify 0.3.0 version DSL specification
Usage
Basic Usage
生成一个 Dify 工作流用于 [业务需求描述]
Detailed Usage
帮我生成一个 Dify 工作流 DSL 文件:
- 功能: [工作流要实现的功能]
- 输入: [用户输入的内容]
- 处理步骤: [详细的处理逻辑]
- 输出: [期望的输出结果]
- 使用插件: [需要的插件,可选]
Dify DSL File Structure
Based on learning from 86+ real workflow cases, Dify DSL YML files follow the structure below:
1. App Configuration
app:
description: '工作流描述'
icon: 🤖
icon_background: '#FFEAD5'
mode: advanced-chat # 或 workflow, agent-chat
name: 工作流名称
use_icon_as_answer_icon: false
Mode Description:
advanced-chat: Advanced chat mode (chatflow)workflow: Workflow modeagent-chat: AI Agent mode
2. Dependencies
dependencies:
- current_identifier: null
type: marketplace
value:
marketplace_plugin_unique_identifier: 插件唯一标识符
Common Plugins:
langgenius/openai_api_compatible: OpenAI-compatible interfacebowenliang123/md_exporter: Markdown exporter- Other marketplace plugins are added as needed
3. Workflow
kind: app
version: 0.3.0
workflow:
conversation_variables: []
environment_variables: []
features:
file_upload:
enabled: false
speech_to_text:
enabled: false
text_to_speech:
enabled: false
graph:
edges: []
nodes: []
Node Type Details
Start Node
- data:
desc: ''
title: 开始
type: start
variables:
- label: 用户输入
max_length: 1000
options: []
required: true
type: paragraph # 或 text-input, select, file
variable: query
id: 'start'
position:
x: 100
y: 300
type: custom
width: 244
height: 90
Variable Types:
paragraph: Paragraph text (multi-line)text-input: Single-line textselect: Dropdown selectionfile: File uploadnumber: Number
LLM Large Language Model Node
- data:
context:
enabled: false
variable_selector: []
model:
completion_params:
temperature: 0.7
max_tokens: 2000
mode: chat
name: gpt-4
provider: openai
prompt_template:
- id: 唯一ID
role: system
text: 系统提示词
- id: 唯一ID
role: user
text: 用户提示词 {{#变量引用#}}
title: LLM节点
type: llm
vision:
enabled: false
id: '节点ID'
position:
x: 400
y: 300
type: custom
Common model providers:
openai: OpenAIlanggenius/openai_api_compatible/openai_api_compatible: Compatible interfaceanthropic: Claudealibaba: Tongyi Qianwen
Variable reference format:
{{#节点ID.输出变量#}}: Reference the output of other nodes{{#sys.query#}}: Reference system variables (user input){{#节点ID.text#}}: Reference LLM output text
Code Execution Node
- data:
code: |
import json
def main(arg1: str, arg2: str) -> dict:
# 处理逻辑
result = process(arg1, arg2)
return {
"result": result,
"status": "success"
}
code_language: python3
outputs:
result:
type: string
status:
type: string
title: 代码执行
type: code
variables:
- value_selector:
- '前置节点ID'
- 输出变量
variable: arg1
id: '节点ID'
position:
x: 700
y: 300
type: custom
Code Language:
python3: Python 3javascript: JavaScript (supported in some versions)
Output Types:
string: Stringnumber: Numberobject: Objectarray[string]: String arrayarray[number]: Number arrayarray[object]: Object array
HTTP Request Node
- data:
authorization:
config: null
type: no-auth
body:
data: '{"key": "{{#变量#}}"}'
type: json
headers: ''
method: post
timeout:
max_connect_timeout: 0
max_read_timeout: 0
max_write_timeout: 0
title: HTTP请求
type: http-request
url: https://api.example.com/endpoint
id: '节点ID'
position:
x: 1000
y: 300
type: custom
HTTP Methods:
get: GET requestpost: POST requestput: PUT requestpatch: PATCH requestdelete: DELETE request
Authentication Types:
no-auth: No authenticationapi-key: API Keybearer: Bearer Token
If-Else Conditional Judgement Node
- data:
cases:
- case_id: case1
conditions:
- comparison_operator: contains
id: 条件ID
value: 期望值
variable_selector:
- '节点ID'
- 变量名
id: case1
logical_operator: and
logical_operator: or
title: 条件判断
type: if-else
id: '节点ID'
position:
x: 1300
y: 300
type: custom
Comparison Operators:
contains: Containsnot contains: Does not containis: Equalsis not: Not equalsempty: Is emptynot empty: Is not empty
Logical Operators:
and: Andor: Or
Tool Node
- data:
provider_id: 工具提供者ID
provider_name: 工具提供者名称
provider_type: builtin # 或 api
title: 工具调用
tool_configurations: {}
tool_label: 工具标签
tool_name: 工具名称
tool_parameters:
参数名:
type: mixed
value: '{{#变量#}}'
type: tool
id: '节点ID'
position:
x: 1600
y: 300
type: custom
Tool Types:
builtin: Built-in tools (such as search, weather, etc.)api: API toolsplugin: Plugin tools
Answer direct reply node
- data:
answer: |
{{#LLM节点ID.text#}}
{{#代码节点ID.result#}}
title: 直接回复
type: answer
variables: []
id: answer
position:
x: 1900
y: 300
type: custom
Variable Aggregator node
- data:
advanced_settings: null
desc: ''
groups:
- group_name: 分组1
output_type: string
variables:
- value_selector:
- '节点ID'
- 变量名
variable: 输出变量名
title: 变量聚合器
type: variable-aggregator
id: '节点ID'
position:
x: 2200
y: 300
type: custom
Parameter Extractor node
- data:
instruction: 提取指令说明
is_array: false
model:
completion_params: {}
mode: chat
name: gpt-4
provider: openai
parameters:
- description: 参数描述
name: 参数名
required: true
type: string
query:
- role: user
text: '{{#输入变量#}}'
reasoning_mode: prompt
title: 参数提取
type: parameter-extractor
id: '节点ID'
position:
x: 2500
y: 300
type: custom
Edges connection relationships
edges:
- data:
isInIteration: false
isInLoop: false
sourceType: start
targetType: llm
id: 源节点ID-source-目标节点ID-target
source: '源节点ID'
sourceHandle: source
target: '目标节点ID'
targetHandle: target
type: custom
zIndex: 0
Connection rules:
- Each node has at most one incoming edge (except the start node)
- A node can have multiple outgoing edges (branch nodes such as if-else)
- Must ultimately connect to the answer node or other output nodes
sourceTypeandtargetTypemust match the actual node type
Position coordinate layout
Recommended layout:
- Starting X: 100
- Node spacing X: 300-400
- Y coordinate: keep on the same horizontal line (300) or adjust appropriately based on branches
- Y coordinate of child nodes of branch nodes: ±150
Example layout:
Start(100,300) → LLM(400,300) → Code(700,300) → Answer(1000,300)
Branch layout:
→ Branch1(1100,150)
If-Else(800,300) →
→ Branch2(1100,450)
Workflow generation steps
1. Requirements analysis
- Understand the user's business requirements
- Determine the workflow type (chatflow/workflow/agent)
- Identify the required node types
- Plan the processing flow
2. Node design
- Design the input variables of the start node
- Plan the prompts for LLM nodes
- Determine the code execution logic
- Configure HTTP request parameters
- Design the output format
3. Flow connection
- Establish the logical relationships between nodes
- Configure variable passing
- Handle conditional branches
- Ensure the flow is closed-loop
4. DSL generation
- Generate YAML format that conforms to the specification
- Configure unique node IDs
- Set reasonable coordinate positions
- Add necessary dependency plugins
5. Verification check
- Check the correctness of the YAML format
- Verify the completeness of variable references
- Confirm the reasonableness of node connections
- Check the completeness of required fields
Learning from real cases
Summary of learning based on 86+ real workflow cases:
Case 1: Image OCR recognition workflow
Requirements: Upload image → OCR recognition → Extract text
Node flow:
- Start(file input) →
- LLM(vision enabled, OCR) →
- Answer(display result)
Key configuration:
- Start node: type: file, allowed_file_types: [image]
- LLM node: vision.enabled: true, vision.configs.variable_selector points to the file variable
- System prompt: "Only output the text information recognized in the image"
Case 2: Text-to-HTML generation workflow
Requirements: Text description → Generate HTML code → Save as file
Node flow:
- Start(text input) →
- LLM(generate HTML) →
- Parameter Extractor(extract HTML code) →
- Tool(md_exporter, save file) →
- Answer(return file URL)
Key configuration:
- LLM prompt: "Generate an HTML program, output only the HTML code"
- Parameter Extractor: Extract the HTML code block
- Tool: Use the md_exporter plugin to save the file
Case 3: Data query visualization workflow
Requirements: User question → SQL query → Chart display
Node flow:
- Start(query input) →
- LLM(generate SQL) →
- HTTP Request(database API) →
- Code(format data) →
- LLM(generate chart HTML) →
- Answer(display chart)
Key configuration:
- LLM1: Text-to-SQL generation
- HTTP: Call the database query API
- Code: Format JSON data into chart data format
- LLM2: Generate ECharts/Chart.js HTML
Case 4: AI Agent workflow
Requirements: Complex task → Agent autonomous planning → Call tools → Return results
Node flow:
- Start(task input) →
- LLM(reasoning, with tools) →
- Multiple Tool nodes(parallel) →
- Variable Aggregator(collect results) →
- LLM(summarize) →
- Answer(final response)
Key configuration:
- mode: agent-chat
- LLM configuration: Enable multiple tools
- Tool parallel execution: Multiple edges from LLM pointing to different Tools
- Variable Aggregator: Aggregate the outputs of multiple Tools
Common prompt templates
Text-to-SQL
你是一个专业的 SQL 专家。根据用户的自然语言问题生成准确的 SQL 查询语句。
数据库schema:
{{#数据库结构#}}
用户问题: {{#sys.query#}}
要求:
1. 只输出 SQL 语句,不要有其他说明
2. 确保 SQL 语法正确
3. 使用合适的 JOIN 和 WHERE 条件
Data extraction
从以下文本中提取指定信息:
文本内容:
{{#输入文本#}}
提取要求:
- 提取所有日期
- 提取所有人名
- 提取所有金额
以 JSON 格式输出:
{
"dates": [],
"names": [],
"amounts": []
}
HTML generation
根据用户需求生成完整的 HTML 页面。
需求: {{#用户需求#}}
要求:
1. 生成完整的 HTML 文档
2. 包含必要的 CSS 样式
3. 添加必要的 JavaScript 交互
4. 确保代码格式规范
5. 只输出 HTML 代码,不要 markdown 代码块标记
Notes
Rules that must be followed
- Unique ID generation: Each node must have a unique ID (recommended to use a timestamp:
1747991890414) - Variable reference format: Must use
{{#节点ID.变量名#}}format - Node type matching: The sourceType and targetType in edges must match the actual node types
- Required fields: Required fields in YAML cannot be omitted
- YAML format: Strictly follow YAML indentation rules (2 spaces)
Avoid common errors
-
❌ Variable reference error:
{{节点ID.变量}}✅ Correct format:{{#节点ID.变量#}} -
❌ Missing node connection: Node is isolated and unconnected ✅ Ensure all nodes have connection relationships in edges
-
❌ Duplicate ID: Multiple nodes use the same ID ✅ Each node uses a unique ID
-
❌ Position overlap: Multiple nodes have the same coordinates ✅ Plan node positions reasonably to avoid overlap
-
❌ Missing dependency: A plugin is used but not declared in dependencies ✅ When using a plugin, the corresponding dependency must be added
Output format
The generated DSL file must be a complete YAML format that can be directly imported into Dify:
app:
# App 配置
dependencies:
# 依赖列表
kind: app
version: 0.3.0
workflow:
conversation_variables: []
environment_variables: []
features:
# 功能配置
graph:
edges:
# 连接关系
nodes:
# 节点定义
Quality standards
Qualified standards (mandatory)
- ✅ YAML format is correct and can be parsed
- ✅ Includes complete app, dependencies, and workflow configuration
- ✅ Includes at least start and answer nodes
- ✅ Nodes have correct connection relationships
- ✅ Variable reference format is correct
- ✅ All required fields are complete
Excellent standards (recommended)
- 🌟 Prompt design is professional and meets business needs
- 🌟 Node layout is visually appealing and logic is clear
- 🌟 Includes appropriate error handling (if-else judgment)
- 🌟 Uses suitable plugins to enhance functionality
- 🌟 Code execution nodes are highly robust
- 🌟 Variable naming is semantic
Trigger keywords
Keywords that automatically trigger the dify-dsl-generator skill:
- "Generate Dify workflow"
- "Create Dify DSL"
- "Dify YML file"
- "Workflow configuration file"
Update log
v1.0.0 (2025-11-22)
- ✅ Initial version
- ✅ Based on learning from 86+ real cases
- ✅ Supports all major node types
- ✅ Complete DSL generation capability
- ✅ Intelligent node connection
- ✅ Standardized format output
Technical support
Reference resources:
- Dify GitHub: https://github.com/langgenius/dify
- DSL example repository: https://github.com/wwwzhouhui/dify-for-dsl
- Dify official documentation: https://docs.dify.ai