Setvar

Definition

This tag creates a variable which can be used later in the dial plan. The contents of the variable created by <setvar> is a data string. This data string may be referenced (e.g.,${call.lastinput}) or defined (e.g., "Elvis Presley"). The <setvar> tag also supports basic math and Boolean expressions in JavaScript. NOTE: you can reference the uploaded spreadsheet data by using column letters that become corresponding contact fields, such as ${contact.D} which could reference data from column D that becomes field D in the contact data.

Value

Example values: "${call.lastinput}" or "${contact.firstName}" or "${contact.D}" or "Elvis Presley" or "${answer8} + 10"

Attributes

Attribute Required Values Description
name N any text A unique name for the tag
varname Y any text The variable to be referenced later in the dial plan

Use Case

The setvar tag can be used to open up a long number string entered by the user, so that it can be read back by the text-to-speech engine as individual integers rather than as a whole number. The following example shows the user input (keypress tag), using setvar to open up the input string (setvar tag), and the playback of the number as integers (play tag).

Enter your phone number. ${call.lastinput}.split("").join(" "); You entered a phone number of ${ExplodedInput}.