CallXML 2.0 Development Guide Home  |  Frameset Home

  Introduction to Document Navigation  |  TOC  |  External Document Navigation  
This documentation is for CallXML 2, which has been superceded by CallXML 3. The CallXML 2 language is not being updated any longer. CallXML 3, however, has many new features and is actively being enhanced. If you're writing a new CallXML application, you should use CallXML 3. Click here for the CallXML 3.0 documentation.

Tutorial: Document Navigation

This Lesson is based on the things you accomplished in tutorial 1 & 2. If you haven't yet done those Lessons, you'll need to go through them first.


In this Lesson, we will:

Step 1: the block element

In the previous Lesson, we ended up with a callxml file that looked like this...

<?xml version="1.0" encoding="UTF-8" ?>
<callxml version="2.0">
  <playaudio value="helloworld.wav"
            termdigits="*#"/>
  <ontermdigit value="*">
    <text>you pressed the star key.</text>
  </ontermdigit>
  <ontermdigit value="#">
    <text>you pressed the pound key.</text>
  </ontermdigit>
</callxml>


...and we learned about callxml action elements and callxml event elements. There is a third category of callxml elements, known as block elements. Block elements group action and event elements together.

For example, you could add a block element to the above callxml file above like this:


<?xml version="1.0" encoding="UTF-8" ?>
<callxml version="2.0">
  <block>
    <playaudio value="helloworld.wav"
              termdigits="*#"/>
    <ontermdigit value="*">
      <text>you pressed the star key.</text>
    </ontermdigit>
    <ontermdigit value="#">
      <text>you pressed the pound key.</text>
    </ontermdigit>
  </block>
</callxml>


If you were to dial into this updated callxml file, you would find that it does the same thing as the previous callxml file. Block elements are not required, but they are useful when you want to organize your actions & events into ordered groups. And us humans, being scared and panicky animals that we are, like to see order and unity; it helps keep our egos intact.


Step 2: the block element and the goto element

We could further break our "hello world with events" callxml file into blocks, and use the <goto> element to jump from one block to another. We'll talk more about the <goto> element in a moment:

<?xml version="1.0" encoding="UTF-8" ?>
<callxml version="2.0">
  <block>
    <playaudio value="helloworld.wav"
              termdigits="*#"/>
    <ontermdigit value="*">
      <goto value="#one"/>
    </ontermdigit>
    <ontermdigit value="#">
    <goto value="#two"/>
    </ontermdigit>
  </block>

  <block label="one">
    <text>you pressed the star key.</text>
    <exit/>
  </block>

  <block label="two">
    <text>you pressed the pound key.</text>
    <exit/>
  </block>

  <onerror>
  <sendemail from="MyApp@here.com"
    to="YourEmail@there.net" type="debug">
    We caught an error in our application.  Details follow...
  </sendemail>
  </onerror>

</callxml>


This updated callxml file still functions the same as the callxml we started with from the previous Lesson. However, we've used the <block> element to break our actions into separate pieces, and the <goto> element to jump from one block to another.

As you see above, the <block> element has a label attribute which "names" the block; and the <goto> element has a value attribute, which describes where to jump to. In this example, the "#" in front of the block label indicates that we're jumping to a specific block in this file. <goto> can also be used to jump to blocks in separate callxml files; we'll investigate that in a later tutorial.


Step 3: save, upload, and try it out

Your updated hello world callxml file is now done. go ahead and save it as "helloworld.xml", and upload it to the same web server and directory you uploaded to in the previous tutorial. Call the number associated with your callxml file, and you'll find that the results of this tutorial work just like the previous one -- except now we know how to use block's and goto's.

  CallXML 2.0 source code.




  ANNOTATIONS: EXISTING POSTS
seanohagan
11/27/2005 5:04 AM (EST)
The code in Step 2 does NOT do the same thing as the code in Step 1. The second version clearly speaks both text messages when the user presses the star key.
MattHenry
11/27/2005 12:41 PM (EST)


Hello Sean,

Correct you are; our sample code is missing an <exit/> within it's blocks, and should really read like this:

  <block label="one">
    <text>you pressed the star key.</text>
    <exit/>
  </block>

  <block label="two">
    <text>you pressed the pound key.</text>
    <exit/>
  </block>

I have this fixed in our internal build of the docset, and will be made live in the near future.

~Matt




login
  Introduction to Document Navigation  |  TOC  |  External Document Navigation  

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