This page requires Python familiarity. Variables are set and read in Python functions.
conv.state object within a function. You can choose a name for your variable
and update its value to anything you want like so:
Built-in state keys
Theconv.state object comes pre-populated with system-managed keys. These are set automatically by the platform and available in every conversation:
| Key | Type | Description |
|---|---|---|
from_ | str | Caller’s phone number (note the trailing underscore — from is a Python reserved word) |
to | str | Called number (callee) |
call_sid | str | Unique call session identifier |
asr_lang_code | str | Active ASR language code (e.g., "en-US") |
tts_lang_code | str | Active TTS language code (e.g., "en-US") |
shared_id | str | Shared identifier for correlating conversations across systems |
handoff | object | Handoff configuration object (destination, reason, SIP method) |
disable_recordings | bool | Whether call recording is disabled |
stop_recording | bool | Whether recording has been stopped mid-call |
use_tts_for_responses | bool | Whether to use TTS instead of pre-recorded audio |
asr_provider | str or dict | Override the default ASR provider |
asr_config | dict | Custom ASR configuration |
listen_for_sms | bool | Whether SMS listening is enabled (default False) |
Prompt templating
Variables can be used within function calls and injected dynamically into prompts shown to the LLM. To inject a variable’s value into your prompt, use the syntax$variable_name. The system will replace this placeholder with the variable’s value wherever it matches.
Example:
In your start function, you can write:
$current_date.
…becomes:
The current date is September 06, 2024.
When using variable templating, ensure the stored value is readable by the LLM. Complex objects like dictionaries or datetime
will be stringified automatically.
Environment configuration
You can use theconv.env property to define environment-specific functions and activate test features in sandbox or
pre-release environments.
For example:

