Skip to content

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.

Variables

Any variable can be set by this method.

Examples

Setting variables

YAMLJSON

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

YAMLJSON

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

  • Variables and Expressions: Complete reference for SWML variables, scopes, and syntax
  • unset: Remove variables from the script

SignalWire Developer Documentation