Skip to main content
A common pattern in voice agents: offer to send the caller a link by SMS, but transfer to a live agent if SMS isn’t an option or the caller asks for it. The decision lives in a function so it is deterministic, not subject to LLM interpretation.

Files involved

Testing via poly chat: caller_number will be emptyconv.state.caller_number is populated from inbound caller ID, which is only available on a real voice call. When testing with poly chat, caller_number is always empty regardless of --channel, so wants_sms: True will always hit the “unable to send” branch.To exercise the SMS path locally, mock the value in start_function.py:

config/handoffs.yaml

The destination value passed to conv.call_handoff must match the name of a handoff defined in config/handoffs.yaml. All handoffs are defined in a single file under the handoffs key.
See the handoffs reference for all SIP method options and field details.

Per-environment sender number

If the sender number differs between environments, the simplest approach is to configure env_phone_numbers directly in config/sms_templates.yaml, with no code required:
The keys are the environment ids: sandbox for Sandbox, pre_release for Staging and live for Live. The platform selects the right number automatically when conv.send_sms_template() is called. See the SMS setup reference for full template configuration options. If you need more control, for example when using conv.send_sms() to send free-form content rather than a template, you can read conv.env directly. It returns sandbox, pre-release (the Staging environment) or live:
Use secrets for sender numbers in productionAvoid hardcoding phone numbers in function code. Store them as secrets and retrieve with conv.utils.get_secret("sms_sender_live").

SMS templates

Structure and variable substitution for SMS templates.

Handoffs

Configure transfer destinations used by conv.call_handoff.

Functions

Return values, conv API, and function structure.

Conversation object reference

Full reference for conv.send_sms_template, conv.call_handoff, conv.env, and all other conv attributes.

Secrets (platform)

Store sensitive values like sender numbers and retrieve them at runtime with conv.utils.get_secret.

SMS setup (platform)

Configuring SMS channels, sender numbers, and template structure.
Last modified on September 15, 2026