Table of Contents
VoiceXML variables and ECMAScript variables share the same variable space. In other words, variables declared in a <script> element can be used in VoiceXML, and ECMAScript can use variables declared by a <var> element.
The variables can be declared in 3 different ways:
- By a <var> element.
- Within the <script> element in an ECMAScript block.
- Field item variables declared by one of the form items: <block>, <field>, <initial>, <object>, <record>, < subdialog >, <transfer>, <data>
VoiceXML defines the following variable scopes:
Session variables are available to all VoiceXML applications within a particular session. They are declared by the interpreter and are read-only. New session variables cannot be declared by VoiceXML documents. The following are standard VoiceXML session variables:
This variable refers to the DNIS (Dialed Number Identification Service). It provides the telephone number dialed by the caller if the service is supported, (alias session.telephone.dnis).
This variable refers to the ANI (Automatic Number Identification). It provides the telephone number of the caller if the service is supported, (alias session.telephone.ani).
The following are specific session variables added by Vxi VoiceXML browser:
This variable indicates the session/channel ID.
This variable contents the call ID or a user parameter assigned by the Asterisk Extension script.
This variable contents a user paramer assigned by the Asterisk Extension script.
Application variables are available to the root document and its application leaf documents. They are declared by the <var> elements of application root document's <vxml> element. Application variables defined in the root document can be referenced by the application leaf documents as application.variable.The following are standard VoiceXML application variables:
This read-only variable holds information about the last recognition to occur within this application. It is an array of elements, application.lastresult$[i], for the N-best recognition.
This variable is the confidence level for this interpretation from 0.0 (minimum confidence) to 1.0 (maximum confidence).
This variable indicates the raw string of words that were recognized for this interpretation.
The input mode variable is the mode in which user input was provided: DTMF or Voice.
The last result variable is the interpretation of this result. It will be the same as raw results for index 0 when no slot match was found, and for any index > 0.
Enable if property
recordutterance is set to true. This variable contain the last audio part treat by field or record tag, or undefined if no audio is collected.
Enable if property
recordutterance is set to true. This variable contain the size of the recording in bytes, or undefined if no audio is collected.
Enable if property
recordutterance is set to true. This variable contain the duration of the recording in milliseconds, or undefined if no audio is collected.
Document variables are available within the VoiceXML document. They are declared by the <var> elements that are children of the <vxml> element. Certain form items (<field>, <record>, <transfer>) may declare shadow variables in addition to the field item variable itself. Please refer to each tag reference for detailed information.
Each dialog (<form> or <menu>) has a dialog scope that exists while the user is visiting the dialog. Variables are declared by <var> elements or by form items.
<block>, <filled>, and <catch> (includes <error>, <help>, <noinput>, and <nomatch>) elements define a new anonymous scope to contain variables declared in that element. Other predefined anonymous variables are available within the <catch> and <enumerate> elements. Please refer to the tag reference for detailed information.