Return values
When creating functions, you can specify return values to control the assistant’s behavior dynamically. The return value can either be a string or a dictionary containing specific fields to guide the virtual assistant.
String return
You can return a simple string, which will be used as the system prompt for the virtual assistant:
Dictionary return
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 assistant will speak after executing the function:
Note: If both content
and utterance
are returned:
- The assistant will stream the
utterance
to the user and end the turn. - The
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
Configures the assistant to listen in the next turn. This uses the Listen configuration from policy:
variant
Switches the conversation to a different variant: