Skip to main content
on_task_complete is called when a Task previously set with call.set_task() is completed by the agent. Use it to persist collected data, trigger downstream workflows, or move the call to the next stage.

Signature

There are two forms:
signature
  • Per-task form (recommended): @agent.on_task_complete("task_name") binds the handler to a specific task_id. The handler receives only the Call object.
  • Generic form: @agent.on_task_complete (bare decorator) fires for every completed task. The handler receives the Call object and the task_id string, letting you dispatch on it manually.
You cannot mix both forms on the same agent — using per-task handlers alongside a generic handler raises a TypeError.
  • on_task_complete fires once all checklist items are resolved and the agent has signaled completion.
  • Use call.get_field() inside the handler to read values collected during the task.
  • The call is still live when this handler runs — you can issue commands such as call.set_task(), call.hangup(), or call.transfer().

Example

waitlist_controller.py