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. There are 3 ways that variables can be declared:
Scope
VoiceXML defines the following variable scopes:
Session Variables
VoiceXML Session Variables
The following are the currently or previously standard VoiceXML session variables. All "telephone" variables continue to be supported. Note that although a certain variable may be supported, it will only be set if it has been enabled during platform configuration.
Note: See Call-Related Variables for details on the naming conventions.
The VoiceXML 2.0 specification also defines the session.connection.protocol session variable whose members give additional information about the underlying protocol:
| session.connection.protocol.sip.uri |
Represents the originator device. It is equal to either session.connection.local.uri or session.connection.remote.uri. Note that if the local.uri and/or remote.uri variables have not been enabled, the originator variable (if it has been enabled) will be undefined. |
| session.connection.protocol.sip.from | Set to the SIP From URI of the corresponding SIP session. The value remains URL-encoded and thus is the exact text that appears in the SIPD PDU. |
| session.connection.protocol.sip.to | Set to the SIP To URI of the corresponding SIP session. The value remains URL-encoded and thus is the exact text that appears in the SIPD PDU. |
| session.connection.protocol.sip.call_id | Set to the SIP Call-ID of the corresponding SIP session. The value remains URL-encoded and thus is the exact text that appears in the SIPD PDU. |
| session.connection.protocol.sip.parameter | This is an ordinal array that reflects the names and values of SIP Request-URI parameters received from SIPD when a call is set up. Each item in the array is an ECMAScript object with two members, “name” and “value”. For instance, a SIP Request-URI of sip:1234@mediaserver.com;abc=1234 would have session.connection.protocol.sip.parameter[0].name = “abc” and session.connection.protocol.sip.parameter[0].value = ‘1234’. Both the parameter names and values presented are URL-decoded. |
Application Variables
Application variables defined in the root document can be referenced by the application leaf documents as application.variable.
The application.lastresult$ shadow variable can be modified by
a VoiceXML application.
When any shadow variable is not set, its value will be ECMAScript undefined.
The following are supported VoiceXML application variables:
| Variable |
Description |
| application.lastresult$ |
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. |
| application.lastresult$[i].confidence |
The confidence level for this result from 0.0 (minimum confidence) to 1.0 (maximum confidence). It is an ECMAScript number. |
| application.lastresult$[i].utterance |
The raw string of words that were recognized
for this result. Limitation: Currently, only
|
| application.lastresult$[i].inputmode |
The mode in which user input was provided: dtmf or voice. |
| application.lastresult$[i].interpretation |
The interpretation of this result (set of slot names and values). This interpretation can be formatted either as an ECMAScript object, or as a string. The choice of format depends on the value of the com.voicegenie.fieldobject property. Note that when |
| application.lastresult$[i].markname |
(VoiceXML 2.1 feature) The name of the mark
last executed by the SSML processor before barge-in occurred or the end
of audio playback occurred. If no mark was executed, this variable is
undefined. For more details, see |
| application.lastresult$[i].marktime |
(VoiceXML 2.1 feature) The number of milliseconds
that elapsed since the last mark was executed by the SSML processor, until
barge-in occurred or the end of audio playback occurred. If no mark was
executed, this variable is undefined. For more details, see |
| application.lastresult$[i].recording |
(VoiceXML 2.1 feature) This variable stores
a reference to the recording, or undefined if no audio is collected (like
|
| application.lastresult$[i].recordingsize |
(VoiceXML 2.1 feature) This variable stores
the size of the recording in bytes, or undefined if no audio is collected
(like |
| application.lastresult$[i].recordingduration |
(VoiceXML 2.1 feature) This variable stores
the duration of the recording in milliseconds, or undefined if no audio
is collected (like |
| application.lastresult$[i].rawresults |
Complete results from ASR in the format of: +[?][slot1:]value1[:score1]+ [?][slot2:]value2[:score2]+... Where ? implies ambiguous match, and optional parts are quoted in [ and ]. |
| application.lastresult$.activegrammars[] |
An array containing all the grammar objects that were active at the time of the recognition. This will contain a valid value whenever voice input is recognized. For now, DTMF input will not result in this variable being set to a meaningful value. |
| application.lastresult$.audiooffset |
Offset of audio data on bargein (-1 if audio was played to the end). Undefined if last played prompt was not <audio>. It is an ECMAScript number. |
| application.lastresult$.bargein |
This is true if bargein occurred, false otherwise. It is an ECMAScript boolean. |
| application.lastresult$.bargeinresult |
The recognized result (phrase|score) returned by ASR upon barge-in. This is only meaningful with certain ASR engines that use special notation in their grammars to allow portions of utterances to trigger bargein. Otherwise, this is only filled if recognition-based bargein is used, in which case it will have the same values as the recognition result and confidence level. |
| application.lastresult$.duration |
If utterance audio is created for the last recognition
result, this variable will contain the duration of the utterance audio
in seconds (like |
| application.lastresult$.info |
ASR recognition result parameters, such as how much time was used to do recognition, from the 'info' portion of the ASR result. (Available with Watson ASR only) |
| application.lastresult$.interpretation.SWI_literalTimings |
Makes special OSR variable, SWI_literalTimings, accessible in the VoiceXML page. See SWI_literalTimings for more details. (Available with SpeechWorks ASR only) |
| application.lastresult$.size |
If utterance audio is created for the last recognition
result, this variable will contain the size of the utterance audio in
bytes (like |
|
application.lastresult$.triggeredgrammar |
The matched result's grammar
object. This will contain a valid value any time voice input is recognized.
For now, DTMF input will not result in this variable being set to a meaningful
value. Note that this variable will be |
| application.lastresult$.utteranceaudio |
Audio file of the user utterance (like This is always assigned an utterance filename (as long as saving utterances is enabled and the inputmodes property is set to either "voice" or "both"). This filename is passed to the ASR engine to create the utterance audio file. However, currently only Watson creates an utterance audio file in the events of noinput, DTMF match, or call disconnect. With other ASR engines, reference to the utteranceaudio shadow variable in those cases (where no audio file is created) will result in a bad fetch error. (However, the application.lastresult$.utteranceaudio will not be set at all, i.e. will be undefined, in the event of a noinput if the com.voicegenie.strictconformance property is set to true.) |