Search docs...

Start typing to search documentation

Chat Guide

Macros (CBS)

Curly-brace scripting inside any prompt text.

Macros are double-brace tokens that expand at request time. They work in character fields, lorebook entries, presets, greetings and chat text, and they nest.

text
{{char}} smiles at {{user}}.
{{random::sunny::rainy::foggy}}
{{calc::1+2*3}}

Arguments are separated with double colons. Unknown macros expand to nothing instead of erroring, so a typo never breaks a request.

Single braces are not macros. One pair reaches the model as literal text and shows up in replies, the usual cause of stray braces. Matches SillyTavern, RisuAI and JanitorAI, so their cards work unchanged.

text
{{user}}   expands to your persona name
{user}     stays literal text

MacroExpands to
{{char}}The current character's name (group chats: the current speaker).
{{user}}Your persona's name.
{{persona}}Your persona's description.
{{description}}The current character's description field.
{{lastmessage}}The most recent message text.
{{time}} / {{date}}Current time / date in your locale and timezone.

random picks one argument fresh each expansion. pick makes a choice that stays stable for the conversation. roll throws dice with d-notation.

text
{{random::a::b::c}}   {{pick::a::b::c}}   {{roll::d20}}

Rolls and randoms are seeded per turn: a regenerate reuses the same values, so swiping does not reroll dice.

Chat variables persist per conversation branch. Global variables persist across all chats. Set them in any macro-capable text or from trigger scripts.

text
{{setvar::mood::happy}}
{{getvar::mood}}
{{setglobalvar::visits::1}}

Branch-scoped storage means swiping to another branch restores that branch's variable state. Siblings never leak values into each other.

Blocks wrap content. if renders its body when the condition is truthy. each loops over arrays with slot substitution. when adds line-based else branches.

text
{{#if {{equal::{{getvar::mood}}::happy}}}}
{{char}} is in a great mood.
{{/if}}

{{#each {{array::red::green::blue}} item}}
Color: {{slot::item}}
{{/each}}

pure and escape protect literal braces from expansion. Any closing tag closes the innermost open block.

Comment macros vanish before the model sees them, so they work for notes inside card fields. Use pure blocks to show macro syntax literally.

text
{{// note to self, never sent to the model}}
{{#pure}}{{char}} stays literal here{{/pure}}