Page 1 of 1
Repeat/Skip mySQL row
Posted: Wed Aug 29, 2007 9:31 pm
by KikiEss
I have a general question.
I just created files of vxml and php script aimed at providing information from an sql database, depending on user input (e.g., pressing 1 will provide users with a list of all of the record stores and their addresses in the area).
I wanted to include an option that allows the user to repeat a row of data or skip to the next row matching the query. Is this possible in php? And if not, could I do it using xml data?
A bit of guidance is all I need.
IVR developers need more info for Repeat/Skip mySQL row
Posted: Thu Aug 30, 2007 11:29 am
by support
Hello,
Could you please provide more details about what exactly you are trying to accomplish with your IVR application? The solution to this is going to be highly implementation dependent. How exactly are you attempting to present the information to the user? For example are you going to read 1 row and then ask them to press 1 for the next row, press 2 to skip one row? Or are you planning on trying to play all the rows one after another with the ability to press 1 to skip ahead?
Regards,
Plum Support
Posted: Thu Aug 30, 2007 3:05 pm
by KikiEss
The latter. It's set to just echo the rows one after the other. I want to allow the user the option of pressing 1 to repeat the row or 2 to skip to the next row.
Using PHP/SQL to creat one large IVR document
Posted: Thu Aug 30, 2007 3:41 pm
by support
Hello,
In that case this really is less a PHP question and more of a VoiceXML question. The VoiceXML script should contain several fields each
<field> can be used to read back a single row. For an IVR example here is some static VoiceXML that will read back a single piece of data, depending on the user input it will either repeat, skip ahead or continue on at the end of the audio file:
Code: Select all
<?xml version="1.0"?>
<vxml version="2.0">
<form>
<block>
<prompt>Here are the results. You can press 1 to repeat an item or press 2 to skip ahead to the next item.</prompt>
</block>
<field name="field1" type="boolean">
<prompt timeout="0s">
This is the first item of information.
This is the description of the item blah blah blah.
</prompt>
<catch event="noinput nomatch">
<!-- this assign marks this field as "filled" and goes to the next item -->
<assign name="field1" expr="0"/>
</catch>
<filled>
<if cond="field1">
<clear namelist="field1"/>
<reprompt/>
</if>
<!-- do nothing and we'll fall through to the next field -->
</filled>
</field>
<field name="field2" type="boolean">
<prompt timeout="0s">
This is the second item of information.
This is the description of the item blah blah blah.
</prompt>
<catch event="noinput nomatch">
<!-- this assign marks this field as "filled" and goes to the next item -->
<assign name="field2" expr="0"/>
</catch>
<filled>
<if cond="field2">
<clear namelist="field2"/>
<reprompt/>
</if>
<!-- do nothing and we'd fall through to the next field if there were one -->
</filled>
</field>
</form>
</vxml>
In your case rather than using static VoiceXML you should dynamically create the list of fields following the pattern above using PHP/SQL. This allows you to create one large VoiceXML document from the data in your database and uses the internal logic of VoiceXML to repeat a field or skip ahead to the next one.
Regards,
Plum Support
Posted: Thu Aug 30, 2007 5:24 pm
by KikiEss
thank you kindly

Follow-up
Posted: Fri Aug 31, 2007 10:46 am
by KikiEss
Sorry to bother you again. I just wanted to make sure I completely understood the response.
If I understand correctly, I could very well connect to the sql data at the beginning of a vxml document, using php code. And then, using a setup similar to the one you provide above, just use each row's information to populate the prompts.
Sound about right?
output sections of IVR script using PHP in each row of data
Posted: Fri Aug 31, 2007 11:09 am
by support
Hello,
That is correct, you would connect to the database at the beginning of the IVR script and then output the
"<field>...</field>" sections of the VoiceXML script dynamically using PHP for each row of data.
Regards,
Plum Support
Posted: Fri Aug 31, 2007 11:10 am
by KikiEss
Cool beans

Umm...I think I may be going about this wrong.
Posted: Thu Sep 27, 2007 12:25 am
by KikiEss
So, I may be a bit guilty of trying to do this the easiest way that I can imagine. As a result, I think I'm doing this all wrong. To make a long story short, I reference a php file called "PhillyConnect" near the top of the file to allow access to my database and create the table of data that I'll need to populate my prompts.
[Please note the queries do in fact work, as I already tested them server-side. Also note that I'm only including one of the fields (Metro1) at the moment, since I see no point in listing them all if the first one doesn't work yet.]
I try to populate the prompt utilizing php script, but it doesn't work. The call goes through the entire thing correctly, except for the fact that it completely ignores the php section in the "Metro1" field. [I checked the log and that is exactly what it's doing; there is no error.]
Below is my code. Please help, if at all possible.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE vxml PUBLIC "-//The Plum Group//Voice Markup Language 2.0//EN"
"http://vxml.plumgroup.com/vxml-221.dtd">
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
<?php
include("http://URL/FileName.php")
?>
<form id="AllPhillyList">
<block>
<prompt bargein="false">
The following is a complete listing in the Philadelphia metro.
Press 1 at any time to repeat a listing.
Press 2 to skip to the next listing.
Press the star key to go back to the previous menu.
Press the pound key to disconnect.
</prompt>
</block>
<field name="Metro1">
<grammar type="application/x-jsgf" mode="dtmf">0|1|2|"*"|"#"</grammar>
<prompt bargein="true">
<?php mysql_data_seek($result, 0);
$info=mysql_fetch_assoc($result);
echo $info["name"] . ", located at " . $info["address"] . ", phone number " . $info["phone"];
?>
</prompt>
<filled>
<if cond="Metro1==1">
<clear namelist="Metro1"/>
<reprompt/>
<elseif cond="Metro1==2"/>
<goto next="Metro2"/>
<elseif cond="Metro1=='*'"/>
<goto next="EEPhillymenu"/>
<elseif cond="Metro1=='#'"/>
<goto next="#end"/>
</if>
</filled>
<catch event="noinput nomatch">
<assign name="Metro1" expr="0"/>
</catch>
</field>
<field name="EndValue">
<grammar type="application/x-jsgf" mode="dtmf">1</grammar>
</field>
<filled>
<if cond="EndValue==1">
<goto next="#ListEnd"/>
</if>
</filled>
<catch event="noinput nomatch">
<goto next="#ListEnd"/>
</catch>
</form>
<form id="ListEnd">
<property name="timeout" value="5"/>
<field name="EndChoice">
<grammar type="application/x-jsgf" mode="dtmf">1|2|"#"</grammar>
<prompt bargein="true">
To repeat these listings, press 1.
To go back to the main menu, press 2.
Press the pound key to disconnect.
</prompt>
<filled>
<if cond="EndChoice==1">
<goto next="Metro1"/>
<elseif cond="EndChoice==2"/>
<goto next="EEPhillymenu"/>
<elseif cond="EndChoice=='#'"/>
<goto next="#end"/>
</if>
</filled>
<nomatch>
I did not understand that response.
<reprompt/>
</nomatch>
<noinput>
<reprompt/>
</noinput>
<noinput count="3">
<prompt>Thank you for calling the Elite Entertainment Hotline.</prompt>
<disconnect/>
</noinput>
</field>
</form>
<form id="end">
<block>
<prompt>
Thank you for calling the Elite Entertainment Hotline.
</prompt> <disconnect/>
</block>
</form>
</vxml>
IVR code needed to understand user's issue
Posted: Thu Sep 27, 2007 10:16 am
by support
Hi,
It is not clear as to where the value $result is being set in your IVR code. Can you please provide us with more information to help you resolve this IVR issue? For debugging, you should go to your .php file in a web browser. From here, you can view the results of your .php code.
Regards,
Plum Support
...
Posted: Thu Sep 27, 2007 10:31 am
by KikiEss
$result stores the data from my PhillyMetro table in my database. The php script as a whole works "perfectly".
I split the script up into 2 parts- the php file referenced in the beginning and the part that you see under the Metro1 field. I did this to allow me the ability to change the mysql_data_seek value in each field (these fields will be included once I get this first one to work).
In other words, the php file in the beginning connects to the server, the database and the table; and then selects all the data into $result.
The prompt portion in the Metro1 field simply moves the pointer, fetches the data and presents it.
Maybe it just can't be done this way. Maybe the script can't be split up. I don't know. I'd hate to have to do this portion completely in PHP, dynamically creating the vxml, to alleviate confusion in the system.
Return raw php back to IVR application
Posted: Thu Sep 27, 2007 1:46 pm
by support
Hi,
You should change this line of IVR code:
Code: Select all
include("http://URL/FileName.php")
to this:
This will return the raw php back to your IVR application instead of making a request to the IVR server.
Regards,
Plum Support
still no worky...
Posted: Sat Sep 29, 2007 11:23 am
by KikiEss
Hey support
Well, I tried what you said. Put everything on the server, since I had mainly been working off of the scratchpad, and changed the include to read AllPhillyConnect.php. And it didn't work.
I even went so far as to completely delete the initial include statement, opting to insert it's contents directly into the prompt section, e.g.,
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE vxml PUBLIC "-//The Plum Group//Voice Markup Language 2.0//EN"
"http://vxml.plumgroup.com/vxml-221.dtd">
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
<form id="AllPhillyList">
<block>
<prompt bargein="false">
The following is a complete listing in the Philadelphia metro.
Press 1 at any time to repeat a listing.
Press 2 to skip to the next listing.
Press the star key to go back to the previous menu.
Press the pound key to disconnect.
</prompt>
</block>
<field name="Metro1">
<grammar type="application/x-jsgf" mode="dtmf">0|1|2|"*"|"#"</grammar>
<prompt bargein="true">
<?php
// Connecting to server
$db = mysql_connect("localhost", "username", "password") or die(mysql_error());
//Selects database
$data = mysql_select_db("database name", $db) or die(mysql_error());
// Grabs all data
$result = mysql_query("SELECT * FROM Table ORDER BY name") or die(mysql_error());
mysql_data_seek($result, 0);
$info=mysql_fetch_assoc($result);
echo $info["name"] . ", located at " . $info["address"] . ", phone number " . $info["phone"];
?>
</prompt>
<filled>
<if cond="Metro1==1">
<clear namelist="Metro1"/>
<reprompt/>
<elseif cond="Metro1==2"/>
<goto next="#Metro2"/>
<elseif cond="Metro1=='*'"/>
<goto next="EEPhillymenu.vxml"/>
<elseif cond="Metro1=='#'"/>
<goto next="#end"/>
</if>
</filled>
<catch event="noinput nomatch">
<assign name="Metro1" expr="0"/>
</catch>
</field>
<field name="EndValue">
<grammar type="application/x-jsgf" mode="dtmf">1</grammar>
</field>
<filled>
<if cond="EndValue==1">
<goto next="#ListEnd"/>
</if>
</filled>
<catch event="noinput nomatch">
<goto next="#ListEnd"/>
</catch>
</form>
<form id="ListEnd">
<property name="timeout" value="5"/>
<field name="EndChoice">
<grammar type="application/x-jsgf" mode="dtmf">1|2|"#"</grammar>
<prompt bargein="true">
To repeat these listings, press 1.
To go back to the main menu, press 2.
Press the pound key to disconnect.
</prompt>
<filled>
<if cond="EndChoice==1">
<goto next="#Metro1"/>
<elseif cond="EndChoice==2"/>
<goto next="EEPhillymenu.vxml"/>
<elseif cond="EndChoice=='#'"/>
<goto next="#end"/>
</if>
</filled>
<nomatch>
I did not understand that response.
<reprompt/>
</nomatch>
<noinput>
<reprompt/>
</noinput>
<noinput count="3">
<prompt>Thank you for calling the Elite Entertainment Hotline.</prompt>
<disconnect/>
</noinput>
</field>
</form>
<form id="end">
<block>
<prompt>
Thank you for calling the Elite Entertainment Hotline.
</prompt> <disconnect/>
</block>
</form>
</vxml>
The result was the same. Again, the php code on it's own works fine when in a php file. You can check it out yourself by clicking on this link
http://www.elitee.net/AllPhillytest.php .
Why won't it work when called in the prompt?
IVR application needed to better understand user's problem
Posted: Mon Oct 01, 2007 10:14 am
by support
Hi,
Could you provide a direct link to the IVR application? This will help us better understand your IVR problem.
Regards,
Plum Support
Changing file extension should resolve IVR issue
Posted: Tue Oct 02, 2007 3:09 pm
by support
Hello,
Based on the email that your sales representative forwarded on to support the problem is that you are attempting to include PHP directly in a *.vxml file. Apache/PHP will only work if the file extension is *.php. Our IVR platform will ignore the file extension and automatically parse the file as VoiceXML, so there is no reason for you to use *.vxml. Without the php file extension your web server is simply returning the unparsed PHP mixed with the VXML already in the file. Changing the file extension should resolve the IVR issues you are having.
Once you rename your file you should be able access it directly in a web browser and confirm that the VXML being dynamically generated looks correct. This makes it much easier to debug any further IVR issues without needing to call into our IVR system.
Regards,
Plum Support