CCXML Voxeo 1.0 Development GuideHome  |  Frameset Home

  F: Outbound Dialing  |  TOC  |  Limiting Call length  
This documentation is for CCXML 1.0-Voxeo, which has been superceded by CCXML 1.0-W3C. The CCXML-Voxeo platform is not being updated any longer. The CCXML 1.0-W3C version, however, has many new features and is actively being enhanced. If you're writing a new CCXML application, you should use CCXML 1.0-W3C. Click here for the CCXML 1.0-W3C documentation.

Postdialing

If your application is going to be hitting a PBX system of any sort, you'll want to have the ability to enter extension numbers after the call is initially connected. Will the standard w3c CCXML spec allow for this? Heck no. But with the Voxeo CCXML implementation, such a chore is easily accomplished by using the 'dtmf' type extension of the <dialogstart> element.

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.


For this example, all we need to do is take our sample code from CCXML Lesson 7, and modify it a bit. To start off with, lets get ourselves a nice little HTML page to start the token off. We will need three fields in this code:


Start.html


<title>CCXML Token Trigger</title>
<form name="SampleForm"
  action="http://api.voxeo.net/SessionControl/CCXML.start"  method="POST">
  <input type="hidden" name="tokenid" value="***YOUR TOKEN HERE***">
  <input type="hidden" name="resulturl" value="http://***YOUR RESULT URL HERE***">

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

  Enter the PBX phone number:<br>
  <input type="text" name="num2" size="10" maxlength="10" value=""><br><br>
  Enter the PBX extension number:<br>
  <input type="text" name="ext" size="5" maxlength="5" value=""><br><br>
  <br><br>
  <input type="reset" value="Clear">
   
  <input type="submit" name="submit" value="Give me a call!">
</form>


Of course, like good Boy Scouts, we will need to Be Prepared, so we will need a 'hold music' page,  and a 'call failed' page, exactly like the ones detailed in CCXML Lesson 6.


Now, we get to the 'meat' of postdialing with CCXML. We will need to snag our querystring values from the webform, so we'll write this using some tender-loving ASP. Once we grab these variables, we will want to place a call to yourself to get started, and once it is answered, place the call to that PBX destination. Assuming that everyone plays nice and answers their phone, we put our querysting variable into the 'dtmf' dialog src. Put on your seatbelts:


<?xml version="1.0" encoding="UTF-8" ?>
<ccxml version="1.0">
<%
<!-- sample code by Michael 'Topflite' Book, Voxeo Corporation -->
'*******************************************************
' Grab the "num" and "ext" var from the querystring
'*******************************************************
Num_1  = request.querystring("num1")
Num_2  = request.querystring("num2")
Ext = request.querystring("ext")
'*******************************************************
' Now we must assign those values to CCXML variables
'*******************************************************
response.write "<var name=""phoneNum_1""  expr=""" & Num_1 & """/>"
response.write "<var name=""phoneNum_2""  expr=""" & Num_2 & """/>"
response.write "<var name=""pbxExt"" expr=""" & Ext & """/>"
%>

  <var name="state0" expr="'init'"/>

  <eventhandler statevariable="state0">
    <transition state="'init'" event="ccxml.loaded">
      <log expr="'-- Application Starting --'"/>
      <log expr="'-- Making Outbound Call #1 --'"/>
      <assign name="state0" expr="'calling_1'"/>           
      <createcall dest="phoneNum_1"/>
    </transition>   

    <transition state="'calling_1'" event="connection.CONNECTION_CONNECTED" name="evt">
      <log expr="'-- Call #1 Answered --'"/>
      <var name="callid_1" expr="evt.callid"/>
      <assign name="state0" expr="'play_1_hldmsc'"/>
      <dialogstart src="'holdmusic.vxml'" dialogid="holdMusicDlg_1"/>
    </transition>

    <transition state="'play_1_hldmsc'" event="dialog.started">
      <log expr="'-- Caller #1 Hold Music Started --'"/>
      <assign name="state0" expr="'calling_2'"/>           
      <createcall dest="phoneNum_2"/>
    </transition>   

    <transition state="'calling_2'" event="connection.CONNECTION_CONNECTED" name="evt">
      <log expr="'-- Call #2 Answered --'"/>
      <var name="callid_2" expr="evt.callid"/>
      <assign name="state0" expr="'createDelay_2'"/>
      <send event="'continue'" target="session.id" delay="'3000'"/>
    </transition>

    <transition state="'createDelay_2'" event="user.continue" name="evt">
      <log expr="'-- *Continue* Event Received --'"/>
      <assign name="state0" expr="'playExt_2'"/>
      <dialogstart src="'dtmf://'+ pbxExt +'#?pause=200&duration=200'"
                  type="'application/x-senddtmf'"
                  callid="callid_2"
                  dialogid="dialExtDlg_2"/>

    </transition>

    <transition state="'playExt_2'" event="dialog.exit">
      <log expr="'-- Extension Dialed On Call #2 --'"/>
      <assign name="state0" expr="'stopHoldMusic_1'"/>
      <dialogterminate dialogid="holdMusicDlg_1"/>
    </transition>

    <transition state="'stopHoldMusic_1'" event="dialog.exit">
      <log expr="'-- Call #1 Hold Music Stopped --'"/>
      <log expr="'-- Now Connecting Call Legs --'"/>
      <assign name="state0" expr="'bridging'"/>
      <join sessionid1="callid_1" sessionid2="callid_2"/>
    </transition>   

<!-- ************************ -->
<!-- *** If call #1 fails *** -->
    <transition state="'calling_1'" event="connection.CONNECTION_FAILED">
      <log expr="'-- Call #1 Failed --'"/>
      <exit/>
    </transition>
<!-- ************************ -->

<!-- ************************ -->
<!-- *** If call #2 fails *** -->
    <transition state="'calling_2'" event="connection.CONNECTION_FAILED">
      <log expr="'-- Call #2 Failed --'"/>
      <assign name="state0" expr="'call_2_failed'"/>
      <dialogterminate dialogid="holdMusicDlg_1"/>
    </transition>

    <transition state="'call_2_failed'" event="dialog.exit">
      <log expr="'-- Hold Music Stopped --'"/>
      <assign name="state0" expr="'playingCallFailed_1'"/>
      <dialogstart src="'callfailed.vxml'"/>                 
    </transition>

    <transition state="'playingCallFailed'" event="dialog.exit">
      <log expr="'-- Call Failed Dialog Played --'"/>
      <log expr="'-- So Sad...  Bye Bye --'"/>
      <disconnect/>
      <exit/>
    </transition>
<!-- ************************ -->

<!-- ******************************************* -->
<!-- *** If we just generally mess things up *** -->
    <transition event="call.CALL_INVALID" name="evt">
      <if cond="callid_1 == evt.callid">
        <exit/>
      </if>
    </transition>

    <transition event="error.*" name="evt">
      <log expr="' AN ERROR HAS OCCURED: (' + evt.error + ')'"/>
      <exit/>
    </transition>
  </eventhandler>   
<!-- ******************************************* -->

</ccxml>


Sample Code, Anyone?

Just in case you'd like the 'no-fuss, no-muss, show-me-the-money' code, you can download the whole thing by clicking right HERE!.




  ANNOTATIONS: EXISTING POSTS
esirkin
10/5/2006 3:43 AM (EDT)
The syntax on <dialogstart> is not consistent with your documentation for the element.  Should name="holdMusicDlg_1", be namelist="holdMusicDlg_1" ?
Michael.Book
10/5/2006 11:26 AM (EDT)
Hello,

Actually, "name" is a deprecated attribute.  Its replacement/equivalent is the "dialogid" attribute.

Our apologies for the confusion, and thank you for bringing this to our attention.  Our documentation admins have been notified, and will update this example.


Best,

~ Michael
alexey.timofeev
2/19/2008 6:08 AM (EST)
Hi!
I'm really need to pass variables to my ccxml scripts. Can I do that just by using method GET? How can I get this variables in my ccxml script?
Do I need to write separate php-script or it can be done directly in the ccxml?

The example of GET form:
<html><head><title>Run</title></head><body>
    <form action="http://session.voxeo.net/CCXML.start" method="get" target="_blank">
        <table align="left" border="0" cellpadding="0" cellspacing="5">
        <tr> <td>TokenID  </td> <td><input name="tokenid" value="**My token here**" type="text"></td></tr>
        <tr> <td>variable1  </td> <td><input name="variable1" value="1" type="text"></td></tr>
        <tr> <td>variable2  </td> <td><input name="variable2" value="2" type="text"></td></tr>
        <tr> <td><input value="GO!" type="submit">        </td> </tr>
        </table><br>
    </form>
  </body></html>

CCXML script.

<?xml version="1.0" encoding="UTF-8"?>
<ccxml version="1.0" xmlns:voxeo="http://community.voxeo.com/xmlns/ccxml">

  <var name="state0" expr="'init'"/>
<!--
  When I used vxml I've got the variable by the next way:
  <var name="variable1"            expr="session.connection.ccxml.values.variable1"/>
  <var name="variable2"          expr="session.connection.ccxml.values.variable2"/>
  -->
  <eventhandler statevariable="state0">
    <!-- events -->
  </eventhandler> 
</ccxml>


Thanks in advance.
voxeojeff
2/19/2008 9:35 AM (EST)
Hi Alexey,

In CCXML Voxeo, you'll need to use server-side to grab the parameters passed to CCXML.  This is because CCXML Voxeo is based on the older 2002 specification.  The newer CCXML 1.0 W3C mark up actually has a session variable (session.values.*) to reference parameters passed into CCXML.  However, as I said, for CCXML Voxeo, you'll need to use server-side, or in this case, your php script.

Hope this helps,

Jeff
alexey.timofeev
2/19/2008 10:52 AM (EST)
Hi Jeff!
Thanks for your answer. I have one more problem.
I've written the php script in order to grab the variables.
I've made it initial application on my ccxml voxeo account.

I've used the next POST form to pass the variables:
<title>CCXML Token Trigger</title>
<form name="SampleForm"
  action="http://session.voxeo.net/CCXML.start"  method="POST">
  <input type="hidden" name="tokenid" value="**my token**">
 
  template<br>
  <input type="text" name="tmpl" size="10" maxlength="10" value="test.vxml"><br><br>

  <input type="reset" value="Clear">
   
  <input type="submit" name="submit" value="Give me a call!">
</form>

And my php-script is simply as following:
<?xml version="1.0" encoding="UTF-8"?>
<ccxml version="1.0" xmlns:voxeo="http://community.voxeo.com/xmlns/ccxml">
<var name="tmpl"  expr="'<?=$_REQUEST['tmpl']?>'"/>"
  <var name="state0" expr="'init'"/>
  <eventhandler statevariable="state0">
    <transition state="'init'" event="ccxml.loaded">
      <assign name="state0" expr="'dialing'"/>         
      <createcall dest="'tel:**my phone number**'"/>
    </transition>
    <transition state="'dialing'" event="connection.CONNECTION_CONNECTED">
      <assign name="state0" expr="'connected'"/>         
    </transition>

    <transition state="'dialing'" event="connection.CALL_CREATED">
      <log expr="'Call is created'"/>
      <exit/>
    </transition>


    <transition state="'dialing'" event="connection.CONNECTION_FAILED">
   
      <exit/>
    </transition>

    <transition state="'connected'" event="dialog.exit">
      <log expr="'Thats all for now folks.'"/>
      <exit/>
    </transition>

  </eventhandler> 
</ccxml>

But the debugger threw the script away - as the matter of fact the script was not even loaded:
'session terminated (document conversion analysis failed)'

Then I've tried the example from ccxml_postdial.zip
This time I've made Start.asp initial application on my ccxml voxeo account.
This time the script was successfully loaded but the next error occurred: 'error: first script failure (error (3, 2) "Expected an element name")'

Is this something with my account or I've done something wrong? Could you please make this issue more clear for me?

Thanks in advance.



voxeojeff
2/19/2008 11:43 AM (EST)
Hello again Alexey,

I see that the start URL for your application is a PHP document.  Our hosted server will only accept static XML documents, so this is why it is 'rejecting' your PHP script.  You'll want to host your PHP document on a PHP-capable webserver, and point the Start URL to that location.  Then the application should work as intended.

Hope this helps,

Jeff

login
  F: Outbound Dialing  |  TOC  |  Limiting Call length  

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