Deny by default
The Code Step validator rejects any function or method call that is not on the allow-list below. Validation runs before execution, so disallowed calls never run. This page covers the Code Step inside a call script. The Code step in an automation pipeline is a separate sandbox with its own list of functions — see Steps.Built-in Functions
print(...) writes a user-facing system note for Code Step diagnostics. It supports multiple values plus sep and end; multi-line output is split into separate system notes. range accepts range(stop), range(start, stop), and range(start, stop, step).
sleep(seconds) pauses the Code Step for that many seconds before it carries on. The call waits with it, so keep pauses short (a second or two), for example to give an SMS reply time to arrive before reading it.
Allowed Methods
get is allow-listed for dictionary-style values, and append is allow-listed for list-building.
Flow Helpers
coalesce(value, default)— returnsdefaultwhenvalueisNoneor""is_empty(value)— true forNone,"",[], or{}is_not_empty(value)— the inverse ofis_emptymap_value(key, mapping, default)— lowercases and strips string keys before lookup
Type Helpers
is_number returns true for int or float, but false for bool.
Object and Path Helpers
{{...}} placeholder syntax for normal variable access. Use these helpers when working with dynamic dictionaries inside the code.
commit_contact_timezone(iana, state, city)— validates an Australian IANA timezone, updates the current contact’stimezoneandlocation, refreshes runtime calendar timezone state, and writes the canonical{{contact.*}}and{{timezone.*}}result variables. With no arguments it reads{{timezone.resolved_iana}},{{timezone.resolved_state}}, and{{timezone.resolved_city}}.commit_composite_outputs()— inside a sub-flow, commits declared parent composite output variables before the sub-flow returns, and returns the sorted output ids it mapped. Outside a composite context it returns an empty list.
Date Helpers
parse_datetime uses Python ISO parsing:
timezone_offset(iana, at) returns the UTC offset for an IANA timezone at a specific datetime. If at is omitted it uses the current datetime; if at has no offset it is treated as local wall time in the supplied timezone. Invalid input returns "".
Random Helpers
random_int(min_value, max_value)— an integer between the bounds, inclusiverandom_choice(values)— one item from a non-empty list, orNonewhen emptyrandom_shuffle(values)— a shuffled copy of the list; the original is not mutated
Voice Helper
voice_id is the identifier of a voice in the Voice Library. It is not the voice’s name.
- Returns
Truewhen the voice was accepted, so you can branch on it. - Returns
Falsewhen the value is not a valid voice identifier. The call keeps the voice it already had, and a note is recorded on the call so you can see it happened. It never stops the Code Step. - The switch is applied as soon as
run()finishes, before the flow moves to the next step.
Language Helper
codeis a language code such as"es"(Spanish),"vi"(Vietnamese) or"ar"(Arabic).set_language("en")switches back to English. Regional English codes such as"en-AU"are accepted and mean English.voice_idis optional. Pass a voice identifier to switch to a voice that speaks the language natively at the same moment. It takes priority over a separateset_voice(...)in the same Code Step.- Returns
Truewhen the request was accepted andFalsefor an unknown language code or voice identifier, so you can branch on it. OnFalsethe call keeps its current language and a note is recorded on the call. It never stops the Code Step. - The switch is applied as soon as
run()finishes, before the flow moves to the next step.
Schedule Helper
True when a routing endpoint’s schedule is open right now, and False when it is closed. endpoint_id is the identifier of a routing endpoint (see Routing Endpoints). The check uses the same schedule the Handoff tool would use: the endpoint’s own schedule, or the default from its department, location or team. It is evaluated at the moment the Code Step runs, so a call that crosses closing time gets the right answer.
True when no schedule applies, so make sure the identifier is correct.
Turn-Timing Helpers
idle_offset(seconds)addssecondsto how long the assistant waits in silence: both the wait before it re-prompts a quiet caller and the wait before it ends a silent call. See Silence Tolerance. The quick move-on after a statement (Fast Response) is not affected.endpoint_offset(seconds)addssecondsto how long the assistant waits after the caller stops speaking before it replies. See Response Eagerness. The wait never drops below the built-in minimum.
- The last call wins; the offsets don’t add up.
idle_offset(0)orendpoint_offset(0)clears the offset. - Negative values shorten the waits.
- They return
Truewhen accepted andFalse(with a note on the call) for a value that isn’t a number. They never stop the Code Step.
Routing Helpers
service_location_propose takes the caller’s own words for a state and suburb and returns the best-matching locality. service_location_resolve takes a four-digit postcode. Both return a dictionary with a status and the routing endpoints that cover the area, and never raise an error: a failed or slow lookup returns {"status": "error", ...}. Most scripts should use the tool rather than calling these directly.
Reading the Transcript
Read what has been said so far through variables rather than a function:{{call.transcript.last_user}}— the caller’s latest turn, as a string{{call.transcript.last_ai}}— the assistant’s latest line, as a string{{call.transcript.items}}— the whole conversation as a list of turns, each a dictionary withrole,content,step_nameand more
call variables for the full shape.
Regex Helper
JSON Helpers
Not Allowed
importorfrom ... import ...- Filesystem, network, shell, or subprocess access
- Reflection and dynamic execution —
eval,exec,compile,open,__import__ - Dunder names or dunder attributes
- Lambdas, nested functions, classes
- Any unlisted function or method
Next Steps
- Code Step overview — The
run()contract and variables - Examples — Common patterns and troubleshooting

