October 26, 2016
Hot Topics:

VoiceXML Developer Series: A Tour Through VoiceXML, Part XI

  • October 11, 2002
  • By Jonathan Eisenzopf
  • Send Email »
  • More Articles »


This dialog queries the Access database for an address matching the phone number that the user entered and confirmed in the telephone_number.vxml dialog. If we find a matching record, we transition to the confirm_address form, otherwise, we transition to the record_address form, which prompts the user to say their address.

This VoiceXML file is unlike the others we've develop so far, because it intermingles VoiceXML with PerlScript ASP code. On line 3, we specify that our ASP language in this script will be PerlScript. On lines 7 and 8, we create a new instance of an ADO object, and connect to the access database using the Microsoft Access database driver. On line 11, we retrieve the phone_number variable from the Request object. If you are unfamiliar with ASP, the Request object contains all of the field values that were submitted from a form. In our case, the phone_number field was submitted to this script by the telephone_number.vxml form.

Lines 12 through 22 convert the phone number, which may have been passed as a set of words rather than digits, is converted to numbers. Perl is well known for its regular expression and text processing capabilities, so it's well suited for creating complex VoiceXML applications, which require many different types of text and language processing from grammars and prompts to parsing input and output values. In fact, on line 36, you'll see another Perl regular expression that searches for a number in the address variable and encloses it in a <sayas> element so that the TTS engine will pronounce the number portion of the address as digits rather than a large number.

Lines 25-27 execute the select statement that searches for an address record in the database that matches a phone number. Lines 30-39 contain an if/else conditional expression that basically says, if we have a matching address, create a string that will assign the value to the application.address variable and then transition the user to the confirm_address form, otherwise, transition to the record_address form. In other words, if we find an address, we want to have the user confirm that it is the correct address. If we do not have an address on file, we want to have the customer tell us their address so we can save it for next time. Line 40 ends the main block of PerlScript code.

view example 3

Line 43 prints the value of the $string variable, which controls which form the user will be trasitioned to. If the customer has an address, they are transitioned to line 47, where we prompt the user (lines 49-53) to confirm their address, i.e. "I have your address as, 555 green wood drive. Is this correct?". We re-used the yes_or_no.vxml subdialog here, just as we did in telephone_number.vxml. If the use confirms their address, we transition to the take_order.vxml dialog, which will prompt the customer for their order. If they do not confirm their address, then we transition the user on line 60 to the record_address form starting on line 66.

The user will be sent to the record_address form if they say no when asked if their address is correct, or if the customer does not have an address on record. Either way, we need an address for the customer. Since we cannot accurately recognize a full address, we have to record it to a wav file with the <record> element on line 68. The audio content is submitted to the save_address.asp script where their database record is created or updated, and the audio file is saved to disk. An operator will need to go through the database on a regular basis and manually fill the address field in the Access database based on the recordings.


Well, we've completed the first three VoiceXML dialog files. In the next article, we will finish the last three dialog files in the application. Also, a few notes on what we've done so far. First, recognizing spoken numbers is not always 100% accurate. If you experience problems, you may want to convert to using DTMF tones to capture the number, which is almost always correct the first time. Also, we will need to go back and add event handlers and error checking once we've completed the initial version of the application.

About Jonathan Eisenzopf

Jonathan is a member of the Ferrum Group, LLC based in Reston, Virginia that specializes in Voice Web consulting and training. He has also written articles for other online and print publications including WebReference.com and WDVL.com. Feel free to send an email to eisen@ferrumgroup.com regarding questions or comments about the VoiceXML Developer series, or for more information about training and consulting services.

Page 2 of 2

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel