Variable Interpolation
Variable interpolation is a way to embed variable values directly into text strings. Instead of showing fixed text, you can make text dynamic by inserting variable values. The syntax is simple: wrap the variable name in double curly braces:{{variableName}}
Basic Syntax
{{userName}}is replaced with the value of theuserNamevariable{{score}}is replaced with the value of thescorevariable
- If
userName = "John"andscore = 95 - The text becomes:
"Hello John, you scored 95 points."
Common Uses
Interpolation works in any text field in the Creator App. Here are the most common uses:Show Text Action
Panel Titles and Descriptions
Feedback Messages
All Variable Types
Interpolation works with all variable types:String Variables
Number Variables
Boolean Variables
Array Variables
len() to work with them.
Advanced: Using Expressions in Interpolation
In addition to simple variable names, you can use expressions inside{{ }}. This includes:
Ternary Expressions (If-Then-Else)
condition ? valueIfTrue : valueIfFalse
Another example:
Arithmetic
Function Calls
len(value)— Length of string or arrayclamp(v, min, max)— Constrain number between min and maxnow()— Current timestamp (milliseconds)In(stateId)— True when the given state is currently active
String Concatenation
Undefined Variables: Default Behavior
What happens if you try to interpolate a variable that doesn’t exist or is uninitialized?- Always initialize variables with a default value
- Use a ternary expression to provide fallback text:
Real-World Examples
Quiz Feedback
Personalized Status Message
Time-Based Messaging
Conditional Content
Where Interpolation Works
Interpolation is available in:| Location | Example |
|---|---|
| Show Text action text | "You scored {{score}}." |
| Show Panel title and body | "Question {{currentQuestion}} of {{total}}" |
| Narrative or audio cue text | "Hello {{userName}}" |
| Any text field in the Creator App | Anywhere you see a text input, you can interpolate |
- Variable names and values (you can’t use interpolation in the Variable Inspector itself)
- Condition expressions (use variables directly, not interpolated)
Testing Interpolation
When you preview your training:Best Practices
Keep interpolation readable
Keep interpolation readable
Avoid overly complex expressions in
{{ }}. If it’s hard to read, it’s hard to maintain. Consider breaking complex logic into separate variables.Always initialize variables
Always initialize variables
Set default values so interpolated text doesn’t show blanks.
userName = "" is better than undefined.Use ternary for conditional text
Use ternary for conditional text
Instead of creating separate panels for different text, use
{{condition ? text1 : text2}} to keep one panel that changes.Be consistent with variable names
Be consistent with variable names
If you use
userName in some places and learnerName elsewhere, you’ll confuse yourself. Pick a naming convention and stick with it.Test with real data
Test with real data
Preview your training with actual variable values to make sure the interpolated text looks good and reads naturally.
Use friendly text
Use friendly text
Even if
score = 92, consider displaying “Great job!” instead of just the number. Use ternary expressions to show friendly feedback.Common Mistakes
Next Steps
Learn more about:- Creating Variables — Set up the variables you interpolate
- Variable Types — Understand string, number, boolean, and array types
- Conditions — Use variables to control training flow (not interpolation)

