Assigning custom IDs
By default any entries in blocks
, results
, and items
are assigned an auto incremented ID. This behaviour can be changed and the IDs can be set explicitly which makes it easier to later work with the Riddle's stats or webhook data.
Additionally it makes it easier to configure custom logic settings based on the IDs you have assigned.
Custom block IDs
You can assign a custom ID to any block by adding the id
property to the block object. The ID must be a positive integer and unique (not used in blocks
+ result
/results
).
Example object:
{
"id": 101,
"title": "The best noodles?",
"type": "SingleChoice",
"items": [
"Spaghetti",
"Fusilli"
]
}
Custom item IDs
You can assign a custom ID to any item by adding the id
property to the item object. The ID must be a positive integer and unique (only within the same block). Usually, items are defined as an array of strings, for example:
{
"items": [
"Spaghetti",
"Fusilli"
]
}
To be able to assign custom IDs, you need to change the items definition from an array of strings to an array of objects, for example:
{
"items": [
{
"id": 201,
"title": "Spaghetti"
},
{
"id": 202,
"title": "Fusilli"
}
]
}
Custom result IDs
You can assign a custom ID to any result by adding the id
property to the result object. The ID must be a positive integer and unique (not used in blocks
+ result
/results
).
Example simple result:
{
"id": 301,
"title": "Thank you",
"description": "Thanks for your vote."
}
Example advanded result page with blocks:
{
"id": 302,
"blocks": [
{
"type": "Text",
"text": "<h1>Thank you!</h1><p>Thanks for your vote.</p>"
}
]
}
Full Riddle example with custom IDs
{
"type": "Poll",
"build": {
"title": "Favorite color poll",
"blocks": [
{
"id": 101,
"title": "What's your favorite color?",
"type": "SingleChoice",
"items": [
{
"id": 201,
"title": "green"
},
{
"id": 202,
"title": "red"
}
]
}
],
"result": {
"id": 301,
"title": "Thank you",
"description": "Thanks for your vote."
}
}
}