The previous article in this series on VoiceXML introduced menus and forms, the two kinds of dialog elements used in building voice applications. Menus are handy when we have a set of predefined options to present to our users. Forms are more flexible, enabling us to collect multiple input items. In this installment, we’ll dig deeper into forms by creating a login page and then a data capture page for a Baseball Facts Hotline in which users will be able to use cell phones to log in and request baseball stats.
VoiceXML Form Structure
To capture data from our users, we need to understand how VoiceXML forms work. A VoiceXML form is very similar to an HTML form. Figure 1 shows a comparison. Each input field is associated with a VoiceXML field element that includes a prompt element containing the text or audio file reference that the user will hear.
In addition to field elements, forms can also contain block elements, which provide executable content but do not collect information from users. In Figure 1, a block element at the top of the form is used to present an introductory message to the user. The block at the end of the form is used to send the collected data to a server for processing. A common pattern in many VoiceXML forms is to have an introductory block and a final block that serves to submit data to a server, similar in function to the SUBMIT button on an HTML form.
Figure 1 A traditional web form versus a VoiceXML form