Wait for Human Task
Wait for Human Task
Section titled “Wait for Human Task”Type: human-task-wait · Package: Human Task Activities v1.3.3 · Output: object
Waits for the decision on a task created with Create Human Task. The robot checks the task every few seconds and continues as soon as someone decides it, cancels it or the task expires. If the wait times out, it doesn’t fail: it returns status = "timeout" so the flow can decide what to do.
It’s meant for decisions that take minutes. If the decision can take hours or days, it’s better to use onCompleteProcess in Create Human Task and end the process, instead of keeping the robot busy waiting.
How it works
Section titled “How it works”- Checks the status of the
taskIdtask. - If the task is
completed,cancelledorexpired, it finishes and returns the result. - If it’s still open (
pendingorclaimed), it waitspollSecondsseconds and checks again. - If
timeoutMinutesminutes pass without the task closing, it returns the task withstatus = "timeout". WithcancelOnTimeout = true, it also cancels it (with the reason “No decision within N min (process timeout).”) so nobody decides it late. If that cancellation fails, only a warning is logged and the activity still returnstimeout.
If the execution is stopped while waiting, the activity fails with “Cancelled while waiting for the human task.”.
It can only wait for tasks created by a robot in the same environment; a task from another environment, or created another way, responds as if it didn’t exist.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
taskId | string | — | Task id: the id output of Create Human Task. E.g.: task["id"]. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
timeoutMinutes | int | 60 | Maximum minutes to wait. An empty, 0 or negative value uses 60. |
pollSeconds | int | 15 | Seconds between checks. The minimum is 5: a lower value is raised to 5. |
cancelOnTimeout | bool | false | On timeout, cancel the task so a late decision doesn’t trigger onCompleteProcess (a linked queue item is released). |
Output
Section titled “Output”Returns an object (dictionary) with:
| Field | Type | Description |
|---|---|---|
id | string | Task id. |
status | string | completed, cancelled, expired or timeout (the wait ran out). |
title | string | Task title. |
decision | string | The chosen option (e.g. Aprobar). If the task was cancelled, cancelada; null if it expired or the wait ran out. |
comment | string | Comment of whoever decided (for a cancellation, the reason). |
fields | Dictionary | Fields the person filled in. E.g.: result["fields"]["approved_amount"]. With a form, tables arrive as lists of rows (each row with all of its columns; empty ones as null) and files as references you download with Download Human Task File. |
form | Dictionary | With a form: its name and version. Without a form, null. |
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'taskId' is required. | taskId is missing. |
… HTTP 404: … (task not found) | The id isn’t valid, the task belongs to another environment or wasn’t created by a robot. Pass the id Create Human Task returned. |
Cancelled while waiting for the human task. | The execution was stopped during the wait. |
Human task activities require a Zoan Automation runtime context. Missing: … | The process isn’t running from Zoan Cloud or from the Designer signed in. |
Errors while reading the task arrive with the prefix “Could not wait for the human task: ”. A timeout is not an error.
Example
Section titled “Example”Create Human Task title = "Validate the supplier's tax id" data = { "Supplier": "Test customer", "Tax id read": "900.000.000-0" } fields = { "tax_id": "Correct tax id:text*" } assignRole = "tenant-admin" → output: taskWait for Human Task taskId = task["id"] timeoutMinutes = 20 cancelOnTimeout = true → output: resultIf condition = result["status"] == "completed" && result["decision"] == "Aprobar" ├─ then: │ Set Variable name = taxId value = result["fields"]["tax_id"] └─ else: Throw message = "Tax id not validated: " + str(result["status"])Related activities
Section titled “Related activities”- Create Human Task — create the task to wait for.
- Cancel Human Task — cancel the task at another point of the flow.