Last verified: September 3, 2026 Workflow Builder Visual Builder

Dify Workflow Guide 2026: Nodes, Triggers and API

Dify Workflows are visual, node-based processes that connect models, knowledge bases, APIs, tools and code. This guide covers the core nodes, walks through a small workflow, and shows three patterns you can adapt and test with your own data.

What Are Dify Workflows?

A Dify Workflow is a visual pipeline where you connect nodes to run a multi-step AI task. Unlike a general automation tool, Dify includes dedicated nodes for models, knowledge retrieval and agentic actions.

Unlike a Chatflow, which adds a conversation layer, a Workflow runs once from its start node. Conditions, loops and iterations determine which steps run. This makes Workflows useful for automation, document processing, data enrichment and other tasks with an explicit process.

A Workflow runs once from its selected start node. It can begin with User Input or an automatic trigger, and it can return selected variables through an optional Output node. The run log shows inputs, outputs and execution details for debugging.

Visual drag-and-drop canvas
AI-native LLM nodes
RAG knowledge retrieval built-in
Python & JavaScript code nodes
HTTP request any external API
Conditional branching (If/Else)
Run logs for debugging
API, schedule and webhook starts

Core Node Types

Every Dify Workflow is built from these fundamental node types. Understanding each one is the key to designing effective pipelines.

User Input

Use this start node when a person or API call supplies the workflow inputs. You can define text, number, file and other fields that downstream nodes reference.

Tip: Keep inputs minimal and typed. Use "text" for strings, "number" for numeric inputs, "select" for dropdowns.

LLM

The core model node. Select a configured model, add instructions and insert variables from upstream nodes through the variable picker.

Tip: Use structured output mode (JSON schema) when downstream nodes need to parse the LLM response programmatically.

Knowledge Retrieval

Searches your Dify Knowledge Bases using vector similarity (RAG). Pass a query string and get back the most relevant document chunks. Connect the retrieved context to an LLM node for grounded, factual answers.

Tip: Test retrieval count, score threshold and reranking on representative questions instead of assuming one setting fits every knowledge base.

Code

Execute Python or JavaScript directly in the workflow. Use it to parse JSON, transform strings, compute values, filter arrays, or do anything a script can do. Input variables from upstream nodes are available as local variables.

Tip: Code nodes run in a sandboxed environment. Use an HTTP Request node when the workflow needs an external network call.

HTTP Request

Call external services with standard HTTP methods. Configure authentication, headers, query parameters, timeouts and the request body using workflow variables.

Tip: Store sensitive API keys in Dify environment variables, not hardcoded in the node config.

If/Else

Conditional branching. Evaluate any expression (string comparison, numeric threshold, regex match, contains check) and route the workflow to different branches. You can add multiple "Else If" conditions for complex routing logic.

Tip: Use If/Else for business conditions. For a failed LLM, HTTP, Code or Tool node, use Dify's built-in retry, default-value or fail-branch handling.

Template

Transform and format data using Jinja2 templates. Combine variables, format values and loop over lists without writing a full Code node.

Tip: Great for building dynamic prompts that combine multiple upstream outputs before passing them to an LLM node.

Variable Aggregator

Converge outputs from exclusive branches into one variable so downstream nodes can reference a consistent output type.

Tip: Use "array" mode to collect all branch outputs into a list, then process with a Code node.

Output

Select the variables returned to a user or API caller. Output is optional, but a branch without an Output node returns no values. Chatflows use an Answer node instead.

Tip: Multiple Output nodes are supported. Give every output variable a unique name so later results do not overwrite earlier ones.

Building Your First Workflow

Build a small article summarizer that takes text as input and returns a three-point summary.

1

Create a new Workflow app

In Dify Studio, create a blank Workflow and name it "Article Summarizer". The canvas begins with a User Input node; add an Output node for the result.

2

Configure the User Input node

Click the User Input node. Add a Paragraph field named article_text. This is what the user or API caller supplies when starting the workflow.

3

Add an LLM node

Add an LLM node and select a model available in your workspace. Insert article_text with the variable picker, then ask for exactly three concise bullet points.

4

Connect User Input → LLM → Output

Connect User Input to the LLM node, then connect the LLM node to Output. Configure Output to return the LLM node's text variable.

5

Test it

Click "Test Run", paste sample text into article_text and start the run. Inspect the result and the run details before publishing.

What you built: User Input (article_text) → LLM (summary prompt) → Output (summary). Reuse this basic shape for other text-in, text-out tasks.

Workflow vs Chatflow vs Agent Node

Current Dify documentation distinguishes Workflow and Chatflow as the two canvas app types. An Agent is a node you can place inside a flow when a model needs to select and use tools dynamically.

Feature Workflow Chatflow Agent node
Interaction model One run from start to finish Multi-turn conversation Dynamic tool selection inside a flow
Process shape Explicit nodes and branches Explicit flow for every message Model chooses its next tool action
Best for Automation and batch processing Support and guided Q&A Tasks that require flexible tool use
Debugging Inspect each node and run log Inspect conversation and node logs Inspect the agent trace and tool calls
API access User Input workflows can expose an API Available through the chat API Invoked through its parent app
Knowledge retrieval Available as a node Available as a node Available through connected tools
External API calls Use HTTP Request or Tool Use HTTP Request or Tool Use connected tools
Automatic start Schedule, webhook or integration trigger Starts from user input Starts when its parent flow reaches it
Rule of thumb: If the process can be drawn as explicit steps and branches, start with a Workflow. If users need an ongoing conversation, use a Chatflow. Add an Agent node only when the model needs to decide which tools to call.

3 Practical Workflow Examples

These example shapes illustrate common Dify Workflow patterns. Treat them as starting points and test every branch, model and external dependency with your own inputs before production use.

Example 1

Content Summarization Pipeline

Takes any article text and produces a structured summary with a headline, 3 key points, and a one-sentence takeaway. Useful for content teams, newsletter editors, and research assistants.

User Input (article_text) LLM (summarize + structure) Output (summary)

LLM Prompt: "Given the article inserted below, return a headline, exactly three key points and a one-sentence takeaway as structured output." Insert article_text with Dify's variable picker.

Example 2

Customer Support Triage

Classifies incoming support tickets by intent, then routes each category to a focused response path. Measure classification accuracy and escalation rates on your own ticket set before automating replies.

User Input (ticket_text) LLM (classify intent) If/Else (route by category) LLM (specialized response) Output

If/Else logic: If intent == "billing" → billing LLM (knows pricing, refund policy). If intent == "technical" → tech LLM (knows product docs). Else → general support LLM.

Example 3

Document Q&A Pipeline

Takes a question and retrieves the most relevant document chunks from your knowledge base, then passes them to an LLM for a grounded, citation-backed answer. Perfect for legal docs, technical manuals, and internal wikis.

User Input (question) Knowledge Retrieval (top-5 chunks) LLM (answer with context) Output (answer)

LLM Prompt: "Answer the question using only the retrieved context. If the answer is not present, say so." Insert the retrieval result as context and the user question through Dify's variable picker.

Running Workflows via API

A Workflow that starts with User Input can be published as a backend service API. Workflows that start automatically use a Schedule, Webhook or Integration Trigger instead.

POST https://your-dify-instance/v1/workflows/run

{`curl -X POST 'https://your-dify-instance/v1/workflows/run' \\
  -H 'Authorization: Bearer YOUR_API_KEY' \\
  -H 'Content-Type: application/json' \\
  -d '{
    "inputs": {
      "article_text": "Your article content goes here..."
    },
    "response_mode": "blocking",
    "user": "user-123"
  }'`}

Response (blocking mode)

{`{
  "task_id": "abc-123",
  "workflow_run_id": "xyz-456",
  "data": {
    "outputs": {
      "result": "• Key point 1\\n• Key point 2\\n• Key point 3"
    },
    "status": "succeeded",
    "elapsed_time": 2.34,
    "total_tokens": 312
  }
}`}

blocking

Returns one response after the workflow completes.

streaming

Returns workflow progress through a Server-Sent Events stream.

Tips for Production Workflows

Getting a workflow to run once is easy. Getting it to run reliably at scale requires a few extra considerations:

Use structured outputs from LLM nodes

Define a structured output when downstream nodes expect fields. Validate the result before using it in code or an external request.

Use built-in node error handling

LLM, HTTP, Code and Tool nodes support retries and failure behavior. Choose whether to stop, return a typed default value or route through a fail branch.

Keep LLM prompts focused

Give each LLM node a narrow responsibility. Separate classification, generation and rule-based formatting when the stages need different validation.

Monitor token usage per workflow run

Use the run logs to inspect inputs, outputs, latency and usage. Compare models on representative inputs before choosing a cheaper option.

Test edge cases with the built-in runner

Run the whole flow and test individual nodes with cached variables. Include empty, malformed and maximum-size inputs before publishing.

Retest after model or provider changes

A different model or provider can change output shape, latency and failure modes. Repeat your representative tests before publishing the update.

Frequently Asked Questions

What is a Dify Workflow?

A Dify Workflow is a visual process that combines model, retrieval, code, tool, HTTP and logic nodes. It runs once from its selected start node and can return chosen values through an Output node.

When should I use a Workflow instead of a Chatflow?

Use a Workflow for a process that runs from input to output, such as document processing or batch work. Use a Chatflow when users need a multi-turn conversation around the process.

Can I run Dify Workflows automatically on a schedule?

Yes. Current Workflow apps support a Schedule Trigger with a visual schedule or cron expression. Workflows can also start from integration and webhook triggers. A workflow that starts with User Input can instead be invoked through its service API.

Can Dify Workflows call external APIs?

Yes. The HTTP Request node supports standard methods, authentication, headers, query parameters and several request body types. Previous node values can be inserted as variables.

Host Dify and Start Building Workflows

Self-hosting gives you control over the Dify application and its infrastructure, but model, storage and network costs still depend on your configuration and usage. Compare a self-managed VPS with a managed deployment before choosing.

Deploy on Hetzner → One-Click on Elestio → Compare All Hosting Options

Official Dify References

Product behavior on this page was checked against Dify documentation on September 3, 2026. Interface names can change, so use the linked documentation when a control is not present in your installation.