How-to guide
Add approvals and external tasks
Pause a run for a human decision or an external system, then resume it with real result data.
Prerequisites
- Users, roles or groups that can be assigned tasks
Two flow-control activities pause a run until something outside the engine responds.
| Activity | Resumed by |
|---|---|
approval |
A person, or a member of a role or group, approving or rejecting |
external_task |
A callback with a token, or someone completing it manually from My Tasks |
Both write real result data into the run when they resume, for example the external-task result, which later activities can read.
Approval#
{
"id": "a_approve_refund",
"type": "approval",
"approval": {
"assignType": "user",
"assignedUserId": "alice",
"title": "Approve refund",
"message": "{{inputs.amount}} refund for {{inputs.customerId}}"
},
"next": "a_after_approval"
}
The output is taskId. Assign to a user, or to a role or group so any member can act on it.
Resolve tasks in Studio, or from the CLI:
kiwi flow tasks-mine --status Pending
kiwi flow task-approve --id <task-id> --comment "Approved after review"
kiwi flow task-reject --id <task-id> --comment "Missing documentation" # resumes the run down the rejection path
External task#
Use external_task when another system, or a person outside Kiwi Flow, does the work and reports back.
{
"id": "a_wait_erp",
"type": "external_task",
"external_task": { "title": "Waiting for ERP nightly batch" }
}
Outputs are taskId, token, callbackUrl and failUrl. Send the callback or fail URL to the other system, which calls it, with the token, when it finishes. The run then resumes with the posted data.
From the CLI (authenticated), or via the token-based callback variants that need no login:
kiwi flow external-tasks-mine
kiwi flow external-task-complete --id <task-id> --data-json '{"approved":true}'
kiwi flow external-task-fail --id <task-id> --error "Batch failed" # resumes the run down the failure path
Notifying assignees#
Both activities have a notification body so assignees are told when a task is waiting, using role-based recipient resolution and the saved email templates. See Email, templates and storage.
Branching on the decision#
Follow an approval with an if_else or switch on the resolved outcome. Keep long waits in these activities rather than in scripts: run state is persisted, so a wait can span hours or days.
Expected result
- A run pauses at the task, and resumes with the decision or result data when it is resolved