While stress-testing a new customer onboarding workflow built in Relevance AI's visual builder, I encountered a common architectural hurdle: the need to inject a human decision point into an otherwise automated agent chain. Specifically, after a preliminary risk assessment, I needed a compliance officer to manually review and approve certain high-value cases before proceeding with account provisioning.
The intuitive, but ultimately cumbersome, approach would be to have the agent send a notification (email, Slack) and then pause, requiring a separate system to resume the workflow via an API call. However, Relevance's `wait for` node provides a much more elegant and self-contained solution. This node essentially creates a pause point where the workflow halts, waiting for an external signal before continuing down a specific branch.
Here’s a simplified example of the workflow segment I constructed:
```yaml
- id: assess_risk
type: chain
# ... risk assessment logic
outputs:
- risk_score
- customer_id
- id: check_approval_needed
type: switch
inputs:
value: "{{assess_risk.risk_score}}"
cases:
- case: "> 70"
goto: request_human_approval
- default: goto: proceed_automatically
- id: request_human_approval
type: wait_for
inputs:
event_name: "manual_approval_{{assess_risk.customer_id}}"
timeout: 86400 # 24 hours in seconds
outputs:
- approved_status: "{{event_data.approved}}"
- officer_id: "{{event_data.officer_id}}"
on_timeout: goto: handle_timeout
- id: process_approval_decision
type: switch
inputs:
value: "{{request_human_approval.approved_status}}"
cases:
- case: "true"
goto: provision_account
- case: "false"
goto: send_rejection
```
The key is the `wait_for` node. It halts execution and listens for a specific event, in this case named dynamically like `manual_approval_cust_12345`. To resume, you send a POST request to Relevance's dedicated webhook endpoint with the corresponding event name and payload.
```bash
curl -X POST https://api.relevance.ai/v1/workflows/events
-H 'Authorization: Bearer YOUR_API_KEY'
-H 'Content-Type: application/json'
-d '{
"event_name": "manual_approval_cust_12345",
"event_data": {
"approved": true,
"officer_id": "officer_jane",
"notes": "All checks cleared."
}
}'
```
Upon receiving this event, the workflow consumes the `event_data`, populates the `wait_for` node's outputs, and proceeds down the `provision_account` branch.
Some critical observations and implications from my testing:
* **State Persistence:** The workflow state is preserved during the wait. This is not a simple HTTP request hanging open; the platform manages the state efficiently, allowing for long wait times (days) without resource issues.
* **Integration Flexibility:** The manual approval can be triggered from anything: a click in a custom admin dashboard, an action in another SaaS tool via Zapier/Make, or even another, separate agent workflow acting as an overseer.
* **Timeout Handling:** The mandatory timeout is a crucial safety net. The `on_timeout` branch allows you to escalate, notify, or clean up stalled processes, which is essential for production reliability.
* **Context Passing:** The entire context of the workflow up to that point is available after the wait. You can use data from previous nodes (like `customer_id`) to both name the event and inform the human approver's interface.
This pattern effectively transforms a linear automation into a robust human-in-the-loop (HITL) system. It moves beyond simple notification schemes by maintaining the workflow's context and providing a structured channel for the human response to re-enter the automated process. For those building complex, multi-stage agentic processes that require governance checkpoints, this node is an absolute game-changer.
testing all the things
throughput first