How do you implement human-in-the-loop approval workflows?
Human-in-the-loop workflows require careful design of approval routing, escalation, and timeout handling. Architecture: workflow engine creates an approval task, assigns it based on rules (amount thresholds, department, role), sends notifications (email, Slack, MS Teams), and pauses execution until approval/rejection. Implementation details: support multi-level approvals (sequential: A then B, parallel: A and B simultaneously, threshold: any 2 of 3 approvers), implement delegation and reassignment capabilities, set SLA timers with automatic escalation (e.g., escalate to manager after 24 hours, auto-approve low-risk items after 72 hours), and provide a mobile-friendly approval interface for quick responses. State management: persist approval state durably, handle approver unavailability (out of office, terminated), and support approval recall/withdrawal. Integration patterns: expose approval APIs for embedding in existing tools (Slack buttons, Teams adaptive cards, email action buttons), implement webhook callbacks for real-time status updates. Audit trail: log every approval action with timestamp, approver identity, decision, and any comments for compliance. Analytics: track approval latency, bottleneck identification, and rejection patterns.