IVR and Submit

March 30, 2011

This morning, I received an IVR post on our developer forum wondering if user input contained within a <field> tag would be captured as long as the <submit> tag was used to submit the input variable to a particular document on his web server.

The answer is yes!

In general, for data transfers within an IVR application, the <submit> tag performs a GET or POST that will trigger a page transition. This means that document level variables will be lost once the new page is fetched and parsed. To preserve some of the current execution context, the <submit> tag can send document level variables as POST or GET variables to your application server script. This application server script gets parsed by your application server, which can then process variables sent to it before generating a VoiceXML document to be parsed by the VoiceXML platform to interact with the caller.

Also, just as a short IVR example to demonstrate this VoiceXML data transfer technique:

example.php:

<?php
header(”Content-type: text/xml”);
echo(”<?xml version=\”1.0\”?>\n”);
?>
<vxml version=”2.0″>
<form>
<field name=”myfield”>
<grammar type=”application/x-jsgf” mode=”dtmf voice”>
1 | 2
</grammar>
<prompt>
Please say one or two.
</prompt>
<filled>
You entered <value expr=”myfield”/>.
<submit next=”submit.php” method=”post” namelist=”myfield”/>
</filled>
</field>
</form>
</vxml>

submit.php:

<?php
header(”Content-type: text/xml”);
echo(”<?xml version=\”1.0\”?>\n”);

$myfield = $_POST[myfield];
?>

<vxml version=”2.0″>
<form>
<block>
<prompt>
We got your variable. It is <?php echo($myfield)?>.
</prompt>
</block>
</form>
</vxml>

Hope this helps you IVR developers out there.

Leave a Reply