logo
14

Visual Orchestration with Dify

⏱️ 15 min

Dify Workflow Board

Honestly, most people hearing "AI workflow orchestration" for the first time imagine writing Python, calling APIs, doing prompt engineering. But Dify did something: turned all of that into drag-and-drop. You don't need to write a single line of code to build a working AI application.

Sounds like magic? After building a few real workflows, you'll realize it's more like assembling Lego. Each block (node) has a fixed function. Your job is figuring out how to connect them.


What Is Dify

One-liner: Dify is an open-source LLMOps platform that lets you build AI applications through visual drag-and-drop instead of writing code.

Analogy: If you've used Zapier or Make.com for automation -- Dify is the AI version. Zapier connects SaaS tools (Gmail -> Slack -> Google Sheets). Dify connects AI models and data sources (user question -> knowledge retrieval -> LLM generation -> formatted output).

How to use this at work: A PM wants to quickly validate "adding an AI assistant to customer service." No waiting for dev sprints -- just drag and drop one yourself, connect company FAQ docs, half-day demo done.

Most common mistake: Thinking Dify can replace all backend development. It handles AI-related logic really well, but complex business logic (multi-step approvals, permission management, database transactions) isn't its strength. Someone on our team built a "smart approval system" with Dify, and 80% of the time was spent writing HTTP Request nodes to call external APIs. Should've just written code.


Self-Hosted vs Cloud: Which One

Bottom line:

DimensionDify Cloud (dify.ai)Self-hosted (Docker)
Setup speedRegister and use, 5 minutesNeed a server + Docker, 30 min minimum
Free tier200 messages/day (Sandbox Plan)Unlimited, but you pay for LLM API fees
Data privacyData on Dify serversData on your own server
Best forPersonal learning, quick validationEnterprise production, sensitive data
MaintenanceZeroVersion updates, DB backups, server costs
VersionAlways latestMust manually docker-compose pull to update

My advice: Start with Cloud to learn workflow building. Only self-host once you've confirmed you're going to production. Too many people jump straight into Docker deployment without understanding Dify's basic concepts.

Quick note: Dify's self-hosted version updates very frequently -- nearly every two weeks. From v0.6 to v0.7, the database structure changed, and quite a few people's workflows broke after upgrading. So if you self-host, always back up the database before upgrading.


Core Concepts: Four Things You Must Understand

1. Workflow

A processing chain from input to output. User gives input, it goes through a series of nodes, and produces a result.

Two types:

  • Chatflow: Conversational, good for customer service bots and Q&A assistants. Has context memory, supports multi-turn dialogue.
  • Workflow: Single execution, good for batch processing. Input -> process -> output, no conversation history.

Honestly, 90% of scenarios work fine with Chatflow. Only batch processing (like "translate all 100 of these articles") needs Workflow mode.

2. Knowledge Base

Upload documents (PDF, Word, web pages, Notion), and Dify chunks, vectorizes, and stores them in a vector database. Then the LLM can retrieve these documents when answering questions.

This is what people call RAG (Retrieval-Augmented Generation).

Key parameter: chunk size

This is where we've hit the most pitfalls. Chunk size determines how big each document segment is:

Chunk SizeEffectGood for
200-300 wordsPrecise retrieval, but might lose contextFAQ, Q&A pairs, short entries
500-800 wordsBalance between precision and contextBest starting point for most scenarios
1000+ wordsRich context, but retrieval may be impreciseLong documents, technical manuals

We had a real case: fed a 200-page product manual to a customer service bot using default chunk size (1000 words). User asked "what's the return policy," and the AI returned a long block containing return info mixed with shipping info. Changed to 300-word chunks and answers got much more precise.

3. Tools

Dify has built-in tools (Google search, weather queries, calculator), and you can connect your own APIs via OpenAPI schemas.

The value here is making AI not just "chat" but actually "do things." Like when a user says "check today's weather in Beijing," AI calls a weather API, gets data, and replies in natural language.

4. Variables

Nodes in a workflow pass data between each other via variables. One node's output becomes the next node's input.

Written as {{node_name.output}}, similar to template engines. Anyone who's done frontend will find this familiar.

One gotcha: Variable names are case-sensitive. {{LLM.output}} and {{llm.output}} are not the same thing. I've wasted 2 hours debugging this.


Node Type Quick Reference

Dify workflows are composed of various nodes, each doing one thing:

NodeFunctionUsage frequencyNotes
StartDefine input variablesEvery workflow has oneSet user input fields and types
LLMCall large language model★★★★★Core node -- write prompt, pick model, set temperature
Knowledge RetrievalRetrieve from knowledge base★★★★RAG core -- configure top-k and score threshold
IF/ELSEConditional branching★★★Route based on variable values
CodeRun Python/JS★★★Data processing, format conversion, complex logic
HTTP RequestCall external APIs★★★Connect any REST API
TemplateText template★★Format output with Jinja2
Variable AssignerVariable assignment★★Modify variable values mid-flow
EndDefine outputEvery workflow has oneDetermine final content returned to user

Hands-On: PDF Summary + Email Notification Workflow

Real business scenario: team receives tons of supplier PDF reports daily. Someone needs to read them, write summaries, then email relevant colleagues.

Flow Design

Start (upload PDF URL)
  -> HTTP Request (download PDF content)
  -> Code (extract text)
  -> LLM (generate summary)
  -> IF/ELSE (does summary contain urgent keywords)
  -> HTTP Request (send email notification)
  -> End (return summary)

Step 1: Start Node

Add a file_url input variable, type String.

Step 2: HTTP Request to Download PDF

  • Method: GET
  • URL: {{start.file_url}}
  • This step gets the raw PDF content

Step 3: Code Node to Extract Text

def main(inputs):
    # Dify's Code node supports simple Python
    raw_content = inputs["http_response"]
    # In real scenarios you might need PDF parsing
    # Simplified handling here
    return {"text": raw_content[:5000]}

Step 4: LLM Generates Summary

Prompt design:

You are a professional business analyst. Read the following document and generate a concise summary in Chinese.

Requirements:
1. Keep it under 200 words
2. Extract key data points and conclusions
3. Flag whether there are urgent items requiring attention

Document content:
{{code.text}}

Model selection: For summary tasks, GPT-4o-mini or Claude 3.5 Haiku is sufficient. No need for the most expensive model.

Step 5: IF/ELSE for Urgency

Condition: {{llm.output}} contains "urgent"

  • If yes -> Take urgent notification path (email + Slack)
  • If no -> Take normal path (just log it)

Step 6: HTTP Request to Send Email

Send via webhook or email API (like SendGrid or Resend).

This workflow takes about 15 minutes to build. Implementing the same functionality in code, plus error handling and deployment, would take at least half a day.


Dify vs Coze vs n8n: Which One

This is what everyone cares about most. Direct comparison:

DimensionDifyCozen8n
PositioningAI app dev platformAI bot builderGeneral automation platform
Open source✅ Apache 2.0❌ Closed✅ Limited open source
Self-host✅ Docker one-click❌ Official platform only✅ Docker deployment
AI focus★★★★★ Built for AI★★★★ Bot-focused★★★ AI is one of many features
Non-AI integrations★★ Basic HTTP★★★ Plugin marketplace★★★★★ 400+ integrations
Learning curveMediumLowMedium-high
Chinese ecosystem✅ Good docs✅ Natively Chinese⚠️ Community translations
Best forDevelopers, technical PMsOps, content creatorsDevOps, automation engineers

Bottom line:

  • Building AI apps (customer service, Q&A, content generation) -> Dify
  • Quick multi-platform bot -> Coze
  • Complex cross-system automation where AI is just one piece -> n8n
  • Data can't leave your servers -> Dify self-host

Pricing: Don't Get Fooled by "Free"

PlanPriceMessagesKnowledge baseTeam
SandboxFree200/day5MB1 person
Professional$59/mo5,000/mo200MB3 people
Team$159/mo10,000/mo1GBUnlimited
Self-hostedFree (open source)UnlimitedUnlimitedUnlimited

Quick note: Sandbox's 200/day includes your own testing messages. During development with repeated debugging, 200 a day isn't enough. I've burned through the quota in one afternoon, then had to wait until the next day.

Self-hosted looks free, but don't forget you're paying for:

  • Server costs (minimum 2C4G, ~$20/mo)
  • LLM API fees (this is the big one)
  • Vector database storage (gets large with lots of docs)

The Version Management Pain

Dify's iteration speed (as of late 2025) is "aggressive" level. v0.6 -> v0.7 -> v0.8 -> v0.9, nearly every major version has breaking changes.

Version disasters we've lived through:

  1. v0.6 -> v0.7: Workflow variable reference syntax changed. All {{#node_id.output#}} had to become {{node_id.output}}. Dozens of workflows to fix manually.
  2. v0.8 knowledge base: Introduced new embedding model switching, but after upgrade, old embedding indexes were incompatible. Had to re-index all documents.
  3. Docker image tags: For a while, the latest tag pointed to nightly builds, not stable releases. People running latest in production cried.

Laziest approach:

  • Self-hosted: Lock to specific version numbers, don't use latest
  • Check GitHub Release Notes for Breaking Changes before every upgrade
  • Run in staging before upgrading production

Common Errors and Solutions

ErrorCauseSolution
Knowledge base retrieval returns emptyChunk size too large, or embedding model mismatchReduce chunk size (300-500), ensure embedding and retrieval models match
LLM node timeoutPrompt too long or model response slowShorten prompt, switch to faster model (GPT-4o-mini)
Variable reference errorWrong case or node not connectedCheck node connections, confirm variable names match exactly
HTTP Request failsTarget API requires auth or has CORS restrictionsAdd Authorization in Headers. Self-host has no CORS issues
Workflow behaves differently after publishingEditor uses draft versionMust click "Publish" after each change -- it doesn't auto-save

From Workflow to API: One-Click API Endpoint

Workflows built in Dify can directly generate API endpoints. In the app settings page, find API Access and you'll get:

  • Base URL
  • API Key
  • Curl example
curl -X POST 'https://api.dify.ai/v1/workflows/run' \
  -H 'Authorization: Bearer app-xxxxxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
    "inputs": {
      "file_url": "https://example.com/report.pdf"
    },
    "response_mode": "blocking",
    "user": "user-123"
  }'

response_mode has two options:

  • blocking: Wait for workflow to finish, then return (good for short tasks)
  • streaming: Return results as they come (good for generating long text)

This means any workflow you build in Dify can be called by other systems. Frontend apps, WeChat bots, enterprise internal systems -- anything that can make HTTP requests.


When NOT to Use Dify

Honestly, Dify isn't a silver bullet. These scenarios, just write code:

  1. Complex state management: Multi-step approvals, flows needing rollback and retry
  2. High concurrency: Hundreds of requests per second -- Dify's performance isn't enough
  3. Deep UI customization: Dify's built-in WebApp interface is basic. Nice frontends still need custom code
  4. Model fine-tuning: Dify supports calling fine-tuned models, but fine-tuning itself needs other tools

But if your need is "connect LLM + knowledge base + simple logic + ship fast," Dify is currently the laziest option. Especially for non-full-time developers -- PMs, ops people, founders -- Dify lowered the AI app development barrier to "if you can use Excel, you can build this."

Get it running first, then optimize. That's the right AI Builder mindset.