Skip to main content

04 — Variables & Conditions

4.1 The state model​

Call state is one flat key→value map. In order of arrival:

  1. Metadata defaults — every key in default_metadata (give every custom variable a default; use null for "empty by default").
  2. Contact/context values — supplied per call by the platform (phone, contact_name, …).
  3. Collected answers — stored under the collecting goal's name the moment they're detected.
  4. Overrides — the values action (03-tools §3.3) and webhook responses write any key at any time. Writing an empty value clears a collected answer (and re-opens its goal).

Booleans are 'yes'/'no' throughout. Value lifetime is normally the whole call; lifecycle_scope: "turn" on a goal clears its value at the next contact turn, and lifecycle_scope: "<goal name>" clears it as soon as a goal outside that container starts (lifecycle_turns exists in stored configs; leave untouched).

4.2 Placeholders​

The rule: {bare_key} for your own variables and collected answers; %name% (still inside braces when formatted into text: {%agent_name%}) is reserved for built-ins. Never invent new %…% names.

Built-in catalog​

Call & agent:

PlaceholderValue
%agent_name% / %company_name%the agent's name / the company it represents
%agent_phone_number%number used for the current call
%call_type%phone_inbound / phone_outbound / web
%is_voice%yes/no
%call_result%current call result (03-tools §3.4)
%parent_call_sid%set on a transfer child call
%turn_number% / %turn_role%current turn index / user or agent
%user_message% / %user_message_lower%the contact's last utterance

Contact: phone, contact_name (first name — always this key), contact_last_name, contact_full_name, timezone_name, contact_source, %contact_discovered% (a new contact was discovered mid-call). The platform's CRM field names — firstName, lastName, timezone — are labels in the script editor only; the engine resolves the contact_* / timezone_name keys, and {firstName} renders as an empty string.

Date & time (in the contact's timezone): %today% (with year), %today_short%, %today_iso%, %now%, %now_iso%, %time%, %this_week% / %next_week% ("Week of {start}"), %utc_minute% (minute-of-week in UTC, for working-hours conditions), %in_transfer_working_hours% (yes/no; unset when transfer hours aren't configured).

Goal-relative (resolve against the goal the text/condition sits on): %self% (its collected value), %self_name%, %parent_name%, %active_goal%, %parent_goal%, %parent_goal_value%, %performed% (yes/no), %performed_count%, %trigger_count%, %collected_count%, %active%, %triggered% (this goal is being triggered this turn), %triggered_goal% (name of the goal the contact just triggered). Dotted form reaches another goal: %email.performed%, %interested in offer.collected_count%.

Control knobs, set in default_metadata:

KnobEffect
%call_intro%very brief self-introduction only — spoken before verification, so never a question and nothing about the contact (05 §5.1)
%speaker_verification_question%the contact-verification question — leave unset (built-in default) unless genuinely necessary
%speaker_verification_acknowledge% / …_callback%acknowledgement after verifying the contact (outbound / callback calls)
%inbound_welcome_message%how inbound calls are answered — the builder defaults it to the literal {%call_intro%} so both directions share one intro
%inbound_ask_for_name% (yes) / %inbound_ask_for_last_name% (no)proactive name collection on inbound calls
%voicemail_message% / %voicemail_disabled% / %voicemail_count%voicemail behavior (05 §5.2)
%human_message%message left with a human gatekeeper
%call_screener_prompt%extra instructions for call screeners
%IVR_TARGET%who/what to ask an IVR for (defaults to contact full name)
%transfer_opening%how to open with a gatekeeper
%allow_speak_on_behalf% (yes)a gatekeeper offering to speak for the contact may continue the call — "no" restricts to the contact
%contact_discovery_ownership% / …_reason% / …_for_named_contacts%contact discovery — setting the ownership turns it on (05 §5.2)
%max_not_interested% (2)"not interested" count that ends the call as do-not-call
%email_collection_message%how the agent asks for an email (flows/email-phone-confirmation.md)
%callback_blocked% / %callback_requested% / %callback_schedule%callback control & state (flows/callbacks.md)
%scheduling_*% / %scheduling-via-*-allowed% / %meeting_scheduled*%meeting-scheduling knobs & state (flows/meeting-scheduling.md)
%child_call_start% / %merge_time%transfer timestamps (flows/hot-transfer.md)
%responses_agent_name%, %responses_reason_for_call%, %responses_company_name%, %responses_are_you_ai%, %responses_dont_like_ai%, %responses_list_source%, %responses_talk_to_a_human%, %responses_is_this_a_scam%, %responses_is_this_call_recorded%built-in Q&A answers — override these instead of writing responses for these questions; typically only reason-for-call and list-source are edited

Formatting specifiers​

Voice output mispronounces raw numbers, dates, and addresses — always format them:

SpecifierDoes
digitsper-digit words with double/triple grouping (555123 → "triple five one two three")
digits_no_groupingper-digit, no grouping
wordsnumbers, dates, URLs to words (2025-01-01 → "January first twenty twenty five")
letters / phoneticspell out letters / NATO-phonetic
local_phoneinternational number → local notation (chain with digits)
date / time / parse_datedate only / time only / parse into a date-time (chain with a strftime spec: {d:parse_date:%B %d})
cleanup / alpha_numeric / stripdrop punctuation / keep alphanumerics / trim
quoteswrap in quotes when non-empty
int / abs / boolinteger / absolute value / true-false
days_todays from now to a date
timezone_shorttimezone abbreviation

Chaining: {%agent_phone_number%:local_phone:digits}. Fallbacks: {value1/value2/default text} — the last segment is always a literal default (use {value1/ } for "or nothing"). Conditional: {condition ? if_true ? if_false} where the branches are field names or quoted literals — {weight > 5 ? weight ? "low weight"}. Nested data uses arrows: {goal_name->sub_key}.

4.3 Conditions language​

One string syntax used by every conditions field (goal, message, choice, transition, tool, response). Store conditions as strings — structured lists appear in some configs but aren't editable in the UI; preserve, don't author (lookups/non-ui-fields.md).

interested in offer = yes and not (budget < 1000 or timeline $date_diff_gt 30)
  • Comparison: single = (not ==), != (also <>, ><), >, <, >=, <=. Values compare as strings for equality, as numbers for ordering.
  • Logic: and, or, not(...) — parentheses are required whenever and and or mix.
  • Bare field = non-empty: email alone means "email has a value" (same as email $any).
  • Text: $contains, $not_contains, $empty / $is_empty (unary), $any / $not_empty, $is_english (unary).
  • Goal state (unary, by goal name): $performed, $not_performed, $completed, $not_completed, $triggered, $not_triggered — e.g. 'reason for call' $performed.
  • Dates (field holds a date; value is days from now): $date_valid, $date_diff_eq, $date_diff_gt, $date_diff_gte, $date_diff_lt, $date_diff_lte — timeline $date_diff_lte 4.
  • Field names with spaces work bare; quote them ('field with and') when they contain operator words.
  • Placeholders are legal as fields or values: %utc_minute% >= 900, %self% != yes.