dify-dsl-generator
Original:🇨🇳 Chinese
Translated
Professional Dify Workflow DSL/YML File Generator, automatically generates complete Dify workflow configuration files based on user business requirements, supporting various node types and complex workflow logic
14installs
Added on
NPX Install
npx skill4agent add wwwzhouhui/skills_collection dify-dsl-generatorTags
Translated version includes tags in frontmatterSKILL.md Content (Chinese)
View Translation Comparison →Dify DSL Workflow Generator
Professional automatic generation tool for Dify workflow DSL/YML files. Based on deep learning of 86+ actual workflow cases, it can automatically generate complete Dify-compliant workflow configuration files according to user business requirements.
Core Features
- ✅ Complete DSL Generation: Automatically generates complete YML files including app, dependencies, and workflow
- ✅ Multi-node Support: Supports all node types such as start, llm, answer, code, http-request, if-else, tool
- ✅ Smart Connection: Automatically generates edge connections between nodes
- ✅ Parameter Configuration: Intelligently recommends model parameters and prompt configurations
- ✅ Plugin Integration: Automatically identifies and configures required Dify plugin dependencies
- ✅ Standard Format: Strictly follows Dify 0.3.0 version DSL specifications
Usage
Basic Usage
Generate a Dify workflow for [business requirement description]Detailed Usage
Help me generate a Dify workflow DSL file:
- Function: [Function to be implemented by the workflow]
- Input: [User input content]
- Processing Steps: [Detailed processing logic]
- Output: [Expected output results]
- Plugins Used: [Required plugins, optional]Dify DSL File Structure
Based on learning from 86+ real workflow cases, Dify DSL YML files follow the following structure:
1. App Configuration
yaml
app:
description: 'Workflow description'
icon: 🤖
icon_background: '#FFEAD5'
mode: advanced-chat # or workflow, agent-chat
name: Workflow Name
use_icon_as_answer_icon: falseMode Explanation:
- : Advanced chat mode (chatflow)
advanced-chat - : Workflow mode
workflow - : AI Agent mode
agent-chat
2. Dependencies
yaml
dependencies:
- current_identifier: null
type: marketplace
value:
marketplace_plugin_unique_identifier: Plugin unique identifierCommon Plugins:
- : OpenAI compatible interface
langgenius/openai_api_compatible - : Markdown exporter
bowenliang123/md_exporter - Add other marketplace plugins as needed
3. Workflow
yaml
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
yaml
- data:
desc: ''
title: Start
type: start
variables:
- label: User Input
max_length: 1000
options: []
required: true
type: paragraph # or text-input, select, file
variable: query
id: 'start'
position:
x: 100
y: 300
type: custom
width: 244
height: 90Variable Types:
- : Paragraph text (multi-line)
paragraph - : Single-line text
text-input - : Dropdown selection
select - : File upload
file - : Number
number
LLM Node
yaml
- 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: Unique ID
role: system
text: System prompt
- id: Unique ID
role: user
text: User prompt {{#variable reference#}}
title: LLM Node
type: llm
vision:
enabled: false
id: 'Node ID'
position:
x: 400
y: 300
type: customCommon Model Providers:
- : OpenAI
openai - : Compatible interface
langgenius/openai_api_compatible/openai_api_compatible - : Claude
anthropic - : Tongyi Qianwen
alibaba
Variable Reference Format:
- : Reference output of other nodes
{{#Node ID.output variable#}} - : Reference system variables (user input)
{{#sys.query#}} - : Reference LLM output text
{{#Node ID.text#}}
Code Execution Node
yaml
- data:
code: |
import json
def main(arg1: str, arg2: str) -> dict:
# Processing logic
result = process(arg1, arg2)
return {
"result": result,
"status": "success"
}
code_language: python3
outputs:
result:
type: string
status:
type: string
title: Code Execution
type: code
variables:
- value_selector:
- 'Previous Node ID'
- Output variable
variable: arg1
id: 'Node ID'
position:
x: 700
y: 300
type: customCode Languages:
- : Python 3
python3 - : JavaScript (supported in some versions)
javascript
Output Types:
- : String
string - : Number
number - : Object
object - : String array
array[string] - : Number array
array[number] - : Object array
array[object]
HTTP Request Node
yaml
- data:
authorization:
config: null
type: no-auth
body:
data: '{"key": "{{#variable#}}"}'
type: json
headers: ''
method: post
timeout:
max_connect_timeout: 0
max_read_timeout: 0
max_write_timeout: 0
title: HTTP Request
type: http-request
url: https://api.example.com/endpoint
id: 'Node ID'
position:
x: 1000
y: 300
type: customHTTP Methods:
- : GET request
get - : POST request
post - : PUT request
put - : PATCH request
patch - : DELETE request
delete
Authentication Types:
- : No authentication
no-auth - : API Key
api-key - : Bearer Token
bearer
If-Else Node
yaml
- data:
cases:
- case_id: case1
conditions:
- comparison_operator: contains
id: Condition ID
value: Expected value
variable_selector:
- 'Node ID'
- Variable name
id: case1
logical_operator: and
logical_operator: or
title: Condition Judgment
type: if-else
id: 'Node ID'
position:
x: 1300
y: 300
type: customComparison Operators:
- : Contains
contains - : Does not contain
not contains - : Equals
is - : Does not equal
is not - : Is empty
empty - : Is not empty
not empty
Logical Operators:
- : AND
and - : OR
or
Tool Node
yaml
- data:
provider_id: Tool Provider ID
provider_name: Tool Provider Name
provider_type: builtin # or api
title: Tool Call
tool_configurations: {}
tool_label: Tool Label
tool_name: Tool Name
tool_parameters:
Parameter name:
type: mixed
value: '{{#variable#}}'
type: tool
id: 'Node ID'
position:
x: 1600
y: 300
type: customTool Types:
- : Built-in tools (such as search, weather, etc.)
builtin - : API tools
api - : Plugin tools
plugin
Answer Node
yaml
- data:
answer: |
{{#LLM Node ID.text#}}
{{#Code Node ID.result#}}
title: Direct Response
type: answer
variables: []
id: answer
position:
x: 1900
y: 300
type: customVariable Aggregator Node
yaml
- data:
advanced_settings: null
desc: ''
groups:
- group_name: Group 1
output_type: string
variables:
- value_selector:
- 'Node ID'
- Variable name
variable: Output variable name
title: Variable Aggregator
type: variable-aggregator
id: 'Node ID'
position:
x: 2200
y: 300
type: customParameter Extractor Node
yaml
- data:
instruction: Extraction instruction description
is_array: false
model:
completion_params: {}
mode: chat
name: gpt-4
provider: openai
parameters:
- description: Parameter description
name: Parameter name
required: true
type: string
query:
- role: user
text: '{{#Input variable#}}'
reasoning_mode: prompt
title: Parameter Extraction
type: parameter-extractor
id: 'Node ID'
position:
x: 2500
y: 300
type: customEdges Connections
yaml
edges:
- data:
isInIteration: false
isInLoop: false
sourceType: start
targetType: llm
id: Source Node ID-source-Target Node ID-target
source: 'Source Node ID'
sourceHandle: source
target: 'Target Node ID'
targetHandle: target
type: custom
zIndex: 0Connection Rules:
- Each node can have at most one incoming edge (except the start node)
- Nodes can have multiple outgoing edges (branch nodes like if-else)
- Must eventually connect to an answer node or other output node
- and
sourceTypemust match the actual node typestargetType
Position Layout
Recommended Layout:
- Starting X: 100
- Node spacing X: 300-400
- Y coordinate: Keep on the same horizontal line (300) or adjust appropriately according to branches
- Y coordinate of branch node children: ±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. Requirement Analysis
- Understand user business requirements
- Determine workflow type (chatflow/workflow/agent)
- Identify required node types
- Plan processing flow
2. Node Design
- Design input variables for the start node
- Plan prompts for LLM nodes
- Determine code execution logic
- Configure HTTP request parameters
- Design output format
3. Flow Connection
- Establish logical relationships between nodes
- Configure variable passing
- Handle conditional branches
- Ensure closed-loop flow
4. DSL Generation
- Generate compliant YAML format
- Configure unique node IDs
- Set reasonable coordinate positions
- Add necessary dependency plugins
5. Verification Check
- Check YAML format correctness
- Verify variable reference integrity
- Confirm node connection rationality
- Check completeness of required fields
Practical Case Studies
Summary based on learning from 86+ real workflow cases:
Case 1: Image OCR Recognition Workflow
Requirement: Upload image → OCR recognition → Extract text
Node Flow:
- Start(file input) →
- LLM(vision enabled, OCR) →
- Answer(display result)
Key Configurations:
- Start node: type: file, allowed_file_types: [image]
- LLM node: vision.enabled: true, vision.configs.variable_selector points to file variable
- System prompt: "Only output the text information recognized from the image"
Case 2: Text to HTML Generation Workflow
Requirement: 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 Configurations:
- LLM prompt: "Generate HTML program, only output HTML code"
- Parameter Extractor: Extract HTML code blocks
- Tool: Use md_exporter plugin to save files
Case 3: Data Query Visualization Workflow
Requirement: 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 Configurations:
- LLM1: Text-to-SQL generation
- HTTP: Call database query API
- Code: Format JSON data into chart data format
- LLM2: Generate ECharts/Chart.js HTML
Case 4: AI Agent Workflow
Requirement: 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 Configurations:
- mode: agent-chat
- LLM configuration: Enable multiple tools
- Tool parallel execution: Multiple edges from LLM to different Tools
- Variable Aggregator: Aggregate outputs from multiple Tools
Common Prompt Templates
Text-to-SQL
You are a professional SQL expert. Generate accurate SQL query statements based on user natural language questions.
Database schema:
{{#Database structure#}}
User question: {{#sys.query#}}
Requirements:
1. Only output SQL statements, no other explanations
2. Ensure correct SQL syntax
3. Use appropriate JOIN and WHERE conditionsData Extraction
Extract specified information from the following text:
Text content:
{{#Input text#}}
Extraction requirements:
- Extract all dates
- Extract all names
- Extract all amounts
Output in JSON format:
{
"dates": [],
"names": [],
"amounts": []
}HTML Generation
Generate complete HTML pages based on user requirements.
Requirement: {{#User requirement#}}
Requirements:
1. Generate complete HTML documents
2. Include necessary CSS styles
3. Add necessary JavaScript interactions
4. Ensure standardized code format
5. Only output HTML code, no markdown code block markersNotes
Mandatory Rules
- Unique ID Generation: Each node must have a unique ID (recommended to use timestamp: )
1747991890414 - Variable Reference Format: Must use format
{{#Node ID.variable name#}} - Node Type Matching: sourceType and targetType in edges must match the actual node types
- Required Fields: Cannot omit required fields in YAML
- YAML Format: Strictly follow YAML indentation specifications (2 spaces)
Common Error Avoidance
-
❌ Wrong variable reference:✅ Correct format:
{{Node ID.variable}}{{#Node ID.variable#}} -
❌ Missing node connections: Isolated unconnected nodes ✅ Ensure all nodes have connection relationships in edges
-
❌ Duplicate IDs: Multiple nodes using the same ID ✅ Use unique IDs for each node
-
❌ Position overlap: Multiple nodes with the same coordinates ✅ Plan node positions reasonably to avoid overlap
-
❌ Missing dependencies: Using plugins without declaring in dependencies ✅ Must add corresponding dependency when using plugins
Output Format
Generated DSL files must be complete YAML formats that can be directly imported into Dify:
yaml
app:
# App configuration
dependencies:
# Dependency list
kind: app
version: 0.3.0
workflow:
conversation_variables: []
environment_variables: []
features:
# Feature configuration
graph:
edges:
# Connection relationships
nodes:
# Node definitionsQuality Standards
Qualification Standards (Mandatory)
- ✅ Correct YAML format, parsable
- ✅ Contains complete app, dependencies, workflow configurations
- ✅ At least includes start and answer nodes
- ✅ Correct connection relationships between nodes
- ✅ Correct variable reference format
- ✅ All required fields are complete
Excellence Standards (Recommended)
- 🌟 Professional prompt design that meets business needs
- 🌟 Beautiful node layout with clear logic
- 🌟 Includes appropriate error handling (if-else judgments)
- 🌟 Uses suitable plugins to enhance functionality
- 🌟 Robust code execution nodes
- 🌟 Semantic variable naming
Trigger Keywords
Keywords that automatically trigger the dify-dsl-generator skill:
- "Generate Dify workflow"
- "Create Dify DSL"
- "Dify YML file"
- "Workflow configuration file"
Changelog
v1.0.0 (2025-11-22)
- ✅ Initial version
- ✅ Based on learning from 86+ real cases
- ✅ Supports all major node types
- ✅ Complete DSL generation capability
- ✅ Smart node connection
- ✅ Standard format output
Technical Support
Reference Resources:
- Dify GitHub: https://github.com/langgenius/dify
- DSL Case Repository: https://github.com/wwwzhouhui/dify-for-dsl
- Dify Official Documentation: https://docs.dify.ai