SuperAPI AI Directory

dify_creator

Agents & models

View repository

Updated 10-16 01:31

About this skill

Dify Workflow Generator (dify_creator)

Guide users to clarify their requirements through multi-turn conversations,refer to organized_dsl/ existing cases in the directory, generate a DSL YAML file that conforms to the corresponding Dify version specification, and can be directly imported into Dify for use.

⚠️ Important: You must switch to the skill directory before searching for files!

cd "c:\Users\14429\.claude\skills\dify_creator"

Then search for organized_dsl/INDEX.mdand organized_dsl/**/*.yml

Core Capabilities

  • Intelligent Conversation Guidance: Help users sort out their requirements through questioning, avoiding omission of key information
  • Case Reference Location: Based on the INDEX.md index, automatically match similar Dify cases
  • Workflow Structure Design: After analyzing the requirements, provide the process structure and confirm it with the user
  • Complete DSL Generation: Refer to the DSL node guide to generate a complete YAML configuration that conforms to the specification

Use Cases

  • Create intelligent customer service conversation flows
  • Build RAG knowledge base question-answering systems
  • Design audio and video processing workflows
  • Develop code generation and document processing tools
  • Build complex workflows with multi-model collaboration

Workflow Overview

用户需求 → 案例定位 → 流程设计 → 用户确认 → DSL生成 → 交付

Core Steps

Step Name Output
Step 1 Collect Requirements Requirements Document
Step 2 Case Location Reference Case List
Step 3 Process Design Process Structure Diagram
Step 4 User Confirmation Confirmation Feedback
Step 5 DSL Generation Complete YAML File

Step 1: Collect User Requirements

First, ask the user for basic information to clarify the goals and functions of the workflow.

1.1 Basic Information Collection

请告诉我关于你要创建的 Dify 工作流的基本信息:

1. **工作流名称**(英文,使用连字符,如:document-processor)
2. **一句话描述**:这个工作流做什么?
3. **应用类型**:
   - workflow:批处理任务,单轮执行
   - advanced-chat:高级聊天模式,支持多轮对话
   - chatflow:对话式应用,简单多轮交互
4. **目标用户**:谁会使用这个工作流?

1.2 Functional Requirements Collection

Based on the application type selected by the user, ask in depth about functional requirements:

General Questions:

5. **输入方式**:用户如何提供输入?
   - 文本输入(短文本/长文本)
   - 文件上传(图片/PDF/音视频/文档)
   - 混合输入

6. **核心处理**:工作流需要执行哪些处理步骤?
   - 数据预处理 → 核心处理 → 结果输出
   - 请尽可能描述每个步骤

7. **输出形式**:最终返回什么结果?
   - 文本回复
   - 结构化数据(JSON/Markdown表格)
   - 文件(图片/PDF/音频)
   - 混合输出

Supplement Based on Function Type:

Function Type Supplementary Questions
RAG Q&A Knowledge base source? Retrieval strategy (keyword/vector)? Number of recalls? Is reranking needed?
Audio and Video Processing Audio extraction? Speech recognition (ASR)? Content summarization? Subtitle generation?
Document Processing PDF parsing? Content extraction? Format conversion? OCR recognition?
Image Generation Text-to-image? Image-to-image? Style transfer? Is multi-image composition needed?
Data Processing Data source (API/database/file)? Analysis dimensions? Chart type?
Tool Invocation Which tools/plugins are used? Invocation frequency? Is MCP needed?
Multi-Model Collaboration Which models are called? What is the division of labor? How is information passed between models?

1.3 Model and Tool Configuration

8. **大模型选择**:
   - 模型提供商:OpenAI / Anthropic / 国内模型(硅基流动/通义千问/零一万物等)
   - 模型名称:如 gpt-4o, deepseek-V3, qwen-max
   - 参数设置:temperature(创意度 0-1)、max_tokens 等

9. **工具/插件**:
   - 内置工具:代码执行、知识检索、HTTP请求、TTS等
   - 第三方插件:PDF处理、数据库连接等
   - MCP服务:是否需要集成外部MCP工具?

10. **知识库(可选)**:
    - 是否需要接入知识库?
    - 知识库ID和名称
    - 检索策略配置

1.4 Process Control Inquiry

11. **流程分支**:是否有条件分支?(是/否)
    - 如果是,分支条件是什么?(例如:根据用户意图分类走不同处理路径)
12. **循环处理**:是否需要迭代处理批量数据?(是/否)
    - 例如:批量处理多个文件、对列表中每项进行处理
13. **会话状态**:是否需要保存会话状态?(是/否)
    - 例如:记录用户偏好、跨轮次变量传递
14. **错误处理**:失败时如何处理?
    - 终止流程并报错
    - 继续执行其他分支
    - 返回默认结果

Step 2: Case Location (Based on INDEX.md)

Based on the collected requirements, locate similar cases in organized_dsl/INDEX.md .

2.0 Search Path Configuration

⚠️ **关键步骤:搜索前必须先切换到技能目录!**

**第一步:切换到技能目录(必须执行)**
```bash
cd "c:\Users\14429\.claude\skills\dify_creator"

Step 2: Search DSL Files

  • Search organized_dsl/**/*.yml(search under the skill directory)

Step 3: Search Index Files

  • Search organized_dsl/INDEX.md
  • Search organized_dsl/Dify_DSL_节点完整参考指南.md

Incorrect Approach:

  • ❌ Search **/*.ymldirectly (the current directory may be wrong)
  • ❌ Search **/organized_dsl/**/*.yml(path duplication)
  • ❌ Search **/*.yaml(the file is .yml, not .yaml)
  • ❌ Search organized_dsl/**/*.ymlin other directories (it will not be found)

Correct Approach:

  1. First execute cd "c:\Users\14429\.claude\skills\dify_creator"
  2. then search organized_dsl/**/*.yml
  3. then search organized_dsl/INDEX.md

### 2.1 读取 INDEX.md 索引

首先读取索引文件了解案例分类:

```markdown
1. 搜索并读取 `organized_dsl/INDEX.md`
2. 根据用户需求的功能类型,定位相关分类目录
3. 在对应目录中搜索相似功能的 DSL 案例(使用 `organized_dsl/**/*.yml`)

2.2 Category Location

Find the corresponding directory according to the functional type:

根据你的需求,我定位到以下相关分类:

| 分类 | 目录路径 |
|------|----------|
| 内容创作 | `01_内容生成与创作/` |
| 图像生成 | `02_图像生成与设计/` |
| 视频生成 | `03_视频生成/` |
| 数据分析 | `04_数据分析与可视化/` |
| 文档处理 | `05_文档处理与OCR/` |
| 知识库RAG | `06_知识库与RAG/` |
| Agent工具 | `07_Agent与工具调用/` |
| 教育学习 | `08_教育与学习/` |
| 商业办公 | `09_商业与办公/` |
| 多媒体处理 | `10_多媒体处理/` |
| 代码开发 | `11_代码与开发/` |
| 创意娱乐 | `12_创意与娱乐/` |

2.3 Complexity Matching

Match complexity according to the number of nodes:

Complexity Number of Nodes Applicable Scenarios
Simple 3-5 Single function, linear flow
Medium 6-15 Multi-step processing with branches
Complex 16+ Multi-module collaboration, loop processing

2.4 Output Reference Case List

找到以下与你需求相关的参考案例:

### 📂 案例1:[案例名称]
- **位置**:`目录路径/文件名.yml`
- **复杂度**:简单/中等/复杂
- **节点数**:X个
- **主要节点**:start → llm → answer
- **参考价值**:节点结构、Prompt模板、流程设计

### 📂 案例2:[案例名称]
...

请确认:
- 是否需要查看更多相似案例?
- 哪些案例的结构最符合你的需求?

2.5 Read and Analyze Reference Cases

After selecting a reference case, read the DSL file for analysis:

我已读取参考案例,以下是关键配置提取:

**节点结构:**

[Start Node] ↓ [LLM Node] - Model: xxx, Prompt: xxx ↓ [Tool Node] - Tool: xxx ↓ [Output Node]


**关键配置参考:**
- LLM prompt模板:...
- 变量传递方式:...
- 条件分支逻辑:...

Step 3: Workflow Structure Design

Design the workflow structure based on the requirement analysis and reference cases.

3.1 Design Principles

  1. KISS Principle: Keep it simple, avoid over-design
  2. Modularization: Split complex processes into reusable steps
  3. Clear Variables: Use meaningful variable names for easy tracking

3.2 Output the Process Structure Diagram

根据你的需求,我设计了以下工作流结构:

## 📊 流程结构图

┌─────────────┐ │ Start Node │ Input: {{input_var}} └──────┬──────┘ ↓ ┌─────────────┐ │ Preprocessing Node │ Function: data cleaning/format conversion └──────┬──────┘ ↓ ┌─────────────┐ │ Core Processing │ Function: LLM call/tool execution │ (Branch Judgment) │ Condition: {{condition}} └──────┬──────┘ ┌────┴────┐ ↓ ↓ ┌──────┐ ┌──────┐ │Branch A │ │Branch B │ └────┬─┘ └────┬─┘ │ │ └────┬─────┘ ↓ ┌─────────────┐ │ Result Processing │ Function: formatting/aggregation └──────┬──────┘ ↓ ┌─────────────┐ │ Output Node │ Output: {{output_var}} └─────────────┘


## 📋 节点列表

| 序号 | 节点名称 | 节点类型 | 功能描述 | 输入变量 | 输出变量 |
|------|---------|---------|---------|---------|---------|
| 1 | 开始 | start | 接收用户输入 | - | user_input |
| 2 | 预处理 | code | 数据清洗 | user_input | clean_data |
| 3 | LLM处理 | llm | 生成内容 | clean_data | llm_result |
| 4 | 条件判断 | if-else | 分支处理 | llm_result | branch |
| 5 | 输出 | answer | 返回结果 | final_result | - |

## 📝 关键配置

**LLM配置:**
- 模型:xxx
- Prompt模板:xxx

**变量传递:**
- 上游输出 → 下游输入

Step 4: User Confirmation (⚠️ Required Step)

Warning: Do not generate DSL before obtaining explicit user confirmation!

Show the structure design to the user, and you must obtain the following confirmations before continuing:

4.1 Confirmation Content

## 工作流结构确认 ⚠️

在生成 DSL 文件之前,请确认以下设计:

### ✅ 流程结构
- 节点数量:X 个
- 流程分支:X 条
- 循环处理:X 处

### ✅ 节点配置
1. [节点1]:确认配置 ✓
2. [节点2]:需要调整 →
3. [节点3]:确认配置 ✓

### ✅ 待确认事项
1. 模型选择是否正确?
2. Prompt模板是否需要调整?
3. 分支条件是否合理?
4. 输出格式是否满足需求?

**请回复「确认」或「继续」以生成 DSL,或提供修改意见。**

4.2 Confirmation Checklist

生成 DSL 前必须确认以下全部项目:

- [ ] 用户明确回复「确认」或「继续」
- [ ] 所有节点配置已与用户核对
- [ ] 模型和参数已获用户认可
- [ ] 输出格式符合用户需求

**未满足上述条件,禁止跳到 Step 5!**

4.3 Iterative Adjustment

If the user has revision suggestions, iterate and adjust until confirmed:

根据你的反馈,我进行了以下调整:

1. 修改了 LLM 节点 Prompt 模板
2. 添加了新的条件分支
3. 调整了变量传递逻辑

请再次确认。

Step 5: Generate the complete DSL (⚠️ Must reference examples)

Before generating the DSL, the following steps must be completed:

  1. ✅ Already switched to the skill directory:cd "c:\Users\14429\.claude\skills\dify_creator"
  2. ✅ Already read and analyzed the reference examples in Step 2
  3. ✅ Already obtained explicit user confirmation in Step 4
  4. ✅ Already read organized_dsl/Dify_DSL_节点完整参考指南.md

5.1 Pre-check

生成 DSL 前确认:

- [ ] 已选定参考案例文件(路径:xxx/xxx.yml)
- [ ] 已读取节点配置参考指南
- [ ] 已获得用户「确认」回复
- [ ] 所有节点配置已确定

**未完成以上步骤,禁止生成 DSL!**

5.2 Generate Structure

app:
  description: '{{description}}'
  icon: '{{icon}}'
  icon_background: '{{icon_background}}'
  mode: '{{mode}}'
  name: '{{name}}'
  use_icon_as_answer_icon: false
kind: app
version: {{参考案例的版本号}}
workflow:
  conversation_variables: []
  environment_variables: []
  features:
    file_upload: {}
    # ... 其他功能配置
  graph:
    edges: []
    nodes: []
  viewport: {}

5.3 Node ID Generation Rules

  • Use timestamp + random number as the node ID
  • Format:{时间戳}{随机6位数字}
  • Example:1741011655068, 1735195133945

5.4 Position Calculation

The position of nodes on the canvas is automatically calculated based on the process order:

  • X coordinate: each additional node moves about 300px to the right
  • Y coordinate: uniformly centered or adjusted according to branches

5.5 Complete Output Example

# ============================================
# Dify 工作流 DSL 文件
# 名称:xxx
# 生成时间:2026-01-03
# 参考案例:xxx.yml
# ============================================

app:
  description: '工作流描述'
  icon: 🤖
  icon_background: '#FFEAD5'
  mode: workflow
  name: xxx
kind: app
version: {{参考案例的版本号}}
workflow:
  graph:
    edges:
    # ... 连接配置
    nodes:
    # ... 节点配置

⚠️ 5.6 Node Writing Rules (Important!)

Each node must be written by referring to the example format in the organized_dsl case library!

生成工作流时,请严格遵循以下规则:

1. **先查找参考案例**
   - 搜索 `organized_dsl/**/*.yml` 找到相似功能的 DSL 文件
   - 搜索 `organized_dsl/Dify_DSL_节点完整参考指南.md` 查看节点配置说明

2. **节点结构必须完整**
   每个节点必须包含:
   - `id`: 唯一标识
   - `data.type`: 节点类型
   - `data.title`: 节点标题
   - `position`: 画布位置 {x, y}
   - `width`/`height`: 节点尺寸(可选)

3. **禁止凭空编写**
   - ❌ 不要凭记忆或想象编写节点
   - ✅ 必须复制参考案例的结构,替换关键字段

4. **特别注意事项**
   - **迭代节点**:必须包含 iteration-start 子节点和所有必要标记
   - **LLM 节点**:必须包含 model.provider、model.name、prompt_template
   - **HTTP 请求**:必须包含正确的 authorization 和 body 配置
   - **变量引用**:必须使用 `{{#节点ID.变量#}}` 格式

⚠️ 5.7 Mandatory Check After Generation (❗Must be executed)

After generating the DSL, each node must be mandatorily checked according to the following steps!

## DSL 生成后强制检查 ⚠️

**警告:未完成检查,禁止交付给用户!**

### 第一步:确定版本号
```yaml
version: {{参考案例的版本号}}  # ✅ 与参考案例保持一致

Key points: The version number should be consistent with the selected reference example, not a fixed value.

Step 2: Traverse each node and check it one by one against the reference examples

For each generated node, perform the following checks:

  1. Find a node of the same type in the reference example

    cd "c:\Users\14429\.claude\skills\dify_creator"
    rg "type: 节点类型" organized_dsl/**/*.yml | head -20
    
  2. Read the node structure in the reference example

    • Open the corresponding DSL file
    • Find the node configuration of the same type
  3. Compare field by field

    Field Reference Example Generated Result Correct or Not
    data.positionAbsolute false ?
    data.selected false ?
    height 52 ?
    width 242 ?
    ... ... ...
  4. Mark differences and correct them

    • If any difference is found, correct it immediately
    • For fields that cannot be determined, use the original value from the reference example

Step 3: Edge Connection Check

Traverse each edge and check the following fields:

  • data.sourceType: Source node type
  • data.targetType: Target node type
  • data.selected: false
  • data.isInIteration: false (outside iteration)
  • type: custom/true/false/isInIteration

Step 4: Focused Check on Special Nodes

Node Type Check Focus
variable-aggregator output_type + variables Array (not outputs/formatter_template)
end type: end + outputs(not type: answer)
iteration start_node_id points to iteration-start
llm model.provider, model.name, prompt_template
http-request authorization, body Configuration complete

Step 5: Check Report

## DSL 检查报告

### 节点检查结果
| 节点ID | 节点类型 | 检查状态 | 问题 |
|--------|---------|---------|------|
| xxx | start | ✅ 通过 | 无 |
| xxx | llm | ❌ 失败 | 缺少 model.provider |

### 边检查结果
| 边ID | 类型 | 检查状态 | 问题 |
|------|-----|---------|------|
| xxx | custom | ✅ 通过 | 无 |

### 最终结论
- [ ] 所有节点检查通过
- [ ] 所有边检查通过
- [ ] 无需修正,可以交付

Handling when the check fails:

  1. Locate the problematic node
  2. Read the reference example
  3. Correct the node configuration
  4. Re-check until it passes

---

## Dify DSL 结构规范

### 完整结构模板

```yaml
app:
  description: '应用描述'
  icon: 🤖
  icon_background: '#FFEAD5'
  mode: workflow|advanced-chat|chatflow
  name: 应用名称
  use_icon_as_answer_icon: false
kind: app
version: {{参考案例的版本号}}
workflow:
  conversation_variables: []   # 会话变量
  environment_variables: []    # 环境变量
  features:
    file_upload:               # 文件上传配置
      enabled: false
      # ... 详细配置
    opening_statement: ''      # 开场白
    retriever_resource:        # 检索资源
      enabled: true
    text_to_speech:            # TTS配置
      enabled: false
  graph:
    edges: []                  # 连线列表
    nodes: []                  # 节点列表
  viewport:                    # 视图位置
    x: 0
    y: 0
    zoom: 1
dependencies: []               # 插件依赖

Node Type Description

Node Type Purpose Key Configuration
start Start node variables (input variable definitions)
llm Large language model model、prompt_template、vision、context
answer Chatflow direct reply answer (output template), only used for conversational applications
knowledge-retrieval Knowledge base retrieval dataset_ids、query_variable_selector
tool Tool invocation provider_id、tool_name、tool_parameters
code Code Execution code、code_language、outputs、variables
http-request HTTP Request method、url、authorization、body
if-else Conditional Branch cases (condition evaluation)
template-transform Template Transformation template、variables
assigner Write to Conversation Variable items、write_mode
variable-aggregator Aggregate Multi-Branch Outputs variables, output_type (not simple integration!)
iteration ⚠️ Loop Processing iterator_selector、output_selector、start_node_id (required!)
document-extractor Document Extraction variable_selector、is_array_file
agent Agent agent_parameters、agent_strategy_name
end Workflow End Node outputs (output variables), only used for workflows

Variable Reference Syntax

# 引用格式:{{#节点ID.输出字段#}}

# 引用开始节点的输入
{{#1742961448129.file#}}

# 引用 LLM 节点的文本输出
{{#1742965550311.text#}}

# 引用 Code 节点的自定义输出
{{#1747670104835.result#}}

# 引用会话变量
{{#conversation.status#}}

# 引用环境变量
{{#env.API_KEY#}}

⚠️ Iteration Node Specification (Critical!)

The iteration node is the most error-prone part of the DSL; missing any item will cause the import to fail!

Complete Iteration Node Structure

# 1. iteration 节点 - 循环控制器
- id: '1741011600006'
  data:
    iterator_selector: ['1741011655068', 'text']  # 要遍历的数组
    output_selector: ['1741011662463', 'result']  # 输出结果
    output_type: array[object]                     # 必须格式
    start_node_id: 1741011600006start              # 必须指向 iteration-start
    title: 迭代处理
    type: iteration
  position: {x: 200, y: 100}

# 2. iteration-start 节点 - 迭代入口(必须有!)
- id: 1741011600006start
  data:
    title: 迭代开始
    type: custom-iteration-start
  parentId: '1741011600006'    # 必须指向父迭代节点
  position: {x: 200, y: 200}

# 3. 迭代内部节点 - 处理每个元素
- id: '1741011662463'
  data:
    isInIteration: true         # 必须标记在迭代内
    iteration_id: '1741011600006'  # 必须标识所属迭代
    parentId: '1741011600006'   # 必须指向父迭代
    title: 处理节点
    type: llm
  position: {x: 200, y: 300}

# 4. 迭代内部边 - 连接迭代内节点
- source: 1741011600006start
  target: '1741011662463'
  type: isInIteration           # 必须是 isInIteration
  zIndex: 1002                  # 必须的渲染层级

Successful Version vs Failed Version Comparison

Comparison Item ✅ Successful Version ❌ Failed Version
Version Version of the reference case Version mismatch
iteration-start ✅ Present ❌ Missing
parentId ✅ Present ❌ Missing
iteration_id ✅ Present ❌ Missing
isInIteration edge ✅ Present ❌ Missing
zIndex: 1002 ✅ Present ❌ Missing
output_type format array[object] Incorrect format
start_node_id ✅ Points to iteration-start ❌ Missing

❌ Common Errors

Issue Description
Missing iteration-start Iterations must have a dedicated start child node; it is not "built-in"
Missing parentId Nodes inside an iteration cannot identify which iteration they belong to
Missing iteration_id Iterations cannot correctly manage internal nodes
Missing zIndex: 1002 Incorrect rendering layer for edges inside iterations
Incorrect output_type format Must be array[object]

Iteration Edge Connection Types

Type Description Used for Iteration
custom Normal connection ❌ Outside iteration
true Condition is true ❌
false Condition is false ❌
isInIteration Connection inside iteration ✅ Must use this

Edge Connection Types

Type Description Example
custom Normal connection source → target
true Condition is true branch if-else → true
false Condition is false branch if-else → false
custom_case_id Custom branch if-else → custom case_id
isInIteration Connection inside loop Node connection inside iteration

Usage Example

Example: Translation Workflow

User Requirement:

  • Name: zh-en-translator
  • Function: Chinese-to-English translation
  • Type: workflow
  • Input: Chinese text
  • Flow: User input → LLM translation → Return result

Generation configuration:

app:
  description: '中英文翻译工作流'
  icon: 🌐
  icon_background: '#E3F2FD'
  mode: workflow
  name: zh-en-translator
kind: app
version: {{参考案例的版本号}}
workflow:
  graph:
    edges:
    - source: '1741011655068'
      target: '1741011662463'
      type: custom
    - source: '1741011662463'
      target: llm
      type: custom
    - source: llm
      target: answer
      type: custom
    nodes:
    - data:
        title: 开始
        type: start
        variables:
        - variable: text
          type: paragraph
          label: 输入中文文本
          required: true
      id: '1741011655068'
      position: {x: 0, y: 263}
    - data:
        context:
          enabled: false
        model:
          provider: siliconflow
          name: internlm2_5-7b-chat
          mode: chat
        prompt_template:
        - role: system
          text: '请将以下中文翻译成英文,只输出翻译结果:{{#1741011655068.text#}}'
        title: LLM翻译
        type: llm
      id: llm
      position: {x: 382, y: 263}
    - data:
        answer: '{{#llm.text#}}'
        title: 翻译结果
        type: answer
      id: answer
      position: {x: 690, y: 263}

Best practices

1. Case reuse strategy

  1. Locate first: Find the most similar case through INDEX.md
  2. Then analyze: Read the DSL file and understand the node configuration
  3. Then adjust: Make personalized modifications based on the reference template

2. Flow design principles

  1. Start simple: Implement the core functionality first, then add branches and loops
  2. Modular design: Split complex flows into reusable steps
  3. Clear naming: Use meaningful variable names

3. DSL writing checklist

  • Node IDs are unique and correctly formatted
  • Position coordinates are reasonable and do not overlap
  • Edges are connected correctly with no broken links
  • Variable reference format is correct
  • Model/Provider configuration is valid
  • Output variable names are consistent with references

4. Testing and verification suggestions

  1. After generation, import into Dify for testing
  2. Check the input and output of each node
  3. Verify conditional branch logic
  4. Test boundary cases and error handling

Error handling

Error type Handling method
Incomplete requirements Prompt the user to supplement the missing information
Flow logic error Point out possible circular references or broken links
Node configuration error Provide correction suggestions
Invalid variable reference List the available variable options
Case location failed Expand the search scope or design manually

Reference resources

📂 Case directory structure

organized_dsl/
├── 01_内容生成与创作/
├── 02_图像生成与设计/
├── 03_视频生成/
├── 04_数据分析与可视化/
├── 05_文档处理与OCR/
├── 06_知识库与RAG/
├── 07_Agent与工具调用/
├── 08_教育与学习/
├── 09_商业与办公/
├── 10_多媒体处理/
├── 11_代码与开发/
├── 12_创意与娱乐/
├── 13_信息聚合/
├── 14_参考示例/
├── INDEX.md                    # 案例索引(搜索 organized_dsl/INDEX.md)
└── Dify_DSL_节点完整参考指南.md  # 节点配置参考(搜索 organized_dsl/Dify_DSL_节点完整参考指南.md)

📖 Documentation links

  • INDEX.md: Case index categorized by function
  • Dify_DSL_Node_Complete_Reference_Guide.md: Detailed configuration instructions for each node

Node automatic validation and generation rules

Version number rules

# ✅ 正确 - 生成时必须使用
version: {{参考案例的版本号}}

# ❌ 错误 - 禁止使用
version: {{参考案例的版本号}}

Node basic field rules

Each node must include the following when generated:

- data:
    positionAbsolute: false      # ✅ 必须
    selected: false              # ✅ 必须
    title: "节点名称"
    type: "节点类型"
    # ... 其他字段
  height: 52
  id: '节点ID'
  position:
    x: 0
    y: 0
  width: 242

Edges field rules

Each edge must include the following when generated:

- data:
    isInIteration: false         # ✅ 必须
    selected: false              # ✅ 必须
    sourceType: "源节点类型"
    targetType: "目标节点类型"
  id: "边ID"
  source: "源节点ID"
  sourceHandle: "source"
  target: "目标节点ID"
  targetHandle: "target"
  type: "custom|true|false|isInIteration"

variable-aggregator node generation rules

# ✅ 正确写法 - 用于聚合多分支输出
- data:
    output_type: string          # 聚合结果的输出类型
    type: variable-aggregator
    variables:                   # 聚合多分支的变量(二维数组)
    - - '分支节点ID1'             # 第一个分支的输出
      - text
    - - '分支节点ID2'             # 第二个分支的输出
      - text
  height: 211
  id: '聚合节点ID'

# ❌ 错误理解 - 不是简单的"将多个内容整合到一起"
# variable-aggregator 的真正用途:
# - 整合 IF/ELSE 条件分支的输出
# - 整合并行结构的多个输出
# - 确保无论哪个分支执行,下游都能通过统一变量引用

end node generation rules

# ✅ 正确写法 - Workflow 应用的结束节点
- data:
    outputs:
    - value_selector:
      - '上游节点ID'
      - text
      variable: output
    type: end                    # ✅ 使用 type: end(仅用于 Workflow)
  height: 103
  id: end

answer node usage scenarios

# ✅ 正确写法 - 仅用于 Chatflow 应用
- data:
    answer: '{{#llm.text#}}'     # 使用 answer 字段
    type: answer                 # ✅ 使用 type: answer(仅用于 Chatflow)

DSL generation checklist (must be checked after generation)

After generating the DSL, check item by item:

Application type check:

  • Workflow type uses type: end, Chatflow type uses type: answer
  • Workflow can only have a single End node
  • Chatflow supports multiple Answer nodes

Node check:

  • Version number is consistent with the reference case
  • Each node has data.positionAbsolute: false
  • Each node has data.selected: false
  • Each node has height and width

Edge check:

  • Each edge has data.sourceType
  • Each edge has data.targetType
  • Each edge has data.selected: false
  • Each edge has data.isInIteration(false outside iteration)

variable-aggregator check:

  • Use output_type(not outputs)
  • Use variables array format (not formatter_template)
  • Understand the purpose: aggregate multi-branch outputs, not simply consolidate content

assigner vs variable-aggregator check:

  • Need to write to a session variable → use assigner
  • Need to aggregate multi-branch outputs → use variable-aggregator

Last updated: 2026-01-03 Reference cases: 125+