|« Prev Section||SOAP and REST Webservices|
The VXML Subdialog module can be used to run custom VoiceXML code directly within your Fuse application.
Please note that you will need to know VoiceXML to utilize the VXML Subdialog module. For a full reference of VoiceXML as related to the Plum DEV platform, as well as a tutorial to get you started in coding in VoiceXML, please see our Plum DEV documentation.
For our sample application, we're going to demonstrate how we can use this module to exchange data between a Fuse application and VoiceXML script.
First, drag a Digits Input module to your workspace and connect it to your Start module. In the textbox of the module, enter the following text: “Please enter your four digit PIN on your phone keypad.” Set up the module to take DTMF input only and set the min digits and max digits such that the module will only take 4 digits.
Next, drag a Set Variable module to your workspace and connect it to your Digits Input module. Set the variable name to “PIN” and assign it with the “digits” variable from the Digits Input module. Also, drag out a Reserve Variable module to your workspace and set its name to “license”.
Next, drag a VXML Subdialog module to your workspace and connect it to the Set Variable module. In the URL textbox, we're going to add the URL for our VoiceXML subdialog script: http://myserver.mywebsite.com/~mydirectory/fusesubdialogtest.php. For reference, here's what our VoiceXML script looks like:
<?php header("Content-type: text/xml"); echo("<?xml version=\"1.0\"?>\n"); $username = "Jane Doe"; $userbirthday = "February 8, 1975"; $userpin = $_GET[userpin]; ?> <vxml version="2.0"> <form id="getdriverslicense"> <var name="name" expr="'<?php echo($username)?>'"/> <var name="birthday" expr="'<?php echo($userbirthday)?>'"/> <var name="pin" expr="'<?php echo($userpin)?>'"/> <block> <prompt> You entered <value expr="pin"/>. Hello <value expr="name"/>, your birthdate is <value expr="birthday"/>. </prompt> </block> <field name="driverlicense" type="digits?length=5"> <property name="inputmodes" value="dtmf"/> <prompt> Please enter your five digit license number on your phone keypad. </prompt> <filled> <return namelist="driverlicense"/> </filled> </field> </form> </vxml>
In the VXML Subdialog module, for “Set Remote Var”, we're going to set a remote variable, userpin. For “to Value”, we're going to set it with the PIN variable to pass to our VoiceXML subdialog. For “Set Local Var”, we're going to set a local variable, license. For “to Return Var”, we're going to set it to the variable, driverlicense, which is being returned from our VoiceXML subdialog.
Next, drag a Multipart Prompt module to your workspace and connect it to your VXML Subdialog module. Enter the following text in the textbox: “You entered”. Click on the ”+” button to add two additional phrases/variables. to your module. Click on the toggler for your second phrase/variable to convert it to a variable and select license as your variable. For your third phrase/variable, enter the following text in the textbox: “as your driver's license.” Finally, drag a Hang Up or Exit module to your workspace and connect it to your Multipart Prompt module.
From this example, the Fuse application prompts the user to enter a 4-digit PIN on their phone keypad. Once the user enters 4 digits, the VoiceXML subdialog is called, with the Fuse application passing it a remote GET variable, userpin, via HTTP. For the subdialog, the script states the 4-digit input the user entered, the user's name, and the user's birthday. It then prompts the user to enter their 5-digit license number. Once the user enters a 5-digit number, the subdialog returns the variable, driverlicense, back to the Fuse application. The Fuse application then states the 5-digit license number that the user entered.
If an error occurs with your subdialog, you can use Event Handling to play a specific prompt to the user. The following example demonstrates how you could do this with your application:
Please note that if we are unable to fetch your VoiceXML script or if it does not validate, your subdialog will not execute and you will need to test fetching it yourself to debug the problem. For more information, you should consult our Plum DEV documentation or seek VoiceXML assistance from our Plum DEV forum.
|Next Section »||Sample PHP Webservice Code|