- Workflow design, node schemas and gate logic in Dify.
- Dify · Workflow · RAG · Human-in-the-loop
Problem
A Dify workflow for customer service that routes risky or unsupported questions to a human instead of letting the model guess.
Customer service is where a confident wrong answer costs the most.
Run Fast is a workflow that decides, step by step, whether the AI should answer at all.
A chatbot that always answers will sometimes answer without evidence.
Some questions are out of scope, some need a human, some are risky. A single prompt cannot reliably handle all of these.
Workflow design, node schemas and gate logic in Dify.
Build
A sequence of explicit checks before any answer is generated. Each step produces structured output validated with JSON Schema.
The final Evidence Gate decides between an AI answer and handing over to a human.
Evidence Gate states
no_evidence- Nothing relevant was retrieved. Hand over to a human.
evidence_insufficient- Something was found, but not enough to answer safely. Hand over to a human.
answerable- Retrieved evidence supports an answer. The AI responds.
- Scope Check
- Human Escalation Check
- Risk Classification
- Knowledge Retrieval
- Evidence Gate
- AI Answer / Human
- Scope
- Escalation
- Risk
- Retrieval
- Evidence Gate
- AI Answer
- 03› Risk classification
- 04› Knowledge retrieval
- 05› Evidence Gate: answerable
- 06› The AI answers from the evidence
Scope
Scope check: in scope
Escalation
No human escalation needed
Risk
Risk classification
Retrieval
Knowledge retrieval
Evidence Gate
Evidence Gate: answerable
AI Answer
The AI answers from the evidence
- 01
Workflow before agent
The path is known in advance, so a deterministic workflow is easier to audit than an autonomous agent.
- 02
No evidence, no answer
The AI should not answer when retrieval does not support it. Saying "I'll get a human" is a valid output.
- 03
Structured outputs between nodes
JSON Schema keeps every step's output machine-checkable, so routing never depends on parsing free text.
Engineering
- Built in Dify as a multi-node workflow.
- JSON Schema for structured output at each decision node.
Notes
The most valuable node in the workflow is the one that says no.
- Dify
- Workflow
- RAG
- Human-in-the-loop
- JSON Schema