Platform-Specific Functions
Based supports different deployment platforms (chat, voice, email, SMS) and provides specialized functions for each platform. These functions allow you to take advantage of platform-specific capabilities.Voice Deployment Functions
When your Based agent is deployed for voice conversations, you can use these special functions to control call flow:transfer(phone_number, options?)
Transfers the current call to another phone number. Optionally supports dialing extensions after the call connects.
Syntax:
phone_number(string): The destination phone number to transfer toextension(string, optional): Simple extension digits to dial after the call connectsoptions(dict, optional): Advanced transfer options with the following keys:extension(string): DTMF digits to send after the call connectspauseSeconds(number): Seconds to wait before sending digits (default: 1 second)
When transferring to extensions, the
pauseSeconds parameter controls how long to wait after the call connects before dialing the extension digits. The default of 1 second works for most phone systems, but you may need to increase this for systems that have longer greeting messages or slower IVR responses.end_call()
Ends the current call immediately. Use this to gracefully terminate a voice conversation after completing the interaction.
Syntax:
click_ivr(digits)
Sends DTMF tones (keypad presses) during an active call. This is useful for navigating IVR (Interactive Voice Response) menus programmatically, such as pressing “1” for sales or entering an account number.
Syntax:
digits(string): The DTMF digits to send. Can include numbers 0-9,*, and#
The
click_ivr function sends DTMF tones immediately. If you need to wait for an IVR prompt before sending tones, use a say statement or add appropriate delays in your flow logic.