Sprites Docs
Reference

Template Syntax

Variable references and filters for response templates and operation configs.

Templates use double-brace syntax {{expression}} to reference data. They work in response templates, operation configs, and anywhere you see interpolated values.

Variable references

ReferenceWhat it contains
{{$input.text}}The user's message
{{$input.images}}Array of images in the message
{{$state.field}}Session state value
{{$op.output_name}}Operation result (by output name)
{{$op.output.nested.path}}Nested field from operation result
{{$context.user_id}}User context
{{$loop.item}}Current item in a loop body
{{$loop.index}}Current index in a loop body

Reference operation results with $op. You may see $vars in older examples — it's a legacy alias for $op and still works, but prefer $op in new superpowers.

Date & time sources

All date sources are resolved in the user's timezone.

ReferenceWhat it contains
{{$now}}Current time (ISO 8601)
{{$now.iso}}Current time (ISO 8601)
{{$now.date}}Current date (YYYY-MM-DD)
{{$now.time}}Current time (HH:MM)
{{$now.datetime}}Current date + time (YYYY-MM-DD HH:MM)
{{$today.date}}Today's date (YYYY-MM-DD)
{{$today.start}}Today at 00:00:00 (ISO 8601) — great for time_min
{{$today.end}}Today at 23:59:59 (ISO 8601) — great for time_max
{{$yesterday.date}} / .start / .endSame shape, for yesterday
{{$next_saturday.date}} / .start / .endThe upcoming Saturday
{{$next_sunday.date}} / .start / .endThe upcoming Sunday

$next_saturday and $next_sunday always describe one weekend together: the upcoming one, or the current one when today is already Saturday or Sunday.

Flat legacy forms also work: {{$now_iso}}, {{$now_date}}, {{$today_date}}, {{$yesterday_date}}, {{$now_month_year}}.

Bare references

State keys and operation outputs can be referenced without a prefix: {{my_output}} resolves the same as {{$op.my_output}}, and {{city}} the same as {{$state.city}} (state wins if both exist). This is convenient inside long prompts, but prefer the explicit $op. / $state. forms — they make the source obvious and never collide with a literal word.

Dynamic bracket keys

Bracket notation accepts a variable name as well as a numeric index. The name in brackets is resolved from context, then used as the lookup key:

{{$op.items[0].name}}            → index into a list
{{rates.rates[to_currency]}}     → to_currency resolves first (e.g. "EUR"),
                                   then rates.rates["EUR"] is returned

This works in both $-prefixed and bare paths.

Filters

Filters transform values using the pipe | syntax:

String filters

{{$op.name | upper}}          → "JOHN"
{{$op.name | lower}}          → "john"
{{$op.name | capitalize}}     → "John"
{{$op.text | truncate:50}}    → "First 50 characters..."
{{$op.url | url_encode}}      → "hello%20world"
{{$op.text | replace:'old':'new'}}

Number filters

{{$op.price | round:2}}      → 19.99
{{$op.price | currency}}     → "$19.99"
{{$op.ratio | percent}}      → "45%"
{{$op.total | round_dollars}} → "$20"
{{$op.val | abs}}             → 5

Collection filters

{{$op.items | length}}        → 3
{{$op.items | first}}         → first element
{{$op.items | last}}          → last element
{{$op.items | join:', '}}     → "a, b, c"
{{$op.items | map:'name'}}    → ["Alice", "Bob"]
{{$op.items | sum}}           → total
{{$op.items | sort}}          → sorted
{{$op.items | unique}}        → deduplicated
{{$op.items | slice:0:5}}     → first 5 elements
{{$op.dict | keys}}           → key list
{{$op.dict | values}}         → value list

Date filters

{{$now_iso | date:'%Y-%m-%d'}}     → "2026-04-14"
{{$op.timestamp | relative_time}} → "2 hours ago"
{{$now | add_hours:24}}           → tomorrow

Logic filters

{{$op.val | default:'fallback'}}      → use fallback if null
{{$op.flag | ternary:'yes':'no'}}     → conditional string
{{$op.a | coalesce}}                  → first non-null value

Type filters

{{$op.str_num | int}}     → 42
{{$op.str_num | float}}   → 42.0
{{$op.num | str}}         → "42"
{{$op.val | bool}}        → true/false
{{$op.obj | json}}        → JSON string

Special

{{$op.count | pluralize:'item':'items'}}  → "1 item" or "3 items"

Condition expressions

Conditions power four fields: conditional.condition, enabled_if (on any operation), trigger state_condition, and state-machine auto_transition.guard. They all use the same boolean grammar:

ElementSyntax
Comparisons==, !=, >=, <=, >, <
Membershipcontains (substring for strings, element for lists)
Boolean logic|| / && (also or / and)
Literalsnull, true, false, numbers, 'quoted strings'
OperandsAny template expression, including filters

Both wrapping styles are equivalent — braces around each operand, or around the whole expression:

condition: "{{$state.count}} > 0"
condition: "{{$state.count > 0}}"
condition: "{{$state.city == null || $state.city == ''}}"
condition: "{{$op.check}} != 'NO_ALERTS'"
condition: "{{$op.items | length}} > 3 && {{$state.enabled}} == true"
condition: "{{$op.kind}} contains 'home'"

Bare truthiness. A condition with no comparison operator tests truthiness: "{{$state.flag}}" is true unless the value is empty, false, null, none, or 0 (as a value or as a string — 'false', 'null', and '0' are all falsy). A reference that doesn't resolve to anything evaluates to null, so "{{missing}} != null" is correctly false.

Numeric comparisons only. The ordered operators (>, >=, <, <=) coerce both sides to numbers. If either side isn't numeric — including date strings like "2026-08-13" — the comparison returns false. Compare dates with == / !=, or convert them to numbers first. Equality (==) is forgiving: '5' == 5 and true == 'true' both hold.

Unsupported syntax

Templates are references + filters — not a programming language. These are rejected at validation time:

Not supportedUse instead
Ternaries a ? b : cThe ternary filter: {{$op.flag | ternary:'yes':'no'}}
Arithmetic {{a + b}}A calculate operation
Function calls {{len(items)}}Filters: {{items | length}}
Lambdas =>A loop or llm_generate operation

Validation

Definitions are linted when they're generated and when you publish. Unknown config keys on an operation, unsupported template syntax, unknown filters, unknown $sources, malformed conditions, and conversation_flow nested inside conditional/loop branches are all reported as errors — fix them before the superpower will behave as authored. Bare references that don't match any state key or operation output are flagged as warnings.

On this page