Skip to content

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.

  1. Checks the status of the taskId task.
  2. If the task is completed, cancelled or expired, it finishes and returns the result.
  3. If it’s still open (pending or claimed), it waits pollSeconds seconds and checks again.
  4. If timeoutMinutes minutes pass without the task closing, it returns the task with status = "timeout". With cancelOnTimeout = 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 returns timeout.

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.

ParameterTypeDefaultDescription
taskIdstring—Task id: the id output of Create Human Task. E.g.: task["id"].
ParameterTypeDefaultDescription
timeoutMinutesint60Maximum minutes to wait. An empty, 0 or negative value uses 60.
pollSecondsint15Seconds between checks. The minimum is 5: a lower value is raised to 5.
cancelOnTimeoutboolfalseOn timeout, cancel the task so a late decision doesn’t trigger onCompleteProcess (a linked queue item is released).

Returns an object (dictionary) with:

FieldTypeDescription
idstringTask id.
statusstringcompleted, cancelled, expired or timeout (the wait ran out).
titlestringTask title.
decisionstringThe chosen option (e.g. Aprobar). If the task was cancelled, cancelada; null if it expired or the wait ran out.
commentstringComment of whoever decided (for a cancellation, the reason).
fieldsDictionaryFields 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.
formDictionaryWith a form: its name and version. Without a form, null.
MessageCause 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.

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: task
Wait for Human Task taskId = task["id"] timeoutMinutes = 20
cancelOnTimeout = true → output: result
If 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"])