Dynamic variables
In the Riddle Creator you can use dynamic variables to personalize / dynamically display any Riddle / form data.
You can do the same when building a Riddle via the API - all title and description properties can be personalized with dynamic variables.
Syntax
The following syntax is used to embed dynamic variables into a property:
%riddleVariable
Example:
Welcome back, %name!
riddleVariable then needs to be replaced with the variable you want to use. Keep reading to learn which variables you can use.
Rules for the syntax:
- A variable name consists of letters, digits and dots, and is matched case-insensitively (
%Nameworks just as well as%name). A dot at the very end is not part of the variable, soWelcome back, %name.works as expected. - A variable is only accepted if it exists for this Riddle - see the two sections below. An unknown variable that stands on its own (i.e. is preceded by whitespace) fails the build with
Invalid variable found in rich text: %<name> (original text: ...). - A
%somethingthat is not preceded by whitespace is treated as literal text and left untouched, so texts like50%offdo not break the build.
Dynamic Riddle variables
Available variables
| Riddle type | Variable | Description |
|---|---|---|
| All | riddle.id | The unique ID of the Riddle |
| All | riddle.title | The title of the Riddle |
| All | riddle.image | The image of the Riddle - this will be automatically translated to an image in the email automation / DOI |
| Quiz, Poll | result.title | The title of the user result |
| Quiz, Poll | result.description | The description of the user result |
| Quiz | score.number | The score of the user as a number |
| Quiz | score.percentage | The score of the user as a percentage |
| Quiz | score.max | The maximum achievable score the user could have achieved |
| Personality | personality.title | The title of the visitor's main personality |
| Personality | personality.label | The label of that personality |
| Personality | personality.desc | The description of that personality |
| Personality | personality.score | The score the visitor reached for that personality |
| Personality | personality.percentage | That score as a percentage |
| Personality | personality.2.title (… up to personality.5.…) | The same five variables for the 2nd to 5th ranked personality, e.g. %personality.2.score |
| Personality | attribute.title, attribute.label, attribute.desc, attribute.score, attribute.percentage | The same set for the visitor's main attribute |
| Personality | attribute.2.title (… up to attribute.5.…) | The same for the 2nd to 5th ranked attribute |
Variables that do not exist for the Riddle type you are building are rejected - e.g. %score.number in a Poll.
Example
You could personalize the result page by using the variables result.title, score.number, and score.max:
{
"result": {
"title": "Your result: %result.title",
"description": "You scored %score.number out of %score.max"
}
}
Dynamic form variables
Added form fields can be used in any following blocks as dynamic variables.
A form field's variable is its field type in lowercase, followed by the position of that field among all fields of the same type: %name1, %name2, %email1, %phone1, %dropdown1, and so on. The first field of a type is additionally available without the number.
For example, adding a FormBuilder with two Name fields and one Email field makes the following variables available:
- %name (this will always be the first
Namefield) - %name1
- %name2
- %email (this will always be the first
Emailfield) - %email1
Here's how you could integrate the variables into a SingleChoice quiz question:
{
"title": "What's the capital of Germany, %name1 %name2?",
"type": "SingleChoice",
"items": [
{ "title": "Berlin", "isCorrect": true },
{ "title": "Lissabon", "isCorrect": false },
{ "title": "Leipzig", "isCorrect": false }
]
}
Reading variables back
When you read a Riddle back as a build configuration, variables are turned back into the very %shortcode you would send, so the text can be rebuilt unchanged. For the first field of a type the short form is preferred, i.e. %email rather than %email1.
Two cases cannot be expressed as a shortcode and are therefore returned as the raw variable markup, with a warning for that property:
- a variable that was given a fallback value in the Creator (the API's
%shortcodesyntax has no way to express a fallback), and - a variable whose source no longer exists, e.g. because its form field was deleted.

