This page requires Python familiarity. The start function is written in Python and runs before every call’s greeting.
When to use the start function vs. a flow step
Not every API call belongs in the start function. Use this decision framework:| Scenario | Where to place it |
|---|---|
| Data needed before the greeting (e.g. caller lookup for a personalized greeting) | Start function |
| Fast, reliable API (<1s response time) | Start function — reduces mid-conversation latency |
| Slow or unreliable API (external CRM, third-party lookup) | First flow step — protects the greeting |
| Data only needed mid-conversation | Flow step |
Key features
- Synchronous execution: Completes before the greeting plays
- Context preparation: Stores data for use throughout the conversation
Use cases
Detect channel type
Detect channel type
Use
conv.channel_type to determine whether the conversation is voice, webchat, or another channel — then branch accordingly. Disable call transfers for webchat, set a different persona, or inject channel-specific prompts.Read connection metadata
Read connection metadata
Capture SIP headers (voice) or URL parameters (webchat) to determine the caller’s origin — for example, mapping a dialled number to a business branch.
Retrieve date and time
Retrieve date and time
Initialize state with the current date, time, or day of the week for timestamping or scheduling logic.
Make API calls
Make API calls
Fetch external data such as user preferences, account information, or customer records to preload personalized context.
Set the active variant
Set the active variant
Use
conv.set_variant() to route the conversation to a specific variant based on SIP headers, callee number, or other metadata. This is the standard way to configure multi-site agents.Detect language and branch
Detect language and branch
Read a language header or parameter and configure the agent accordingly — set the variant, choose a language-specific TTS voice, or store language-specific prompt rules in state.
Read outbound call metadata
Read outbound call metadata
For outbound agents, read lead data or campaign metadata from SIP headers injected by the calling platform.
Read integration attributes
Read integration attributes
Access
conv.integration_attributes to read metadata passed from external integrations (e.g. DNIs pooling, Chat API).conv.integration_attributes can only be read in the start function. Extract values and store them in conv.state for use later.Configure a TTS provider
Configure a TTS provider
Set the TTS provider in the start function. Supported providers include Cartesia, PlayHT, and Rime. See voice configuration and function classes.
Implementation example
Below is a Python implementation of the Start function:Return values
The start function supports the same return values as other functions. The most common patterns are:Empty string (default)
Returnstr() when the start function only needs to set up state. The agent greeting defined in the Agent settings will play as normal.
Dynamic greeting
Return anutterance to override the default greeting with a dynamically generated message. This is useful when the greeting depends on data fetched during the start function (e.g. the caller’s name or site-specific wording).
Listen configuration
Return alisten object to configure ASR behaviour for the first turn.
Best practices
- Keep it fast: The start function blocks the greeting. Target under 1 second total execution time. Move slow or unreliable API calls to a flow step.
-
Never hardcode credentials: Use
conv.utils.get_secret()for all API keys, tokens, and passwords. Hardcoded credentials in function code are a security risk and may be exposed in logs or version history. -
Error handling:
- Handle missing or malformed data and avoid runtime errors.
- Provide fallbacks for incomplete or invalid information (like missing SIP headers or unavailable APIs).
-
State initialization:
- Predefine and initialize all state variables needed for the conversation to avoid undefined behaviors.
-
Extract
conv.integration_attributeshere — they are only available in the start function.
-
Contextual relevance:
- Only include setup steps that are directly relevant to the conversation’s purpose.
- Avoid overloading the start function with unnecessary logic.
Common patterns
Multi-site variant routing
Multi-site variant routing
The most common advanced use of the start function is routing to a variant based on the dialled number, SIP headers, or other metadata. This is how multi-site agents (hotels, restaurant chains, retail) determine which location’s content to use.Full article: Variant management
Language detection and branching
Language detection and branching
Read a language code from SIP headers or integration data, set the appropriate variant, and configure a language-specific TTS voice.
Channel-type branching
Channel-type branching
Use
conv.channel_type to disable voice-only features (like call transfers) for webchat, or to inject channel-specific prompts.Multi-voice configuration
Multi-voice configuration
The start function is where you configure which TTS voice the agent uses for a given call. This is required when running multiple voices across variants or channels, because the Voice page UI may not expose all available providers.Full article: Multi-voice
Dynamic user identification
Dynamic user identification
Use
conv.caller_number or metadata from an API call to personalize the greeting or preload account context.Preloading context
Preloading context
Make a fast API call to fetch scheduling information, past bookings, or account details so the agent has context from the first turn.

