Declaring variables

You can declare variables using the <var> element or the name attribute of various form items. Table 1 lists the possible variable scopes:

Table 1. Variable scope
Scope Description Implementation details
anonymous Used by the <block>, <filled>, and <catch> elements for variables declared in those elements. Supported as documented in VoiceXML 2.1.
application Variables are visible to the application root document and any other loaded application documents that use that root document. Supported as documented in VoiceXML 2.1.
The following application variables have been added to hold the audio recorded during speech recognition:
  • application.lastresult$.asraudio
  • application.lastresult$[i].asraudio
See Recording user input during speech recognition for more information.
dialog Variables are visible only within the current <form> or <menu> element. Supported as documented in VoiceXML 2.1.
document Variables are visible from any dialog within the current document. Supported as documented in VoiceXML 2.1.
session Variables that are declared and set by the interpreter context. The following session variables are fully supported:
  • session.connection.aai (contains application to application information passed during connection setup)
  • session.connection.local.uri (provides Dialed Number Identification Service)
  • session.connection.originator (directly references either the local or remote property)
  • session.connection.remote.uri (provides Automatic Number Identification)
  • session.ibm.application_data (contains the application data passed to the VoiceXML document via the VoiceXML Browser bean)
  • session.ibm.line_address (contains the line address of the current call)
  • session.ibm.call_key (contains the CallPath call key)
The following session variables are not fully supported but can be referenced without causing an error:
  • session.connection.protocol.name (always contains the value “WVR_Generic_Protocol”, not the name of the actual underlying telephony protocol)
  • session.connection.protocol.version (contains the installed version of WVR_Generic_Protocol, not the version of the actual underlying telephony protocol)
  • session.connection.redirect (always contains the ECMAScript value “undefined”)

II Digit (Information Indicator Digit) and User to User Information functionality are not available.

   

To ensure that your application is portable, you should check if session variables are defined before attempting to use them:

<if cond="session.x==undefined">
    <exit>
<else>
     ok to access the session variable
<endif>