When creating functions, you can specify return values to control the agent’s behavior dynamically. The return value can either be a string or a dictionary containing specific fields to guide the virtual agent.
You can return a simple string, which will be used as the system prompt for the virtual agent:
Alternatively, you can return a dictionary to specify more detailed and deterministic instructions. The following fields can be used individually or in combination:
content
Equivalent to returning a string, this field specifies the system prompt:
utterance
Specifies the exact phrase the virtual agent will speak after executing the function:
Note: If both content
and utterance
are returned:
utterance
to the user and end the turn.content
rules will apply to the next turn.handoff
Initiates a call handoff after the function executes. This follows the format of a handoff object:
invite
Hands the call off using a SIP INVITE. Configuration fields depend on project telephony integration requirements:
hangup
Ends the call after the function executes:
listen
Return ObjectConfigures the agent to listen on the next turn.
asr.timeout
, you must include an utterance
. Without it, the timeout won’t apply.utterance
so the ASR settings take effect.variant
Switches the conversation to a different variant: