Approval Flow Overview
- Node Execution — Worker reaches approval node
- Pause State — Run status changes to
awaiting_approval - Message Sent — Approval request sent to configured channel
- Human Decision — User replies with approve/decline command
- State Update — Approval recorded to disk
- Resume — Workflow continues or loops back for revision
Runtime Behavior
Node Status Transition
When a workflow worker processes ahuman_approval node:
- Creates approval directory:
workflow-runs/{runId}/approvals/ - Generates random approval code (6-char uppercase)
- Writes
approval.jsonwith pending status - Sends message to configured channel with approval code
- Marks node as waiting in run state
- Pauses execution (no further nodes enqueued)
State Files Written
Run Log Update (workflow-runs/{runId}/run.json):
workflow-runs/{runId}/approvals/approval.json):
Message Template Rendering
The approval message includes template variable substitution: Template Variables Available:{{workflow.name}}— Workflow display name{{code}}— Generated approval code{{ticket}}— Relative path to ticket file- Proposed content preview (from prior node outputs)
- Look for
qc_brandnode output first - Fall back to most recent prior LLM node
- Extract
textfield and sanitize for preview - Show “(Warning: no proposed text found)” if unavailable
Human Response Handling
Command Format
Users reply in the configured channel:- Case-insensitive verb matching:
approve|decline - Code must be exact (uppercase)
- Optional note after code for decline responses
- Parser checks multiple lines, prefers last match
Auto-Processing
When a user replies with a valid approval command:- Event Detection — Plugin listener matches approval format
- Code Lookup — Searches all team runs for matching pending approval
- Decision Recording — Updates approval.json status and note
- Auto-Resume — Calls resume workflow to continue execution
- Telegram (primary)
- Other channels with conditional processing based on metadata
Resume and Continuation
Approval Resume
Approved Flows:Revision Logic
When an approval is declined:- Find revision target — Prefers
draft_assetsnode, else closest prior LLM node - Clear node states — Remove status for revision node onward
- Clear locks — Remove any stale node lock files
- Enqueue revision — Send revision task to appropriate agent
- Include feedback — Pass human note in task packet
Configuration
Node Configuration
approvalBindingId→ Look up in OpenClaw config bindingsconfig.target→ Direct channel target- Back-compat fallbacks for known account IDs
Agent Assignment
Approval nodes are executed by:- Explicit
config.agentId— Workflow author override - Team lead —
${teamId}-lead(default orchestrator) - Current agent — Fallback for backwards compatibility
Command Line Interface
Manual Approval
Resume Workflow
Poll Approvals
Implementation Details
Code Locations
Primary Approval Logic:src/lib/workflows/workflow-approvals.tsapproveWorkflowRun()— Record approval decisionresumeWorkflowRun()— Continue/revise after decisionpollWorkflowApprovals()— Auto-resume decided approvals
src/lib/workflows/workflow-worker.ts- Approval node execution in
runWorkflowWorkerTick() - Message sending and state management
- Approval node execution in
index.ts— Auto-approval reply handler in plugin registration
File Structure
Error Handling
Missing Targets
config.target or add binding in OpenClaw config.
Code Not Found
- Code already processed/expired
- Wrong team workspace searched
- Approval file corrupted
Resume Failures
workflows approve before resuming.
Best Practices
Node Placement
- Place approval nodes after content generation but before publishing
- Use descriptive node IDs:
final_approval,brand_review,legal_check
Message Configuration
- Always configure approval binding in OpenClaw config for production
- Test approval flow with known test accounts/channels
- Include meaningful context in approval messages
Error Recovery
- Monitor approval files for stuck
pendingstatus - Use
poll-approvalsfor automated processing - Set up alerting for approval timeouts
Workflow Design
- Design clear revision loops with identifiable
draft_assetsnodes - Keep approval criteria specific and actionable
- Document approval responsibilities in team workflows
Related Documentation
- WORKFLOW_NODES.md — All node types and configuration
- TEMPLATE_VARIABLES.md — Message template variables
- OUTBOUND_POSTING.md — Publishing after approval
- COMMANDS.md — CLI workflow commands
