VoiceXML 2.1 Development Guide Home  |  Frameset Home

  Post-Dialing  |  TOC  |  Transfer Hotwording  

Transfer Shadow Variables

The normal execution of the <transfer> element will populate three shadow variables: name$.duration, name$.inputmode, and name$.utterance.
There is really only one shadow variable that comes up often in most developer code though. If you want to be able to log the length of a user's call,
(such as for billing purposes), you need only access the name$.duration shadow variable within your application:


      <transfer name="MyCall" dest="tel:+12223334444"
          bridge="true" connecttimeout="20s" maxtime="60s">
            ...
        <filled>
            ...
          <prompt>
            The length of the call was <value expr="MyCall$.duration"/> seconds.
          </prompt>
        </filled>


It is important to remember that the <transfer> shadow variables are only set if the called party hangs up, not if the caller hangs up. Getting the length of a call in that case requires
some simple ECMAScript. We just initialize beginning and ending Date() objects, and check the difference when a connection.disconnect.hangup event occurs.
Note that this will give us the time from when the transfer began, and not from when the call was answered.


    <var name="beginTimer" expr="new Date();"/>
    <var name="endTimer"/>
    <var name="callDuration"/>

    <catch event="connection.disconnect.hangup">
        <goto next="#timer"/>
    </catch>

    <form id="timer">
        <block>
            <assign name="beginTimer" expr="Number(beginTimer.getTime());"/>
            <assign name="endTimer" expr="new Date();"/>
            <assign name="endTimer" expr="Number(endTimer.getTime());"/>
            <if cond="endTimer &lt; beginTimer">
                <assign name="callDuration" expr="0"/>
            <else/>
                <assign name="callDuration" expr="endTimer - beginTimer"/>
            </if>
            <log expr="'The length of the call was ' + callDuration / 1000 + ' seconds.'"/>
        </block>
    </form>


However, if using <transfer> hotwording, (see the next subsection for details), there are a few others that we can grab.
The name$.inputmode shadow variable will relay the method, (voice or dtmf), in which the transfer was terminated. The name$.utterance variable will contain the utterance/dtmf key that was entered by the caller to terminate the conference. It is also worth noting that if the transfer was terminated by speech then the application.lastresult$ will also be populated.


    <transfer name="MyCall" dest="tel:+12223334444"
            bridge="true" connecttimeout="20s" maxtime="60s">

    <grammar type="application/x-gsl">(bye)</grammar>
    <grammar type="application/x-gsl">(dtmf-1)</grammar>
        ...
    <filled>
            <prompt>
              The length of the call was <value expr="MyCall$.duration"/>
              The input mode of the call was <value expr="MyCall$.inputmode"/>
              The utterance of the call was <value expr="MyCall$.utterance"/>
            </prompt>
    </filled>




Download the Code!

  Download the source code



  ANNOTATIONS: EXISTING POSTS
0 posts - click the button below to add a note to this page

login
  Post-Dialing  |  TOC  |  Transfer Hotwording  

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