package VoiceXML::Client; =head1 NAME VoiceXML::Client - Perl extension for VoiceXML (VXML) clients, including useragent, parser and interpreter. =head1 SYNOPSIS #!/usr/bin/perl use VoiceXML::Client; use strict; # basic info for VoiceXML source my $sourceSite = 'voicexml.psychogenic.com'; my $startURL = '/vocp.cgi'; # using dummy device here, to get started my $telephonyDevice = VoiceXML::Client::Device::Dummy->new(); $telephonyDevice->connect(); # our workhorse: the user agent my $vxmlUserAgent = VoiceXML::Client::UserAgent->new($sourceSite); # go for it: $vxmlUserAgent->runApplication($startURL, $telephonyDevice); # that's it... runApplication will return when it has hung up the device. =head1 DESCRIPTION The VoiceXML::Client library allows you to fetch, parse and interpret VoiceXML files. It was developed as a supporting component of the (upcoming version of the) VOCP voice messaging system (http://www.vocpsystem.com). It's role is to: - fetch vxml files - parse their contents - interpret them by executing the instructions therein It is not (yet) a complete implementation of the VoiceXML specs, but does support a lot of interesting features. Have a look at the included exampleBBSBox.vxml file for an idea of what is possible. A quick tour of this file will give you a taste of what's available. =head2 Telephony Interface As noted above, the user agent's runApplication() method is called with two parameters: a URL and a handle to some telephony device. While executing the voicexml code, VoiceXML::Client will likely need to do things like play audio files, collect user DTMF input and allow callers to leave messages. The vxml page tells VoiceXML::Client what to do, and the telephony interface is used to actually perform these actions. Exactly how the device collects user input etc is left as an excercise to the implementor. The only thing that counts from VoiceXML::Client's perspective is that the handle support the VoiceXML::Client::DeviceHandle interface. During testing, you may use VoiceXML::Client::Device::Dummy as the telephony handle. This is a simplified implementation whose only effect is to print all calls to stdout and request DTMF input from the command line, when required. As a programmer, the majority of your work will be in replacing the VoiceXML::Client::Device::Dummy device in the code above with some implementation of the API that actually controls an interesting device. See the Telephony Interface section on http://voicexml.psychogenic.com/api.php for a complete discussion, or have a look at the VoiceXML::Client::Device::Dummy and VoiceXML::Client::DeviceHandle documentation. =head2 VoiceXML A complete discussion of the supported VoiceXML can be found at http://voicexml.psychogenic.com/voicexml.php A summary is provided here. VXML provides for TUI forms to be "displayed" to users (through recorded prompts), and can accept input that fills fields within the form. Each user input field is set based on user DTMF input, and other variables can be created and manipulated in the VXML:
Here you can see a lot of the action. The invalidcount variable is created and set to 0. The first form encountered is entered, the prompt for the first field (movetosel) contains prompts which are played. The filled item awaits user input. Once this is received (or times out), a variable of the same name as the field is initialized with user input. Conditionals can check the value entered by the user, and jump to other forms within the page (or to other pages). Simple arthmetic can also be performed as demonstrated by the invalidcount counter. Voice recordings can be made by users through the use of a item: You may also use items to GET another page: and more complex actions may be performed by submitting data collected through a submit element: would fetch the page output by the same script but would also pass along the values of each of the variables specified in the namelist. More information can be found at http://voicexml.psychogenic.com/ =head2 Supported Elements Currently, the following VoiceXML elements are recognized and supported, at least partially: - assign - audio - block - break - clear - disconnect - else - elseif - field - filled - form - goto - grammar - if - noinput - nomatch - option - prompt - record - reprompt - return - rule - subdialog - submit - var A description and examples of each will be found in the VoiceXML section of the project site, at http://voicexml.psychogenic.com/voicexml.php =head2 Interpreter Variables may be set and manipulated while executing the contents of a voicexml page. The Voice Extensible Markup Language specifications are, currently, far from respected in this regard within VoiceXML::Client. Instead of using a full ECMAScript interpreter, a simple Perl interpreter was created that is, to date, sufficient for most of our requirements. What is available includes, variable creation: and assignment: Note that, unlike numeric values, strings need to be 'quoted'. Comparison operators may be used in the cond attribute of if/elseif elements, and simple arithmetic may be performed in expr attributes: Note here that <, >, <= and >= must be HTML encoded. Variables may also be used in places like