What are Structured Tests?
Structured Tests is a specialized evaluator type that allows you to create dynamic, rule-based test scenarios. Unlike traditional evaluators that follow a linear script, Structured Tests evaluators can adapt their behavior based on what the agent says during the conversation. This makes them ideal for testing complex workflows where the conversation can take multiple paths depending on the agent’s responses. Structured Tests are the default evaluator format. See Evaluator Formats.When to Use Structured Tests
Use Structured Tests evaluators when you need to:- Test branching conversations: Handle different conversation paths based on agent responses
- Simulate decision trees: Test scenarios where user responses depend on what the agent asks
- Create adaptive evaluators: Build evaluators that can handle unexpected agent responses
- Test IVR (Interactive Voice Response) flows: Simulate interactive voice response systems with menu options
- Validate error handling: Test how agents handle various user inputs and edge cases
Example Use Case
Structure
A Structured Tests evaluator has three main parts:1. Role
Therole defines who the testing agent is pretending to be.
2. First message
first_message is what the testing agent says to open the call. It is always spoken word-for-word. Leave it empty ("") when the main agent speaks first.
3. Conditions
Theconditions array defines the rules for the rest of the conversation. Each condition specifies:
- When a certain situation occurs (
when) - What the testing agent says (
say) - Optionally, what it says on the following turns (
then)
Changes from the earlier format
Structured tests used to be written as id-based rows. Responses now return the format on this page. The earlier format is deprecated: it is still accepted when you create or update an evaluator, so existing integrations keep working, but write new evaluators in the current format.Fields
{"say": "...", "then": ["...", "..."]}. <ai_generated> is not allowed in the first message.Validation Rules
The backend enforces the following constraints on all Structured Tests evaluators. Violations return a validation error that names the exact place in your payload, such asfirst_message, conditions[2].say or conditions[0].then[1].
1. The first message is verbatim
1. The first message is verbatim
first_message (and first_message.say) is always spoken word-for-word, so it cannot contain <ai_generated>. Its then steps can.2. Every condition needs when and a non-empty say
2. Every condition needs when and a non-empty say
when is required, and say must contain spoken words or an action tag such as <silence>, <hold>, <audio> or <endcall>. Empty, whitespace-only, punctuation-only and formatting-only steps are rejected. Use <silence time="5s"/> or <hold time="5s"/> for an intentional pause. Only first_message may be empty.3. <ai_generated> wraps the whole step
3. <ai_generated> wraps the whole step
<ai_generated> must wrap the entire step. It cannot be partial, nested, or empty.4. Only known fields
4. Only known fields
when, say and then; first_message as an object accepts only say and then. Unknown fields are rejected — for example, conditions[0]: unknown field(s) fixed. Allowed: when, say, then.5. Language required
5. Language required
scenario_language. Set it by assigning a personality with a language configured. If you provide a personality, the language is inferred automatically; if no personality is set, scenario_language must be explicitly provided.This also applies when changing an existing evaluator’s type to Structured Tests.First Message
first_message is the line the testing agent opens the call with:
then steps:
<silence> always gives way when the main agent starts talking, so a greeting that arrives during a leading <silence> drops the whole line; spoken text gives way according to the personality’s interruption settings. The conversation then continues through the other conditions as usual. To let the main agent greet first and then say an exact line, leave first_message empty and put the line on a condition that matches the greeting:Follow-up Steps (then)
A then step fires on the next turn after the step before it. It does not fire immediately. The sequence is:
- The testing agent delivers the condition’s
say - The main agent receives it and replies
- The first
thenstep fires — the testing agent delivers it - The main agent replies, and the next
thenstep fires, and so on
then has two key uses:
- Multi-part responses: send several messages across consecutive turns after a single trigger
- Scripted sequences: deliver an exact sequence of messages from the testing agent, turn by turn, without needing any conditions to match — the sequence fires automatically regardless of what the main agent says
then steps. A then step never fires in the same turn as the step before it — one reply from the main agent always comes in between.Verbatim vs AI-generated steps
Every step (say or a then entry) is one of two kinds:
Verbatim (default)
The testing agent says the text exactly as written.AI-generated
Wrap the whole step in<ai_generated>...</ai_generated> and the text becomes an instruction the testing agent interprets to produce a natural reply.
When to Use Each
Use <ai_generated>
- Natural, varied responses
- Testing agent adaptability
- When exact wording doesn’t matter
Use verbatim (default)
- Exact phrases required
- Testing specific keywords
- Compliance testing
- Reproducible test cases
- The first message — always verbatim
- Steps containing tags
Supported Tags
Structured Tests supports a variety of special tags inside a step (first_message, say, or a then entry) to control conversation flow and behavior.
Tags can be combined with text and other sibling tags. They run from left to right; do not nest tags inside one another, except inside a regional <voice ...>...</voice> block. <ivr> and <voicemail> must be the whole step.
Communication Tags
<ivr> - Interactive Voice Response
<ivr> - Interactive Voice Response
<ivr>. When a scenario contains the <ivr> tag, any DTMF digits pressed by the main agent (the agent being tested) are captured and appear in the transcript. This lets you write conditions that detect the exact digit pressed — for example, "The main agent pressed 1" — rather than relying on speech detection alone. Both <ivr> and <dtmf> can appear in any step, not just the first message.text: The IVR message to play (required)
<ignore_interruptions> - Protected Playback Span
<ignore_interruptions> - Protected Playback Span
<audio> clips, <hold>/<silence> pauses, or any mix. The typical use is a multi-part IVR menu of clips and pauses.<ivr>, this is a block tag scoped to a span: content goes between the opening and closing tags, it can appear more than once per step, and normal text or tags can come before and after it.What the main agent’s speech does during the span:- It does not interrupt playback or abort the remaining clips.
- It does not trigger a reply from the testing agent — during the span or after it ends.
- It is still transcribed and included in evaluation, so metrics can judge what the agent said over the menu.
<voicemail> - Voicemail Greeting
<voicemail> - Voicemail Greeting
text: Voicemail greeting message (optional) - if omitted, only plays beep; if provided, cannot be empty
<endcall> - End Call
<endcall> - End Call
Speech Control Tags
<silence> vs <hold> — both add pauses, but behave differently:<silence> when you want the conversation to feel natural and allow the main agent to jump in. Use <hold> when you need a guaranteed delay before the next message.<silence> - Add Pauses (interruptible)
<silence> - Add Pauses (interruptible)
time: Duration of silence (required) - format: “Xs” where X is a number (e.g., “1s”, “2.5s”)
<hold> - Hold Between Messages (not interruptible)
<hold> - Hold Between Messages (not interruptible)
time: Duration to wait before next message (required) - format: “Xs” where X is a number (e.g., “5s”, ”10s”)
<spell> - Spell Out Text
<spell> - Spell Out Text
<speed> - Control Speech Speed
<speed> - Control Speech Speed
<speed> tag or the end of the step. Add text to scope it to just those
words instead — the previous speed resumes afterwards:<speed>...</speed> block form.Attributes:ratio: Speed multiplier (required) - Valid range: 0.1 to 2.0
0.8–1.2 keeps speech natural; beyond that it becomes a stress test.text: Words to scope the ratio to (optional)
Cannot contain other tags — use the point form above if you need tags inside.
<volume> - Control Volume
<volume> - Control Volume
<speed>, it may appear anywhere and holds until the next <volume> tag or
the end of the step, and text scopes it to just those words:<volume>...</volume> block form.Attributes:ratio: Volume multiplier (required) - Valid range: 0 to 2
Examples:"1.5"for 50% louder,"0.5"for 50% quieter. Above1.0the output is clipped against the TTS signal, so prefer<= 1.0unless distortion is what you are testing.text: Words to scope the ratio to (optional)
<voice> - Switch the Testing Agent's Voice
<voice> - Switch the Testing Agent's Voice
text changes
every later utterance — including later steps and conditions — until another persistent <voice> tag
changes it. This is the persistent form.This is how you put more than one speaker in a single simulated call: a caller handing the
phone to a family member, a supervisor taking over, or a different person picking up.text to speak only that text in the selected voice; the previous
voice resumes immediately afterward.<silence>, use an opening and closing
block instead. Nested inline tags are allowed only inside this regional voice block.text with the opening/closing form. All <voice> tags require
a verbatim step.Attributes:-
provider: Voice provider (required) -cartesiaor11labs. Must be the same provider the evaluator already runs on. -
id: Voice ID (required) - must belong to that provider: -
model: TTS model (optional) - omit it to use the provider’s default:sonic-3.5for Cartesia,eleven_turbo_v2_5for ElevenLabs.
Interaction Tags
<dtmf> - Send DTMF Tones
<dtmf> - Send DTMF Tones
digits: DTMF digits to send (required) - e.g., “123”, “456#”, “*9”
<dtmf digits="{{test_profile.customer_number}}#" />.
The value is resolved per run and any formatting in it is stripped before the
tones are sent. See DTMF testing.<send_sms> - Send SMS
<send_sms> - Send SMS
text: SMS message content to send (required)
<client_message> - Send an RTVI Client Message
<client_message> - Send an RTVI Client Message
t: App-defined RTVI message type (required). Use the exact type your agent expects; Cekura does not invent or validate application-specific types.d: Optional app-defined payload. JSON is decoded before it is sent. Use single quotes around the attribute when the JSON contains double quotes, as in the example above.
<interruption> - Interrupt After Timeout
<interruption> - Interrupt After Timeout
time: Duration to wait before interrupting (required) - format: “Xs” where X is a number (e.g., “3s”, “5.5s”)
Environmental Tags
<background_noise> - Background Sounds
<background_noise> - Background Sounds
sound: Sound name (required) - see supported sounds belowvolume: Volume level (optional) - between 0 and 1.0; default applies if not specified
<background_noise> tag in evaluator steps. To use a custom audio file URL as background noise (e.g., https://your-domain.com/noise.mp3), use the Custom URL option in the Background Noise dropdown when creating or editing a personality — no tag required.<noise> - Play Sound Effects
<noise> - Play Sound Effects
sound: Sound name (required) - a name from the sound library below, or a directhttps://URL to an audio filevolume: Volume level (optional) - between 0 and 1.0time: Duration in ms (optional)
office, beep, cough1, cough2, female-crying, male-crying, ringback. The library grows over time - newly added sounds work with the same syntax as soon as they are available.ringback is ~6 seconds of a phone ringback tone (one ring, the gap, and the start of the next). The crying sounds are ~10 seconds of a person sobbing. Use them to check whether your agent notices a caller in distress and asks if everything is okay; shorten with time if needed.<network_simulation> - Simulate Network Issues
<network_simulation> - Simulate Network Issues
packet_loss: Packet loss percentage (required) - e.g.,"5"= 5% loss
Custom Functions
Functions let the testing agent fetch live data from your systems during the call and use it in what it says — look up an order, pull an account record, then respond with the real values instead of invented ones. Declare functions once in a top-levelfunctions array (a sibling of role and conditions), then use them from any step after the first message.
Function fields
_, -; up to 64 characters.true (the default), the function runs once automatically at the start of the call, in the background — its values are ready before the conversation needs them. Set false to run the function only when a condition invokes it with a <function> tag.{{test_profile.*}} substitution. Must be an http(s) URL that is publicly reachable — internal and loopback addresses are refused at call time.POST only). Objects and arrays are sent as JSON; strings are sent as-is.When a function runs
say or any then step (including first_message.then), verbatim or <ai_generated>.
Using the response
Two ways to get fetched values into the testing agent’s replies:-
Value placeholder —
{{function.lookup_order.status}}(verbatim steps only). Substitutes one mapped output into the exact spoken text: -
AI-generated steps — no placeholder needed. In an
<ai_generated>step, the testing agent is automatically given the function’s results (your named outputs plus the response) and phrases its reply from them:
"Let me check. <function name=\"lookup_order\"/> It shows as {{function.lookup_order.status}}."Response mapping (JSONPath)
Eachresponse_mapping entry gives a short output name to a value in the JSON response. An entry is either a path string, or an object with path and a default:
Chaining functions
A function’sconfig can reference an earlier function’s outputs, so one call can feed the next — for example, look up a customer, then verify with the fetched name:
auto_run or a tag on an earlier condition.
If the call fails
A failed function never breaks the conversation. On a timeout, an error response, or an unreachable URL:- Mapped outputs fall back to their declared
default. - A placeholder with no default is spoken as-is (
"...status is {{function.lookup_order.status}}") — declare defaults for anything a verbatim step references. - In
<ai_generated>steps, the testing agent is told the lookup failed, so it doesn’t invent values.
Rules
- Function
names must be unique;<function>tags and{{function.*}}placeholders must reference a declared function. - Placeholders require a verbatim step, and the key must be an output declared in that function’s
response_mapping. - Neither tags nor placeholders may appear in the first message itself — use
auto_runand reference the values from a later step.
auto_run function — see Example 5 below.
Attached Audio
Attach a pre-recorded audio clip to a scenario and the testing agent plays the recording instead of speaking the text with TTS when a referencing condition fires. A single clip can be referenced from any number of conditions and even multiple times within one step. Use it when the exact voice, accent, tone, or non-speech sound matters — reproducing a real caller’s recording, a specific IVR prompt, background audio a synthetic voice can’t recreate, or a regression case captured from a live call.<ai_generated> steps — those are meant to vary, and a recording is fixed by definition.How it works
- You upload an audio file to the scenario, optionally attaching it to a condition (from the editor UI or the API). Each clip gets a human-readable name that becomes its id — for example,
greetingorhold-music. - Cekura transcribes it automatically in the background — this is why a clip is briefly processing before it’s ready to use.
- Reference the clip from any number of verbatim steps by pasting its tag:
<audio id="greeting"/>. You can write this tag by hand, or let the upload endpoint insert it for you when you passcondition_id. - When the condition fires, text, recordings, and tags run from left to right. The same clip plays wherever it is referenced.
Attaching audio (UI)
In the Structured Tests editor, each verbatim step has an Attach audio at cursor control:- Place the cursor where the recording should play, click Attach audio at cursor, and pick a file. You can attach more than one recording to the same step.
- When processing finishes, each recording shows its read-only transcript and an audio player. Replace or Remove affects only that recording; surrounding text and tags stay in place.
- While any attached clip is still processing (or has failed), runs are blocked for that scenario until it resolves — see Statuses & run gating.
Attaching audio (API)
Five endpoints on the scenario manage attached audio. Clips are uploaded asmultipart/form-data, or as a JSON body with the file base64-encoded (see file_name and content_base64 below).
status: "pending"; poll the list endpoint until it becomes ready. Each entry — from the list, upload, replace and edit responses — looks like:
steps lists every place the clip is used, as paths into the evaluator (first_message, conditions[1], conditions[0].then[0]), alongside the numeric condition_ids.
The scenario’s GET response also includes a read-only condition_audio summary with every clip’s tag and where it is used, so an author editing instructions directly can discover which clip ids exist:
condition_ids (and the upload’s condition_id) number the steps from 0 in reading order: first_message is 0, followed by its then steps, then each condition’s say followed by its then steps.
<audio> tag and as its stored object name. Letters, digits, underscores and hyphens, max 64 characters; must be unique within the scenario (case-insensitive). Omit to derive a readable name from the filename (lowercased, hyphenated, trimmed to 32 characters).<audio id="..."/> from as many steps as needed.file. The clip’s filename including extension, for example greeting.mp3.file. The audio file as base64, either raw or as a data:audio/mpeg;base64,... data URL. The same size and format limits apply.condition_id. The complete step text with one <audio /> marker where the new recording should be inserted. Existing managed audio tags must remain in the template.condition_id. Points that step’s existing tag at the new clip. To swap a clip’s audio while keeping every reference to it, PUT to condition-audio/{audio_id}/ instead.Editing a clip’s transcript
PATCH on a clip corrects its transcript and, optionally, its word timings (words). The testing agent records the corrected text as what it said when the clip plays.
wordssent: stored as given. They must spell out the transcript (case, spacing and punctuation are ignored), be in playback order, have eachendat or after itsstart, and end within the clip’s duration. At most 5,000 words of up to 100 characters each; otherwise the request returns 400.wordsomitted, same word count: every word keeps its current timing.wordsomitted, different word count: the new words are spread across the span the old ones covered.- Only a
readyclip can be edited. A pending, processing or failed clip returns 409. - Replacing the clip’s audio transcribes it again and discards the edit.
- Runs already in progress are unaffected; the edit applies from the next run.
timing_source showing where its timings came from: deepgram (measured), interpolated (spread evenly) or manual (sent with an edit).
Statuses & run gating
Each attached clip moves through these statuses:ready — the run is rejected with a clear message ("still transcribing — wait for it to finish" for pending/processing, "failed to transcribe — retry or remove it" for failed).
Complete Examples
Example 1: Appointment Cancellation
Example 2: IVR Navigation
- Inbound (main agent IS the IVR): Use
<dtmf>to navigate the IVR menu played by the main agent.<dtmf>can appear in any verbatim step. - Outbound (testing agent simulates an external IVR): Use
<ivr text="..." />to play the IVR menu.<ivr>can appear in any verbatim step. When the scenario contains<ivr>, DTMF digits pressed by the main agent appear in the transcript — write your conditions using the specific digit (e.g.,"The main agent pressed 1").
Example 3: Multi-Part Response with Follow-ups
- Testing agent sends the first message: “Hi, I need help with my order”
- Main agent replies
- The first
thenstep fires — testing agent mentions the missing confirmation email - Main agent replies
- The second
thenstep fires — testing agent asks about expedited shipping - Main agent replies — the condition matches and fires
Example 4: Using Advanced Tags
Example 5: Live Data via a Custom Function
Oneauto_run function feeding both kinds of step: the first condition drops a fetched value into a verbatim step with a {{function.*}} placeholder, and its then step lets the testing agent phrase an AI-generated reply from the same response — no placeholder needed.
- As the call connects,
lookupruns once in the background (auto_run) — say it returns{"status": "shipped", "customer_name": "Jane Doe"} - Testing agent sends the first message: “Hi, I’d like to check on my order.”
- The agent asks for the name — the first condition’s verbatim
sayfires with the placeholder substituted: “It’s under Jane Doe.” - The agent replies — the AI-generated
thenstep fires; the testing agent is given the lookup results automatically and phrases them naturally: e.g. “On my side it shows as shipped — is that what you see?” - The agent confirms — the second condition closes the call
defaults take over: the first condition speaks “It’s under unknown.” and the testing agent in the then step is told the lookup failed rather than inventing a status.
On-demand variant (auto_run: false): to run the lookup only at a specific point in the flow instead of at call start, turn off auto_run and invoke it with a tag — the function completes before the rest of the step is spoken:
Best Practices
Clear Conditions
when so it clearly describes what the agent does to trigger it.- ✅ “The agent asks for your email”
- ❌ “Email”
Specific Steps
- ✅ “
Provide your email address ” - ❌ “
Answer the question ”
Logical Flow
first_message, then follow natural conversation progression.Common Patterns
Pattern 1: Conditional Branching
Handle different paths based on agent response:Pattern 2: Information Gathering
Progressively provide information as requested:Pattern 3: Scripted Sequence with then
Use then to deliver an exact sequence of messages across turns, with no conditions to match — each step fires automatically on the next turn after the main agent replies, regardless of what the main agent says:
Tips
Troubleshooting
Validation error: <ai_generated> is not allowed in the first message
Validation error: <ai_generated> is not allowed in the first message
first_message: the first message is always said verbatim; <ai_generated> is not allowed.Solution: Write the opening line out word-for-word. If you want an improvised step right after it, put it in first_message.then:Validation error: <ai_generated> must wrap the whole step
Validation error: <ai_generated> must wrap the whole step
<ai_generated> part, or nests one inside another.Solution: A step is either entirely verbatim or entirely AI-generated. Split mixed content into two steps using then:Validation error: a tag in an <ai_generated> step
Validation error: a tag in an <ai_generated> step
conditions[0]: action contains <endcall> tag but the step is wrapped in <ai_generated>.Solution: Tags only work in verbatim steps. Remove the <ai_generated> wrapper, or move the tag into its own verbatim then step.Validation error: <interruption> must be a then step
Validation error: <interruption> must be a then step
<interruption> was used in first_message or a condition’s say.Solution: Move it into a then step, at the very start of that step.Validation error: scenario_language is required
Validation error: scenario_language is required
scenario_language explicitly in the request.Condition Not Triggering
Condition Not Triggering
- Make
whenmore specific - Check if a previous condition is matching instead
- Verify
whendescribes what the agent does, not what the evaluator should do
A then step fires earlier or later than expected
A then step fires earlier or later than expected
then step fires at the wrong time.Explanation: Each then step fires on the next turn after the step before it — after the testing agent delivers that step and the main agent replies. It never fires in the same turn, and it does not wait for any particular reply.Solutions:- If a step should only fire after a specific reply, make it its own condition with a matching
wheninstead of athenstep - Keep
thenfor messages that should follow regardless of what the agent says
First Message Not Sending
First Message Not Sending
- Check that
first_messageis set — an emptyfirst_messagemeans the testing agent waits for the main agent to speak first - Check that the role is defined
Can't run — an attached audio clip is still transcribing / failed
Can't run — an attached audio clip is still transcribing / failed
ready. Wait for transcription to finish (pending/processing), or if a clip failed, re-upload it or remove it. Check clip statuses via GET scenarios/{id}/condition-audio/.Attach audio option is missing on a step
Attach audio option is missing on a step
<ai_generated> step returns Audio can only be attached to a verbatim step, not one wrapped in <ai_generated>. Remove the <ai_generated> wrapper from the step first.