Skip to navigation
Calling

set

View as MarkdownOpen in Claude

Set script variables to the specified values. Variables set using set can be removed using unset.

set
objectRequired

An object that accepts user-defined key-value pairs. Each key is a variable name: an ASCII letter or underscore followed by up to 255 ASCII letters, digits, or underscores, optionally prefixed with vars.. vars.foo sets the same variable as foo. These naming rules apply only to the variable names, not to keys inside an assigned object.

Values can be any JSON value. After variable expansion, each value can nest objects and arrays at most 62 levels deep, counting the value itself; scalars don’t add a level. A deeper value isn’t stored.

Variables

Any variable with a valid name can be set by this method.

Examples

Setting variables

version: 1.0.0
sections:
main:
- set:
num_var: 1
- play:
url: 'say: ${num_var}'
- set:
num_var: 2
- play:
url: 'say: ${num_var}'

Setting multiple variables

version: 1.0.0
sections:
main:
- set:
items:
- drill bit
- drill
person: handyman
systems:
ventilation:
- inlet
- outlet
- fans
hr:
- lucy
- liam
- luke
- play:
url: 'say: The items ${items} will be used by ${person} to fix ${systems.ventilation}.'

See Also