CCXML 1.0-W3C Development GuideHome  |  Frameset Home

  Postdial How-To  |  TOC  |  Duplex Conferencing  

Limiting Call Length

So, we have mastered how we can use a CCXML 1.0 token to make an outbound call and join a caller to our nifty VoiceXML application, but what if we want to cap the length of the call? SInce there aren't any obvious provisions for this, we have to wax creative and use the <send delay> element/attribute pairing.

Note: This example application requires the enabling of outdial priveleges on the Voxeo network, and the provisioning of a alphanumeric token string to your application. In order to get hooked up with all these neat features, check our Support Guide for all the juicy details.

Again, for this example, we are looking at three components, all told:


The first and last documents are pretty inconseqential: We've seen the HTML page that triggers a CCXML 1.0 token several times in the course of this documentation set, but we will revisit it here all the same. And the VXML application itself isn't that important, either. Any VoiceXML dialog that will run for an indefinite amount of time will fit the bill. So, let's instead focus on 'Start.php', below. You'll notice that there really isn't anything all that fancy going on. The only wrinkles that make this code different from our CCXML 1.0 Token Tutorial is the fact that when the call is picked up, we will send an delayed event, (30 seconds), that, when trapped by our eventhandler, will end the call:


CallLengthStart.html


<html>
<title>Limiting Call Length: token trigger</title>

<!-- note that the CCXML 1.0 platform uses a unique start URL -->

<form name="SampleForm" action="http://api.voxeo.net/SessionControl/CCXML10.start"  method="POST">
  <input type="hidden" name="tokenid" value="---- YOUR TOKENID HERE ----">

  Enter your phone number:<br>
  <input type="text" name="phoneNum" size="10" maxlength="10" value=""><br><br>

  <br><br>
  <input type="reset" value="Clear">
   
  <input type="submit" name="submit" value="Call Rick Astley!">
</form>
</html>


Start.php


<?PHP
header('Cache-Control: no-cache');
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo "<ccxml version=\"1.0\">";
echo "<var name=\"phoneNum\" expr=\"'tel:+1" . $_REQUEST["phoneNum"] ."'\" />";
?>

<meta name="author" content="Steve Sax"/>
<meta name="copyright" content="2007 Voxeo Corporation"/>
<meta name="maintainer" content="YOUR_EMAIL@HERE.COM"/>

  <var name="state0" expr="'init'"/>
  <var name="myCallID" expr="''"/>
  <var name="myDialog"/>
 
  <eventprocessor statevariable="state0">

<!-- *** CCXML front-end loaded / Making outbound call *** -->
    <transition state="init" event="ccxml.loaded">
      <log expr="'-- Application Starting --'"/>
      <log expr="'-- Making Outbound Call --'"/>
      <assign name="state0" expr="'calling'"/>         
      <createcall dest="phoneNum" timeout="'10s'"/>
    </transition> 

<!-- *** If outbound call fails *** -->
    <transition state="calling" event="connection.failed">
      <log expr="'-- Outbound Call Failed / Exiting App --'"/>
      <exit/>
    </transition>

<!-- *** If outbound call is successful *** -->
    <transition state="calling" event="connection.connected">
      <log expr="'-- Call Answered --'"/>
      <assign name="myCallID" expr="event$.connectionid"/>
      <assign name="state0" expr="'call_answered'"/>

<!-- *** Creating "timer-like" effect *** -->
<!-- *** For purposes of illustration, we will set this to 30 seconds *** -->
      <send data="'callMaxTimeReached'" target="session.id" delay="'30s'"/>

<!-- *** Starting your actual VXML application *** -->
      <dialogstart src="'your_vxml.xml'" dialogid="myDialog"/>
    </transition>

    <transition state="call_answered" event="dialog.exit">
      <log expr="'-- VXML App Complete / Exiting App --'"/>
      <exit/>
    </transition>

<!-- *** If call time reaches 30 seconds, kill the session *** -->
    <transition event="callMaxTimeReached">
      <log expr="'-- Max Call Time Reached / Disconnecting Call --'"/>
      <assign name="state0" expr="'forced_disconnect'"/>
      <disconnect connectionid="myCallID"/>
    </transition>

<!-- *** Clean-up when call is disconnected *** -->
    <transition event="connection.disconnected">
      <log expr="'-- Call Leg: ' + event$.connectionid + 'Has Been Disconnected / Exiting App --'"/>
      <exit/>
    </transition>

    <transition event="error.*">
      <log expr="'CRIKEY AN ERROR HAS OCCURED: (' + event$.reason + ')'"/>
      <exit/>
    </transition>
  </eventprocessor> 
</ccxml>


your_vxml.xml


<?xml version="1.0" encoding="UTF-8" ?>
<vxml version="2.1">
<form id="Form1">
  <field name="dummyField">

  <grammar type="text/gsl">[bhfryplmfswr]</grammar>

    <prompt bargein="false">
      <audio src="give_you_up.wav"/>
      <break time="500"/>
      <audio src="give_you_up.wav"/>
      <break time="500"/>
      <audio src="give_you_up.wav"/>
      <break time="500"/>
      <audio src="give_you_up.wav"/>
      <break time="500"/>
    </prompt>

    <noinput>
    <goto next="#Form1"/>
    </noinput>

</field>
</form>
</vxml>



Sample Code, Anyone?

You wanted it, you got it right HERE!




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

login
  Postdial How-To  |  TOC  |  Duplex Conferencing  

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