00 — The Model
0.1 What a script is
A script is one JSON document:
{
"default_metadata": { "{variable}": "default value", ... },
"goals": [ <Goal>, ... ]
}
It is reusable across contacts: anything contact-specific enters as a variable ({contact_name}, {event_date}) with a default in default_metadata. See 04-variables-and-conditions.
A goal's name is its primary, user-facing identity. The name is the lookup key for transition targets and event-transition triggers, the storage key of the collected answer, the variable usable in conditions and placeholders, the detection label matched against the contact's reply, and a valid "active during" scope reference. Names must be non-empty and unique, and they are matched case-sensitively.
Name goals after the value they represent, not the step: "email", not "collect email for updates". Detection compares the name against what the contact said, so a name that isn't semantic breaks answer detection (see 02-dialogue §2.6).
Goals also carry an id (g7) — backend-assigned, never user-facing. It is the unique handle for editing: address a goal by id in edit tools; use the name everywhere else — replies to users, transition targets, conditions, placeholders.
Four control layers:
- Identity & settings — the agent's identity prompt, included in every LLM call: who the agent is, its personality, and its core objective. Plus agent-level settings such as the voice model.
- Goals — the flow: what the agent says, asks, and does, stage by stage. One goal is active per turn.
- Responses — state-free Q&A pairs answered regardless of the active goal (02-dialogue §2.8).
- Knowledge — documents and site content the agent may draw on when answering questions; not part of this config.
0.2 The turn loop
Everything the engine does per contact turn, in order. Each step's rules live in the linked part.
- Contact speaks → state updates. Voice intents (repeat/continue/interruptions) are handled first; entities are extracted; state variables update.
- Answers detected — the active goal's question first, then passively across every eligible goal whose value appears in the reply → 02-dialogue.
- Reactions evaluated — trigger phrases, event transitions, agent-decided transitions can claim the next goal → 01-flow.
- Next goal selected — a reactive winner takes it; otherwise proactive order picks the next eligible goal → 01-flow.
- Reply composed — acknowledgement + appended goals' content + the selected goal's message or instructions → 02-dialogue §2.3.
- Tools run at each state change — webhooks, values, call results fire on their configured event timing → 03-tools.
0.3 Running example
Referenced throughout the docs as "the running example":
{
"default_metadata": { "%company_name%": "Acme", "offer": "our spring discount" },
"goals": [
{ "name": "Place a call", "goal_type": "callStart" },
{ "name": "Call opening", "goal_type": "identifyContact" },
{
"name": "interested in offer",
"goal_type": "ask",
"value_type": "approval",
"messages": [
{ "message": "I'm calling about {offer} — is that something you'd be interested in?" },
{ "message": "Would you be interested in {offer}?" },
{ "message": "Is {offer} something you'd be interested in?" }
],
"choices": [
{ "name": "yes" },
{ "name": "no", "goals": [
{ "name": "goodbye", "goal_type": "say",
"messages": [{ "message": "No problem, thanks for your time!" }],
"fulfillment": [{ "timing": "performed", "voice_action": "hang_up", "call_result": "disqualified" }] }
]}
]
},
{
"name": "email",
"goal_type": "ask",
"value_type": "email",
"messages": [
{ "message": "What email should I send the details to?" },
{ "message": "Where should I email the details?" },
{ "message": "Which email address works best for you?" }
]
}
]
}
Open → qualify → collect. Every script starts with the two pinned, built-in goals — callStart and identifyContact that are configured through default_metadata (05 §5.1). interested in offer stores yes/no under its own name; the no choice branches into a terminal goodbye — which is why email carries no condition: reaching it already means the happy path (01-flow §1.8). Note the message shape: an ask goal's written messages come in threes and rotate on retries; the first variant of interested in offer carries the intro and the question, the later ones only the question; the goodbye — like any say goal — is a single line (02-dialogue §2.1).