ne obstacle that’s impeded the development of voice applications is the availability of a dedicated, standard or well-known development architecture. To create robust voice applications, voice developers have had to be familiar with many languages, techniques, architectures, and processes. Compounding this problem, voice applications are often built using proprietary markup languages. The emergence of the standard for VoiceXML 2.1 (and soon to come 3.0) eliminates some of this complexity, allowing voice developers to better focus their skills. VoiceXML allows you to adopt Web programming models for your voice applications, and implement them using a server-side framework?like Struts?in the same way you’d implement a Web applications. Using this kind of framework, you can make the transition from Web application to voice application much more easily.
Although speech recognition has improved in recent years, it is still more error-prone than collecting data from a form in a Web page, since background noise and other factors can interfere with the recognition. Therefore, unlike Web applications, voice applications require dialogs between the computer and user to confirm the input, re-prompt the user when there’s no input, etc. The Reusable Dialog Component (RDC) Open Source project intends to help J2EE, JSP, and Struts developers transition into voice application development by using already familiar technology. RDCs are implemented as JSP 2.0 tags and support the Struts framework. Using RDCs to handle the interactions for common dialogs frees you up to deal with more complex areas of your application.
What are RDCs?
A Reusable Dialog Component (RDC) is basically a JSP 2.0 tag, which generates VoiceXML at runtime. RDCs are part of the RDC Tag Library open source Jakarta project. Version 1.0 of the RDC Taglib was released in July 2005. The RDC Taglib projects implifies the development of server-side code in order to generate Voice XML. The RDC Taglib project includes a set of RDCs, which are a collection of JSP 2.0 tags that assist in the development of Voice applications. The RDC tags generate VoiceXML at runtime, which can execute on any VoiceXML 2.0 compliant platform. The RDC Taglib also provides a framework for implementing additional RDCs. The framework helps in orchestrating each individual RDC making sure the user data is collected, verified, and canonicalized. The collection of RDCs included in the Taglib project is made up of both, atomic and composite RDCs. Atomic RDCs collect a single piece of information from the user. For example, date, time, or zipCode are atomic RDCs. Composite RDCs collect multiple pieces of information from a user. These are usually done by using atomic RDCs or aggregating a composite with other atomic RDCs. The RDC project currently includes two such composite RDCs: mortgage and creditcardInfo.
While setting up a development environment that uses RDCs isn’t complicated, it can be a time consuming depending on how much of the necessary software you need to download:
- JSP 2.0 Support: You can get this from either Tomcat 5.0 and IBM WebSphere Application Server 220.127.116.11. If you do not have WebSphere, download Tomcat 5.0 from Apache and follow its instructions to install (you will need a JDK 1.4.2 to run Tomcat).
- The JSTL 1.1, jsp-api.jar, and commons-el.jar libraries: These libraries are prerequisites for the RDC tag library. Find them under
- Struts 1.2x
- The RDC Tag Library: Download this from Apache and add it to the classpath.
Using your favorite IDE for developing Web applications, add all these libraries to your classpath or project and you should be all set to develop and run a voice application using RDCs. This article was written using IBM Rational Application Developer 6.0 with the Voice Toolkit 6.0. The Voice Toolkit includes a nice simulator, which you can use to test the voice application.
The Sample Application
The sample application in this article is a simple voice application that uses RDCs to order pizzas. The application answers calls, asks customers for their telephone numbers to verify that they are already in the system, and takes their order. Customers are then given the choice of paying cash or by credit card. This application uses three existing RDCs:
- The atomic digits RDC: collects the telephone number.
- select1: lists the payment options.
- The composite creditcardInfo RDC: collects the credit card information.
The application is designed using the Struts framework for a well-defined Model View Controller framework and to take advantage of the RDC’s framework’s Struts support. Each interaction with a customer has its own JSP file containing VoiceXML. The JSPs submit the user input to Struts Actions and Form Beans collect the data. Figure 1 shows the JSPs, Struts Actions, and Form Beans that make up the application.
|Figure 1. The Sample Application: This diagram displays the JSPs, Struts Actions, and Form Beans that make up the pizza ordering voice application.|
To keep it simple, concentrate on the JSPs that instantiate the RDCs: welcome.jsp, paymentType.jsp, and creditCardInfo.jsp. Listing 1 shows the welcome.jsp. This JSP defines a PizzaOrderBean with session scope. The bean holds all the current order information?amount owed, number and type of pizzas, payment type, delivery time, etc. This bean is updated throughout the call as input from the customer is processed.
Next in the JSP, notice a VoiceXML block containing a prompt to welcome the user. Inside the
The JSP containing the select1 RDC is very similar to the welcome.jsp, except that the select1 RDC contains an additional attribute. optionList points to an .xml file that defines the options for the RDC. The following code shows the RDC that instantiates the select1 RDC.
The paymentType-Options.xml is very simple and just lists the two options for payment. The code below shows the XML file listing the payment options for select1 RDC:
The composite creditcardInfo RDC is defined in the same way as the atomics digits. However, the configuration file for the composite RDC points to the configuration files for the atomic digits RDCs it contains and that you wish to overwrite. In this case, only the creditcardExpiry configuration file is overwritten. All the other atomic RDCs contained in the creditcardInfo use the default configuration file:
Of course, to make the pizza application complete, you need to create a grammar file and a JSP containing VoiceXML to collect the actual pizza order from customers, as well as all the server-side code. For reference, Listings 3 and 4 show the grammar and JSP, respectively, for this portion. A voice developer should be able to easily implement the grammar and VoiceXML portion to get the order from the customer. And a Web developer should implement the server-side code. But that is beyond the scope of this article.
The Benefits of RDCs
Using RDCs to implement a voice application is ideal for Web developers unfamiliar with VoiceXML. Generating the VoiceXML from the RDC tags at runtime simplifies the creation of components commonly used in voice applications, allowing you to design and implement a voice application just like any other Web application. The RDC framework provides some struts-specific tags that make it easy to use the Struts Framework for development and design. Wherever common dialogs are needed, you simply use the RDC tags. Keep in mind that a production voice application would require more complex grammars, VoiceXML, etc than the existing RDCs can provide. A voice developer can fill this role by authoring the appropriate speech fragments and providing professional quality audios, etc. These could then be integrated into the application to make a complete voice application.