Telephony Isn't All Talk for Java Developers (cont'd)

Outputting the Actual Code

At this point, we're ready to start outputting the actual VoiceXML code. Like any XML document, we should start out with an XML Prolog, following that with the VoiceXML tags. VoiceXML documents consist of "forms" containing a dialog and "fields" within the forms to capture user responses. Add a few logical operators, some structure tags, an exception handler, and miscellaneous flow tags, and you've covered the basics. You can find much more information about VoiceXML at W3C and some coding tips at Voxeo.

This section of the code is very repetitive, since you're just writing text to the HTTP output, where it will be read by the XML user agent responsible for executing the application. Because the VSP will handle the actual execution for you, your server doesn't need to know anything about telephones at all.

// Create the VoiceXML code
    out.println( "" );
    out.print( " '-" );
    out.print( "//Nuance/DTD VoiceXML " );
    out.print( "1.0b//EN'" );
    out.print( "'http://community.voxeo.com/" );
    out.println( "vxml/nuancevoicexml.dtd'>" );
    out.println( "" );
    out.println( "" );
    out.println( "
" );

Dispensing with Print Statements

At this point, we'll dispense with the Java print statements, since they just get in the way of understanding the structure of the VoiceXML code itself. First, we'll recapitulate the code so far and add a bit more describe the voice input form, very similar to an ordinary HTML input form, and get us to the point where we need to describe what our voice input should look like.

<?xml version="1.0"?>
<!DOCTYPE vxml PUBLIC '-//Nuance/DTD VoiceXML 1.0b//EN'
'http://community.voxeo.com/vxml/nuancevoicexml.dtd'>
<vxml version="1.0">
<!-- Label input form so we can branch to it -->
  <form id="VoiceApp">
    <!-- Exception handlers -->
    <catch event="exit">
      <goto next="#Goodbye" />
      </catch>
    <catch event="help">
      <audio src="vxmlhelp.wav" />
      <reprompt />
      </catch>
    <catch event="operator">
      <audio src="vxmlnoop.wav" />
      <reprompt />
      </catch>
    <noinput>
      <audio src="vxmlnoinput.wav" />
      <reprompt />
      </noinput>
    <nomatch>
      <audio src="vxmlnomatch.wav" />
      <reprompt/>
      </nomatch>
    <!-- Delimit and name the input field -->
    <field name="Destination">
      <prompt>
        <audio src="vxmlwelcome.wav" />
        <audio src="vxmljavachoice.wav" />
        </prompt>

     Next: Starting the Input Field

1 Introduction 2 Coding a Java Telephony Application ^ Outputting the Actual Code
4 Starting the Input Field 5 Closing Out the Statement 6 Code It Yourself
Back to Top of This Page
 

Sun Microsystems

Polyphone, Inc.

IBM's Alphaworks

Lucent Technologies

DevX Book Bonus: A Review of "Essential JTAPI--Java Telephony API," by Spencer Roberts (Prentice Hall, 1999)


 TALK BACK
What has been your experience writing telephony applications? What are the pitfalls involved? If you haven't worked on one, do you expect to do so anytime in the near future? Join the discussion.
Click here to Join


Save on Hot Java Specials
SOFTWARE:
dtSearch Web
Add power searching to your web site.
Buy Now!
BOOKS:
PointBase Mobile Edition
Enable local data access for mobile users.
Buy Now!
Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map
Jupiterweb networks

internet.comearthweb.comDevx.comClickZ

Search Jupiterweb:

Jupitermedia Corporation has four divisions:
JupiterWeb, JupiterResearch, JupiterEvents, and JupiterImages

Copyright 2004 Jupitermedia Corporation All Rights Reserved.
Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Jupitermedia Corporate Info | Newsletters | Tech Jobs | E-mail Offers