end_call hangs up. It is how an agent closes a call itself — after the caller
has said they are done, after a booking is confirmed, or on a branch where there
is nothing left to do.
config may be omitted entirely, and an
end_call with any field in it is refused at save.
Everything the tool must do goes before it
end_call is terminal in its chain. Nothing may follow it in the top-level
list or inside a then/else branch, and saving a tree that puts an operation
after one is rejected:
end_call returns, the session is
draining: an HTTP call to log the outcome, a POST that files the lead, a
set_variable that stamps userdata — all of it has to be above the
end_call, while there is still a call to do it on.
Wording the goodbye
Put asay immediately before the end_call if the caller should hear
something. Word it as what actually happens: the call ends here.
You do not need
wait_for_playback on that say. end_call waits for
everything outstanding — the model’s own speech from before the tool ran, and
the goodbye the tree queued — before it hangs up, and the agent never says
anything after it. Ticking the flag adds nothing and can only slow the tree
down. (The wait is bounded: if a text-to-speech provider stalls for 60 seconds,
the call is ended anyway rather than hanging.)
The agent says nothing afterwards
A tool run that reachesend_call tells the model nothing at all, whatever the
tree collected on the way. There is nobody left to narrate it to, so the model
is not given a chance to add a sentence to a call that is already over.
That also means silent is irrelevant on a tool that ends the call — it is
already silent by the time it matters.
How the call is recorded
user_initiated names whichever side called shutdown, which on this platform is
only ever the end_call operation. It means the agent hung up, not the
caller. A caller hanging up is participant_disconnected. See
close reasons.Worked example: qualify, then close
An outbound qualification tool that files the answer and ends the call on one branch while carrying on with the conversation on the other. Note that the whole “keep going” path lives in theelse — branches do not rejoin, so there is no
place after the if to put shared work.
Do not use
end_call as an error handler. A tool whose HTTP call failed should
usually let the agent apologise and carry on; hanging up on a caller because
your API returned a 500 is the worst available outcome. Use on_error on the
failing operation instead — see the operation tree.Next
Transfer
Handing the caller to a person instead of hanging up on them.
Speech operations
say, generate_reply and when a line needs wait_for_playback.Close reasons
Every reason a call can end, and what each one means.