Volume 2, Issue 3 - April/May 2002
   
 

Life in the Shadows

By Rob Marchand

(Continued from part 1

Transfer

The tag also provides a number a number of useful shadow variables. Note that all of these only apply to the 'bridged' case, where the bridge attribute is 'true'.

Shadow Variable

Contents

Typical Uses

name$.duration

Length of the transferred call, in milliseconds.

Billing, statistics, etc.

name$.inputmode

If the call was terminated by either speech or DTMF input (by the original caller), the mode ('speech' or 'dtmf') that caused the outbound call to terminate.

Determining how the call was terminated.

name$.utterance

If the call was terminated by speech, then the user utterance that triggered the recognized grammar.

Selecting follow-on action (note that grammar within transfer is optional and not widely supported).

 

Last Results

In addition to those shadow variables associated with each input item, we also have a general shadow variable for all input collections: application$.lastresult. This isn't the same kind of shadow variable as the others, as it doesn't 'shadow' another particular variable, but rather all input items. The contents always reflect the results of the last input collection (the astute among you will see the reason for the name). Note that 'application' isn’t your application name, but the literal word 'application'.

The shadow variable application$.lastresult is an array of objects, application$.lastresult[n] with members application$.lastresult[n].confidence, application$.lastresult[n].utterance, application$.lastresult[n].inputmode, and application$.lastresult[n].interpretation. The array includes the N-best results (numbered from 0 to a maximum size of maxnbest-1). You should check the length of the array using the application$.lastresult.length member before performing any operations based on application$lastresult. Note also that you can application$.lastresult.confidence, etc., correspond to the 0th element of the application$.lastresult array.

Another interesting point regarding application$.lastresult is the fact that it is set even in the event of a nomatch (this is a recent change to the specification though). This is really interesting, as it allows you to try to decide what went wrong in the user interaction, and to make decisions based upon this. Note that a 'noinput' does not change the values in application$.lasresult. When the VoiceXML interpreter is next collecting input, application$.lastresult will be set to ECMAScript 'undefined'.

Summary

Shadow variables provide 'under-the-hood' information that can be important tools as you develop your VoiceXML application. Know what's available and how to use it, and you’ll be able to develop better applications.

If you get stuck, make sure that you have a look at whatever platform specific information is available; there is a tradeoff here, as you sacrifice portability for features, so consider use of such platform specific variables carefully.

For some examples of shadow variables in action, have a look at these previous First Words columns:

What’s Next?

If there are particular things you’d like to see covered in a future First Words column, drop me a line at , and I’ll try to write about it.

back to the top

 

Copyright © 2001-2002 VoiceXML Forum. All rights reserved.
The VoiceXML Forum is a program of the
IEEE Industry Standards and Technology Organization (IEEE-ISTO).