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-generator

Tags

Translated version includes tags in frontmatter

SKILL.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: false
Mode Explanation:
  • advanced-chat
    : Advanced chat mode (chatflow)
  • workflow
    : Workflow mode
  • agent-chat
    : AI Agent mode

2. Dependencies

yaml
dependencies:
- current_identifier: null
  type: marketplace
  value:
    marketplace_plugin_unique_identifier: Plugin unique identifier
Common Plugins:
  • langgenius/openai_api_compatible
    : OpenAI compatible interface
  • bowenliang123/md_exporter
    : Markdown 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: 90
Variable Types:
  • paragraph
    : Paragraph text (multi-line)
  • text-input
    : Single-line text
  • select
    : Dropdown selection
  • file
    : File upload
  • 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: custom
Common Model Providers:
  • openai
    : OpenAI
  • langgenius/openai_api_compatible/openai_api_compatible
    : Compatible interface
  • anthropic
    : Claude
  • alibaba
    : Tongyi Qianwen
Variable Reference Format:
  • {{#Node ID.output variable#}}
    : Reference output of other nodes
  • {{#sys.query#}}
    : Reference system variables (user input)
  • {{#Node ID.text#}}
    : Reference LLM output 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: custom
Code Languages:
  • python3
    : Python 3
  • javascript
    : JavaScript (supported in some versions)
Output Types:
  • string
    : String
  • number
    : Number
  • object
    : Object
  • array[string]
    : String array
  • array[number]
    : Number array
  • array[object]
    : Object array

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: custom
HTTP Methods:
  • get
    : GET request
  • post
    : POST request
  • put
    : PUT request
  • patch
    : PATCH request
  • delete
    : DELETE request
Authentication Types:
  • no-auth
    : No authentication
  • api-key
    : API Key
  • bearer
    : Bearer Token

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: custom
Comparison Operators:
  • contains
    : Contains
  • not contains
    : Does not contain
  • is
    : Equals
  • is not
    : Does not equal
  • empty
    : Is empty
  • not empty
    : Is 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: custom
Tool Types:
  • builtin
    : Built-in tools (such as search, weather, etc.)
  • api
    : API tools
  • plugin
    : Plugin tools

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: custom

Variable 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: custom

Parameter 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: custom

Edges 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: 0
Connection Rules:
  1. Each node can have at most one incoming edge (except the start node)
  2. Nodes can have multiple outgoing edges (branch nodes like if-else)
  3. Must eventually connect to an answer node or other output node
  4. sourceType
    and
    targetType
    must match the actual node types

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:
  1. Start(file input) →
  2. LLM(vision enabled, OCR) →
  3. 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:
  1. Start(text input) →
  2. LLM(generate HTML) →
  3. Parameter Extractor(extract HTML code) →
  4. Tool(md_exporter, save file) →
  5. 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:
  1. Start(query input) →
  2. LLM(generate SQL) →
  3. HTTP Request(database API) →
  4. Code(format data) →
  5. LLM(generate chart HTML) →
  6. 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:
  1. Start(task input) →
  2. LLM(reasoning, with tools) →
  3. Multiple Tool nodes(parallel) →
  4. Variable Aggregator(collect results) →
  5. LLM(summarize) →
  6. 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 conditions

Data 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 markers

Notes

Mandatory Rules

  1. Unique ID Generation: Each node must have a unique ID (recommended to use timestamp:
    1747991890414
    )
  2. Variable Reference Format: Must use
    {{#Node ID.variable name#}}
    format
  3. Node Type Matching: sourceType and targetType in edges must match the actual node types
  4. Required Fields: Cannot omit required fields in YAML
  5. YAML Format: Strictly follow YAML indentation specifications (2 spaces)

Common Error Avoidance

  1. ❌ Wrong variable reference:
    {{Node ID.variable}}
    ✅ Correct format:
    {{#Node ID.variable#}}
  2. ❌ Missing node connections: Isolated unconnected nodes ✅ Ensure all nodes have connection relationships in edges
  3. ❌ Duplicate IDs: Multiple nodes using the same ID ✅ Use unique IDs for each node
  4. ❌ Position overlap: Multiple nodes with the same coordinates ✅ Plan node positions reasonably to avoid overlap
  5. ❌ 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 definitions

Quality 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: