- Python
- TypeScript
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:- Python
- TypeScript
signature
- Per-task form (recommended):
@agent.on_task_complete("task_name")binds the handler to a specifictask_id. The handler receives only theCallobject. - Generic form:
@agent.on_task_complete(bare decorator) fires for every completed task. The handler receives theCallobject and thetask_idstring, letting you dispatch on it manually.
on_task_completefires 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(), orcall.transfer().
Example
- Python
- TypeScript
waitlist_controller.py