VoiceXML 2.1 Development GuideHome  |  Frameset Home

  Variable Scoping  |  TOC  |  F: All Things Audio  

Session Variables

Session variables define read-only variables set by the interpreter context, which may not be modified. Syntactically, they are referenced on a per-case basis with either the ‘session.' , ‘lastresult$.',  or ‘(formItemName)$.' prefixes.

Session variables are active throughout the course of a call session. The 'lastresult' prefix can also be replaced with the field or record name in question to get a specific field's value. i.e., both 'Fieldname$.inputmode', and 'Fieldname$.utterance' would both be considered valid.

session.telephone.ani

This variable holds the value of the CallerID. This may be spoofed in an outbound call by using the following syntax:

          <transfer dest="tel:+1112223333;ani=8001112222"/>

Note: This syntax changes with VXML 2.0. To catch the sip ANI address, you will use the w3c convention of:

session.connection.local.uri

However, most developers will need to access the tel: ANI value; for this, you will use the Voxeo-specific session variable of:

session.callerid



session.calledid

This variable holds the value of the called ID, and may not be spoofed.


session.connection.remote.uri

In the 2.0 environment, this will provide the calledID, (DNIS) of the caller. An example of what this value would look like is:

SESSION.CONNECTION.REMOTE.URI =sip:6782751234@xx.xx.x.x:xxxx

However, most developers will need to access the tel: DNIS value for this, you will use the Voxeo-specific session variable of:

session.calledid



session.connection.redirect

This session variable is not implemented on the Voxeo platform, and will always return a result of 'undefined'.

session.connection.aai

This session variable is not implemented on the Voxeo platform, and will always return a result of 'undefined'.


session.sessionid

This session variable will display the session ID for the particular call in question on the VWS1.3 platform:
SESSION.SESSIONID=dd552fcdc5fccef412f96d38818a1c25

Application Variables


application.lastresult$

Returns the full array of values from a caller's input, including utterance, inputmodes, and interpretation. An example of the results that one could expect to see would be in the following format:

[confidence=0.6,utterance='dweezil',inputmode=voice,interpretation={F_1=zappa} ]


Note that one cannot get the entire array value from this variable on the Motorola browser, as it will throw an error event. Instead, you should reference each particular value by the fieldname$.value syntax.

lastresult$.confidence

This variable returns the confidence value of the match; i.e. for a value of '0.7', the interpreter is 70% certain that this is the caller's correct utterance.

lastresult$.utterance

This variable contains the recognized phrase in the grammar which the caller spoke.

lastresult$.inputmode

This variable will return the mode in which the utterance was entered; the only available values are 'voice' and 'dtmf'.

FieldName$.interpretation.SlotName

This returns the value that is assigned to the utterance in the grammar file.

Utterance ValueSlotInterpretation Value
[coca cola] { <F_1      "coke"> }


lastresult$.recording

This returns the last utterance recording when the recordutterance property has been set to "true".

lastresult$.recordingsize

This returns the size of the recording in bytes when the recordutterance property has been set to "true".

lastresult$.recordingduration

This returns the duration of the recording in milliseconds when the recordutterance property has been set to "true".

recordname$.duration

This variable will tell us just how long the recorded message is, in milliseconds.

recordname$.filesize

This will return to us the actual filesize of the recorded message, in bytes. This can be useful for determining whether or not to submit our message, thus conserving server resources:

          <if cond="R_1$.size < 0">
              <!--dont do anything-->
          <else/>
              <submit next="Myserver.com"/>


recordname$.termchar

If we need to find out if the caller used a termdigit to end the recording, this variable will return a boolean value that will satisfy this need. In VWS2.0, this variable will be filled with thevalue of the actual dtmf key that was pressed, rather than a boolean value.

recordname$.maxtime

This variable will return a boolean value indicating if the maxtime for the recording session was reached, (TRUE) or not, (FALSE).


See It In Action

You know you want to. You can utilize the following VWS2.0 code to see all these session/shadow/application variable's values get output to the Voxeo Logger. Simply copy the code, map it to your 2.0 number, and call it with the logger open to see the results:


<?xml version="1.0" encoding="UTF-8"?>

<vxml version = "2.0" xmlns="http://www.w3.org/2001/vxml"
        xmlns:nuance="http://voicexml.nuance.com/dialog">

<form id="F1">

  <field name="F_1">
    <prompt> say something here that is very clever and witty </prompt>
    <grammar type="text/gsl">[libertine]</grammar>

    <filled>
      <log expr="'APPLICATION.BROWSER =' + application.browser"/>
      <log expr="'@@@@@@@@ APPLICATION VARS @@@@@@@'"/>
      <log expr="'CONFIDENCE =' + F_1$.confidence"/>
      <log expr="'INPUTMODE =' + F_1$.inputmode"/>
      <log expr="'INTERPRETATION = ' + F_1$.interpretation"/>
      <log expr="'UTTERANCE =' + F_1$.utterance"/>
      <log expr="'@@@@@@@@ END APPLICATION VARS @@@@@@@'"/>
    </filled>
  </field>

  <record name="R_1" beep="true">
    <prompt> next record some stuff here</prompt>

    <filled>
      <log expr="'#############################'"/>
      <log expr="'DURATION =' + R_1$.duration"/>
      <log expr="'SIZE =' +R_1$.size"/>
      <log expr="'TERMCHAR =' + R_1$.termchar"/>
      <log expr="'MAXTIME =' + R_1$.maxtime"/>
      <log expr="'############################'"/>
    </filled>
  </record>

  <transfer name="T_1" bridge="true" dest="tel:+1112223333">
    <prompt> preparing to place the call</prompt>
      <filled>
        <log expr="'********** SESSION VARS ***************'"/>
        <log expr="'SESSION.CALLEDID =' + session.calledid"/>
        <log expr="'SESSION.CALLERID =' + session.callerid"/>
        <log expr="'SESSION.CONNECTION.LOCAL.URI =' + session.connection.local.uri"/>
        <log expr="'SESSION.CONNECTION.REMOTE.URI =' + session.connection.remote.uri"/>
        <log expr="'SESSION.SESSIONID=' + session.sessionid"/>
        <log expr="T_1$.duration"/>
        <log expr="'***********END SESSION VARS**************'"/>

        <if cond="T_1 == 'busy'">
            <prompt>The line is busy. </prompt>
            <exit/>
        <elseif cond="T_1 == 'noanswer'"/>
            <prompt> No one is home. </prompt>
        </if>
      </filled>
  </transfer>
</form>
</vxml>



  ANNOTATIONS: EXISTING POSTS
ddantow
11/12/2005 5:09 PM (EST)
I think the line
<log expr="'SESSION.ID=' + session.id"/>
should be
<log expr="'SESSION.ID=' + session.sessionid"/>
JimMurphy
11/12/2005 10:00 PM (EST)
ddantow,

Good catch. We'll update the documentation.

Jim
MattHenry
11/14/2005 11:18 AM (EST)


Just as an FYI, both variable syntaxes will work on the Voxeo VXML platform, but I can see the source of confusion, since we listed "session.sessionid" in the table, yet referenced "session.id" in the code example.

~Matt

ktmanley
4/10/2006 11:57 AM (EDT)
Note that lastResult$ should be spelled lastresult$ on the Prophecy platform.
yungwei
7/30/2007 12:35 PM (EDT)
Suppose application.lastresult$ contains multiple items. I'd like to loop through it and print out the interpretation of each item in the following format. How can I do that? Thanks.

format: [slot-name]=[value]

login
  Variable Scoping  |  TOC  |  F: All Things Audio  

© 2008 Voxeo Corporation  |  Voxeo IVR  |  VoiceXML & CCXML IVR Developer Site