VoiceXML 2.1 Development Guide Home  |  Frameset Home

  Intro to Server Side  |  TOC  |  tutorial Dynamic Grammars  

Passing Querystring Variables using ASP/JSP/PHP/CF


Since we are now to the point where we have covered most of the concepts you’ll need to know on the voiceXML side of the fence, our next logical step is to look into how we can broaden our scope, and add some more horsepower to our application. After all, while an application that uses dialogs to gather a caller’s input is pretty flashy, in a real-world environment, we would probably need to take this data, and do something meaningful with it, right?

In this section of the documentation, we will look at some basic backend scripting.  To start off, we will look at the Wrong Way, and the Right Way pass a value from one page to another using ASP. Once we have covered this in sufficient detail, we will get a bit fancier, and expand our example to show how we can accomplish 3 goals:



First Steps

The fist step of passing data is within the XML level of the code. We know we can take a caller’s input within a <field>, but how the heck to we pass it along to another page, and do something dynamic with it? Well, once we accept caller input, we can send this to a dynamic page by using the <submit> or <data> elements, and specifying the variable names we want to send across within the namelist attribute:


<field name=" F_1" type="boolean">
  <prompt>Is there anything more stupid than dog sweaters?</prompt>

<filled>
  <submit next="http://MyServer.com/MyPage.asp" namelist="F_1"  method = "get"/>
</filled>
</field>


A quick rundown of the above code is that we ask a yes/no question, and store the caller’s answer in a variable named F_1. We then take this variable, and submit it via the GET method to our post-processing page at http://MyServer.com/MyPage.asp .

Questions:



Next Steps

The next item of business is to grab our voiceXML variable, and store it within the asp context. How the heck do we do that? Whenever we do a <submit>via GET method  to another document, and tack on some variables in the namelist, we will see the following in the voxeo application debugger:

Now going to: http://MyServer.com/MyPage.asp?F_1=yes

Conversely, when we submit variables using the POST method, it will look slightly different:

Now going to: http://MyServer.com/MyPage.asp

We won’t see the variable/value pairs in the querystring, but they are indeed there. The primary purpose of using POST is to hide our sensitive querystring data from prying eyes, and nosy neighbors.

Regardless, each server side markup has it’s own separate methods for grabbing querystring variables, be they POST or GET. Let's now look at a common misconception about sending variables back and forth, this being that it can be done strictly with XML documents:

MyPage.xml


<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.1">

<form>
<block>
<prompt>
  When asked if anything was more colossally dumb than dog sweaters, you indicated that this is 
    <value expr=F_1>
  </prompt>
</block>
</form>

</vxml>


Note that this example, "MyPage.xml" will most certainly *not* work. This document has no idea of the value of the variable named F_1, and as such it will throw an error.semantic event to the browser. The point in this bad example is that we cannot submit a variable value to a static page in any way whatsoever. Now that this point is hammered home, let’s take a look at an example in ASP that will actually take these querystring values and properly store and output the value:

MyPage.asp


<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.1">

<%
' ******************************************************
' Grab the querystring variable via ASP
MyASPQueryStringVar  = request.querystring("F_1")

'*******************************************************
' store it as a voicexml variable local to this page
'*******************************************************
response.write "<var name=""MyVxmlVar""  expr=""" & MyASPQueryStringVar & """/>"

%>


<form>
<block>
<prompt>
  When asked if anything was more colossally dumb than dog sweaters, you answered
    <value expr="MyVxmlVar">
  </prompt>
</block>
</form>

</vxml>



The Next Level


The next set of code illustrates the concepts mentioned above, those being querystring grabs, programming logic, and bland code examples. We cover this concept for four popular languages, those being ASP, ColdFusion, JSP, and PHP. As each backend markup is very different, you’ll note that the code will look wildly dissimilar from one language to the next. When testing these applications out yourself, be very careful not to mix the code samples up, as a .cfm file wont run very well on a server expecting .asp extensions.


ColdFusion Example Part 1 -- GetDigits.cfm


<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.1">

<var name="CallerID" expr="session.callerid"/>

<form id="form_Main">
<field name="digit1" type="digits?length=2">
  <prompt bargein="false">Lets add two digit values together</prompt>
  <prompt>Please speak, or key in any two digit value</prompt>
<filled>
  <log expr="'*** FILLED ***'"/>
  <log expr="'*** digit1 =' + digit1 + '***'"/>
</filled>
</field>


<field name="digit2" type="digits?length=2">
  <prompt bargein="false">Great.</prompt>
  <prompt>Now speak, or key in the second two digit value</prompt>
  <filled>
  <log expr="'*** FILLED ***'"/>
  <log expr="'*** digit2 =' + digit2 + '***'"/>
  <submit next="AddDigits.cfm" method="get" namelist="digit1 digit2 CallerID"/>
</filled>
</field>

</form>

</vxml>



ColdFusion Example Part 2 -- AddDigits.cfm


<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.1">

<CFOUTPUT>

<!-- grab our querystring variables -->
<!-- assign them as new ColdFusion variables -->
<cfset MyCFVar1 ="#digit1#">
<cfset MyCFVar2 ="#digit2#">
<cfset MyCallerID ="#CallerID#">

<!-- perform arithmatic on the two querystring values -->
<!-- store the added total in a new ColdFusion variable -->
<cfset MyTotal = "#Evaluate(MyCFVar1 + MyCFVar2)#">


<form id="F1">
<block>
  <prompt>
    #MyCFVar1# plus #MyCFVar2# equals #MyTotal#.
      <break/>
  </prompt>

  <prompt>
    Just for kicks, let's count up to the total.
      <break/>

      <CFLOOP INDEX = "i" FROM ="1" TO ="#MyTotal#" STEP="1">
      #i# missisippi
        <break/>
      </CFLOOP>
  </prompt>

  <prompt>
    See ya later,
    <say-as interpret-as="telephone">#MyCallerID#</say-as>
  </prompt>


</block>
</form>

</CFOUTPUT>
</vxml>



ASP Example part 1 -- GetDigits.asp


<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.1">


<form id="form_Main">

<field name="digit1" type="digits?length=2">
  <prompt bargein="false">Lets add two digit values together</prompt>
  <prompt>Please speak, or key in any two digit value</prompt>
  <filled>
  <log expr="'*** FILLED ***'"/>
  <log expr="'*** digit1 =' + digit1 + '***'"/>
  </filled>
</field>

<field name="digit2" type="digits?length=2">
  <prompt bargein="false">Great.</prompt>
  <prompt>Now speak, or key in the second two digit value</prompt>
  <filled>
  <log expr="'*** FILLED ***'"/>
  <log expr="'*** digit2 =' + digit2 + '***'"/>
  <assign name="callerID" expr="'<%=Request("session.callerid")%>'"/>
  <submit next="AddDigits.asp" method="" namelist="digit1 digit2 callerID"/>
</filled>
</field>

</form>

</vxml>


ASP Example Part 2 -- AddDigits.asp


<%
Dim digit1, digit2, digitTotal, callerID

//get int versions of each digit
digit1 = CInt(Request("digit1"))
digit2 = CInt(Request("digit2"))

//get the sum of our digits
digitTotal = digit1 + digit2

//grab callerID from our submitted namelist
callerID = Request("callerID")
%>
<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.1">

<form id="form_main">
<block>
  <prompt>
    <%=digit1%> plus <%=digit2%> equals <%=digitTotal%>.
      <break/>
  </prompt>

  <prompt>
    Just for kicks, let's count up to the total.
      <break/>
<%
Dim i
For i = 1 To digitTotal
Response.Write( i & " mississippi " )
Next
%>
<break/>
  </prompt>

  <prompt>
    See ya later, <say-as interpret-as="telephone"><%=callerID%></say-as>.
  </prompt>

</block>
</form>

</vxml>



JSP Example Part 1- GetDigits.jsp


<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.1">


<form id="form_Main">

<field name="digit1" type="digits?length=2">
  <prompt bargein="false">Lets add two digit values together</prompt>
  <prompt>Please speak, or key in any two digit value</prompt>
  <filled>
  <log expr="'*** FILLED ***'"/>
  <log expr="'*** digit1 =' + digit1 + '***'"/>
  </filled>
</field>

<field name="digit2" type="digits?length=2">
  <prompt bargein="false">Great.</prompt>
  <prompt>Now speak, or key in the second two digit value</prompt>
  <filled>
  <log expr="'*** FILLED ***'"/>
  <log expr="'*** digit2 =' + digit2 + '***'"/>
  <assign name="MyCallerID" expr="'<%=request.getParameter("session.callerid")%>'"/>
  <submit next="AddDigits.jsp" namelist="digit1 digit2 MyCallerID"/>
  </filled>
</field>

</form>

</vxml>


JSP Example part 2 - AddDigits.jsp


<%
int digit1 = 0;
int digit2 = 0;

try {
//get int value for our digit1
digit1 = Integer.parseInt(request.getParameter("digit1"));
} catch (Exception e) {}

try {
//get int value for digit2
digit2 = Integer.parseInt(request.getParameter("digit2"));
} catch (Exception e) {}

//get the sum of our digits
int digitTotal = digit1 + digit2;

//grab callerID from our submitted namelist
String callerID = request.getParameter("MyCallerID");
%>
<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.1">

<form id="form_main">
<block>
  <prompt>
    <%=digit1%> plus <%=digit2%> equals <%=digitTotal%>.
      <break/>
  </prompt>

  <prompt>
    Just for kicks, let's count up to the total.
      <break/>
<%
for (int i = 0; i < digitTotal; ++i) {
out.println( (i+1) + " mississippi" );
}
%>
<break/>
  </prompt>

  <prompt>
    See ya later, <say-as interpret-as="telephone"><%=MyCallerID%></say-as>.
  </prompt>

</block>
</form>

</vxml>


PHP Example Part 1 - GetDigits.php


<?php
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
?>

<vxml version="2.1">

<form id="form_Main">

<var name="callerID" expr="session.callerid"/>

  <field name="digit1" type="digits?length=2">
    <prompt bargein="true">Lets add two digit values together</prompt>
    <prompt>Please speak, or key in any two digit value</prompt>
   
    <filled>
      <log expr="'**** FILLED ******'"/>
      <log expr="'**** digit1 =' + digit1 + ' ***'"/>
    </filled>
  </field>

<field name="digit2" type="digits?length=2">
  <prompt bargein="false">Great.</prompt>
  <prompt>Now speak, or key in the second two digit value</prompt>
  <filled>
    <log expr="' *** FILLED *********'"/>
    <log expr="' *** digit2 =' + digit2 + ' ***'"/>

    <submit next="AddDigits.php" method="get" namelist="digit1 digit2 callerID"/>
  </filled>
</field>

</form>
</vxml>



PHP Example Part 2 - AddDigits.php


<?php
//grab each digit and callerID from our submitted namelist
$digit1 = $_REQUEST["digit1"];
$digit2 = $_REQUEST["digit2"];
$callerID = $_REQUEST["callerID"];

header('Cache-Control: no-cache');

//get the sum of our digits
$digitTotal = $digit1 + $digit2;

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
?>
<vxml version="2.0">

<form id="form_main">
<block>
  <prompt>
    <?php echo $digit1?> plus <?php echo $digit2?> equals <?php echo $digitTotal?>.
    <break/>
  </prompt>

  <prompt>
    Just for kicks, let's count up to the total.
    <break/>
<?php
  for ($i=1; $i<=$digitTotal; $i++)
  {
    echo $i . " mississippi ";
  }
?>
    <break/>
  </prompt>

  <prompt>
    See ya later, <say-as interpret-as="telephone"><?php echo $callerID?></say-as>.
  </prompt>

</block>
</form>

</vxml>



And that's all there is to it; passing querystring variables and the like isn't that complicated, and is the first step towards *really* enhancing your applications. Note that as these concepts are not tied into a particular XML_based markup, you can take the basic code structure and tweak it for use in a CCXML, CallXML, or even HTML application that you might want to deploy.




  ANNOTATIONS: EXISTING POSTS
msyriani
5/3/2005 11:22 AM (EDT)
In the jsp example, variable MyCallerID is used and then variable callerid is used. This is causing an error. To fix this problem, replace CallerID with MyCallerID or replace MyCallerID with CallerID.

Also, method is set to empty string. replace with GET or POST
MattHenry
5/3/2005 1:05 PM (EDT)
Wwell, someone wipe the egg from my face.

=8^)

Seriously, thanks for catching those typos. I have them corrected in our internal doc build, and these changes will be reflected in the 'live' docs within the next week or two.

Regards,

~Matt
rajach
8/2/2005 12:03 PM (EDT)
Hi,

Can some one please tell me how to pass a parameter from JSP page to VXML.

Here in this example all I see is passing parameters from VXML to ASP page or JSP page. Is the other way possible? If so please email me the code at rsreddych@yahoo.com. Thanks in advance.

Rajach
MattHenry
8/2/2005 12:31 PM (EDT)
Hiya Raj,

To tweak our JSP example above, (AddDigits.jsp), we could do something like this:

<vxml version="2.1">
<var name="Num1" expr="<%=digit1%>"/>
<var name="Num2" expr="<%=digit2%>"/>

.....

<form id="form_main">
<block>
  <prompt>
    <value expr="Num1"/>
    plus
    <value expr="Num2"/>
    equals
    <%=digitTotal%>.
      <break/>
  </prompt>

....

Hope this helps to clarify,

~Matt


JimMurphy
8/2/2005 12:34 PM (EDT)
rajach,

There are a couple of ways to pass variables from JSP to VXML.

Since JSP or any server-side language is processed before the XML is rendered, you can simply plug variables into the XML.

Assuming that you have a variable called "sampleVar" in JSP:
------------------------
<form id="form_main">
<block>
  <prompt>
    The value of the test variable is <%=testVar%>
    <break/>
  </prompt>

...
------------------------

You'd essentially dynamically build the xml, plugging in the variables you need.

This assumes the JSP variables you wish to use are readily accesible when the vxml is rendered. If you want to take JSP variables that are not accessible at the time the vxml is rendered, you can either use a <subdialog> which references another dynamic document, or you can <goto> another dynamic page.

Does that answer your question?

Jim
rajach
8/2/2005 12:40 PM (EDT)
Thank a lot to both of you. Let me try and will get back to you if I have any problem. Thanks once again
rajach
9/9/2005 12:15 PM (EDT)
Hi,

I have a problem here. I have two Variables called "ANI" and "DNIS" in VXML. I am assigning values using the expressions

<var name="ANI" expr="session.connection.remote.uri"/>
<var name="DNIS" expr="session.connection.local.uri"/>

I want to check for the condition if ANI and DNIS contains a string "tel:", and then I want to strip those four characters from these two variables.

Can some one please tell me how can I check this condition in VXML.

Here is my code in JSP page which includes the vxml.

<?xml version="1.0"?>
<!DOCTYPE vxml PUBLIC "-//Nuance/DTD VoiceXML 2.0//EN" "http://voicexml.nuance.com/dtd/nuancevoicexml-2-0.dtd">
<vxml xmlns="http://www.w3.org/2001/vxml" xmlns:nuance="http://voicexml.nuance.com/dialog" version="2.0" >

<var name="TrunkNumber" expr="session.connection.ctiport"/>
<var name="ANI" expr="session.connection.remote.uri"/>
<var name="DNIS" expr="session.connection.local.uri"/>
<var name="callType"/>
<var name="memberID"/>
<var name="product" expr=""/>
<var name="agentskill" expr=""/>

<form id="collectRequest">

 
  <block>
  <audio src="prompts/welcome.wav"/>
  </block>
  <script>
  ANI = ANI.substring(4);
  DNIS = DNIS.substring(4); 
  </script>
 
 
  <block>
  <prompt>
  port number
  <value expr="TrunkNumber"/>
  </prompt>

  <prompt>
  dnis
  <audio src="pause:750"/>
  <prosody rate="slow">
  <say-as type="telephone">
  <value expr="DNIS"/>
  </say-as>
  </prosody>
  </prompt>

  <prompt>
  annie
  <audio src="pause:750"/>
  <say-as type="telephone">
  <value expr="ANI"/>
  </say-as>
  </prompt>
  </block>


  <block name="wrap_up">

  <submit next="<%=request.getContextPath()%>/routerequest" namelist="TrunkNumber ANI DNIS callType memberID"/>
  </block>
</form>
</vxml>

Thanks in advance. Your help is really appreicated.

Rajach
Michael.Book
9/9/2005 3:09 PM (EDT)
Hi Rajach,

Is there a particular reason you are grabbing the SIP ANI and/or DNIS addresses (i.e. 'session.connection.local.uri')?  If you just want the plain 10-digit telephone nunber, simply use 'session.callerid' and 'session.calledid'.  Will this give you the values your want?

On a side note...  You may want to take a peek at the documentation for the <say-as> element - 'http://docs.voxeo.com/voicexml/2.0/frame.jsp?page=say-as.htm'.  I don't think your <say-as> tags will work as-is.  Also note that the default TTS voice (Speechify) does not support SSML (i.e. <prosody>).  If you would like to use the <prosody> tag, you must use the Rhetorical TTS engine.  Check out 'http://docs.voxeo.com/voicexml/2.0/frame.jsp?page=appendixn.htm' for usable information.

I hope this helps...


Have Fun,

~ Michael
Voxeo Community Support
rajach
9/9/2005 3:44 PM (EDT)
Hi Michael,

Thanks for the reply. I tried your solution by setting

<var name="ANI" expr="session.callerid"/>
<var name="DNIS" expr="session.calledid"/>

This one not at all working.

The following code is working properly. My only doubt is whether
SIP ANI/DNIS addresses I am capturing through
<var name="ANI" expr="session.connection.remote.uri"/>
<var name="DNIS" expr="session.connection.local.uri"/>
will always have "tel:" prefixed to this address or not.

In following I am stripping first 4 characters of ANI and DNIS.
If "session.connection.remote.uri" and "session.connection.local.uri" does
not contain "tel:" then this code will not work since I am stripping first
4 characters in ANI and DNIS.

Can you please clarify me whether SIP ANI/DNIS does always contain "tel:".

As far as <say-as> tag in my code, it seems it working properly. But I will definitely go thorugh your suggestions.

Thanks for the help.

<?xml version="1.0"?>
<!DOCTYPE vxml PUBLIC "-//Nuance/DTD VoiceXML 2.0//EN" "http://voicexml.nuance.com/dtd/nuancevoicexml-2-0.dtd">
<vxml xmlns="http://www.w3.org/2001/vxml" xmlns:nuance="http://voicexml.nuance.com/dialog" version="2.0" >

<var name="TrunkNumber" expr="session.connection.ctiport"/>
<var name="ANI" expr="session.connection.remote.uri"/>
<var name="DNIS" expr="session.connection.local.uri"/>
<var name="callType"/>
<var name="memberID"/>
<var name="product" expr=""/>
<var name="agentskill" expr=""/>

<form id="collectRequest">

 
  <block>
  <audio src="prompts/welcome.wav"/>
  </block>
  <script>
  ANI = ANI.substring(4);
  DNIS = DNIS.substring(4); 
  </script>
 
 
  <block>
  <prompt>
  port number
  <value expr="TrunkNumber"/>
  </prompt>

  <prompt>
  dnis
  <audio src="pause:750"/>
  <prosody rate="slow">
  <say-as type="telephone">
  <value expr="DNIS"/>
  </say-as>
  </prosody>
  </prompt>

  <prompt>
  annie
  <audio src="pause:750"/>
  <say-as type="telephone">
  <value expr="ANI"/>
  </say-as>
  </prompt>
  </block>


  <block name="wrap_up">

  <submit next="<%=request.getContextPath()%>/routerequest" namelist="TrunkNumber ANI DNIS callType memberID"/>
  </block>
</form>
</vxml>

Thanks,
Rajach
Michael.Book
9/9/2005 6:26 PM (EDT)
Rajach,

I am not sure at all why the 'session.callerid' and 'session.calledid' is not working for you.  Try adding these lines to one of your forms, you will see in your logs that the straight, ten-digit ANI and DNIS are indeed included therein:
____________________

<block>
  <log expr="'*** ANI: ' + session.callerid + ' ***'"/>
  <log expr="'*** DNIS: ' + session.calledid + ' ***'"/>
</block>
____________________

On this note, try removing the DTD declaration at the top of your document and change your VXML version to 2.1, like so:
____________________

<?xml version="1.0"?>
<vxml version="2.1">
____________________

This may be what's causing problems for these session variables.

As far as your question though...  Yes, using the 'session.connection.local.uri' and 'session.connection.remote.uri' will always have a tel: or sip: syntax, as per the VoiceXML spec.

I hope this helps...


~ Michael
nachiket
9/14/2005 7:44 AM (EDT)
hi,

  Can anybody tell me how to assign a vxml variable to asp variable in the same document.
  Thanks in advance.

 
JimMurphy
9/14/2005 8:20 AM (EDT)
nachiket,

This is really an issue of scope. When a page loads, asp is processed by the webserver first, then the client side code is rendered (HTML, VXML, etc...). There are three ways you can go about assigning a vxml variable to an .asp variable.

1 -----------------
The obvious first way is to load a new document, passing your vxml variables on the querystring. You can do so using <submit>, with the namelist attribute.

eg.

<?xml version="1.0" encoding="UTF-8"?>

<vxml version = "2.1">

<form id="F1">
  <block>

    <var name="SomeCoolVar" expr="'SomeCoolValue'"/>

    <prompt>
      preparing to submit.
    </prompt>

    <submit next="MyDestinationPage.jsp"  method="get" namelist="SomeCoolVar"/>
  </block>
</form>

</vxml>


2 -----------------
The second way would be to use a <subdialog> to load a new dynamic page from your web server, passing vxml variables on the querystring (which can then become .asp variables). Additionally, when the <subdialog> exits, it can pass variables back to the vxml.

There are some samples of this here:
http://docs.voxeo.com/voicexml/2.0/subdialog.htm

3 -----------------
Along the same lines as #2 above, you can use the <data> element to submit vxml variables back your web server, where you can make them .asp variables. You can also get return variables back.

A good sample are the last two examples at:
http://docs.voxeo.com/voicexml/2.0/data.htm

I imagine you'll have more questions, and we're glad to help. If you do have additional questions, please open a support ticket inside your Evolution account.

Jim

http://docs.voxeo.com/voicexml/2.0/data.htm
Asier
11/3/2005 12:25 PM (EST)
Hi there,

I need help another time, i'm sorry but i need know receive variables from a file.php,
i would be very grateful, if you can tell me a link with information about this or you can put a smple code

Asier
MattHenry
11/3/2005 1:23 PM (EST)
Asier,

In short, this is done in the very same manner as we would do with HTML. However, let's take a closer look at this:

<form>
<block>
<?php
//define a PHP variable
$myVar1 = 'Asier';


?>
<!-- import it to VXML context -->
<var name="myXMLvar" expr="<?=$myVar1?>"/>
<log expr="'*** myXMLVar1 = ' + myXMLVar"/>
</block>
</form>


Hope this helps,

~Matt
steve.sax
2/1/2006 1:29 PM (EST)


Hi there,

I think there is a bit of confusion here; the documentation posts are really meant to add/request clarification of documented material, not for debugging assistance...you'd really be better off creating an account ticket for inquiries such as this.

However, to address your question, you would do well to read our tutorials on VXML, where voice/dtmf recognition is fully detailed and illustrated:

http://www.voicexmlguide.com/tutorialhome.htm

Steve Sax
pacific_is_me
2/8/2006 4:00 AM (EST)
Hi, sorry for my last fool question. But I have a right question here :). Please read my code below.

index.php:
<?php
include "./include/include.inc.php";

$check_session=session_is_registered("ivr_lang_id");
if($check_session)
{
session_unregister("ivr_lang_id");
}


$dir = "index.php";
$sql = "SELECT lang_id, ivr_message, ivr_wave, ivr_name FROM " . DB_PREFIX . "ivr_message WHERE stage_number=1 ORDER BY lang_id";
$res = $sqlpt->sql_query($sql,$db,$err);
if ( !$res )
{
exit();
}

$lang_id_array = array();
$ivr_message_array = array();
$ivr_wave_array = array();
$i=0;

while ( list($lang_id,$ivr_message,$ivr_wave) = $sqlpt->sql_next_row($res) )
{
$lang_id_array[$i] = $lang_id;
$ivr_wave_array[$i] = $ivr_wave;
$ivr_message_array[$i++] = $ivr_message;

}

$res = $sqlpt->sql_query($sql,$db,$err);
if ( !$res )
{
exit();
}
while ($row = $sqlpt->sql_fetch_array($res))
{
$ivr_name=$row["ivr_name"];
}

?>
<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/vxml
http://www.w3.org/TR/voicexml20/vxml.xsd">

<menu id="MainMenu">
<property name="inputmodes" value="dtmf"/>

<!--SPEAK GREETING AND LANGUAGE SELECTION-->
<prompt>
<?php
for ( $i=0; $i < count($lang_id_array); $i++ )
{
if($ivr_wave_array[$i]=="" && $ivr_message_array[$i]=="")
{
echo "ERROR";
}
if($ivr_wave_array[$i]!="" && $ivr_name==WELCOME)
{
echo "<audio src=\"". get_wave_url($ivr_wave_array[$i], WAVE_DIR, $dir ) ."\" />\n";
}

elseif($ivr_wave_array[$i]=="" && $ivr_name==WELCOME)
{
echo "$ivr_message_array[$i]\n";
}
}
?>
</prompt>
<!--#################END#################-->


<!--GENERATE MENU CHOICE TAGS FOR THE LANGUAGES-->
<?php
$sql = "SELECT ivr_id FROM " . DB_PREFIX . "languages ORDER BY ivr_id";
$res = $sqlpt->sql_query($sql,$db,$err);
if ( !$res )
{
exit();
}
$ivr_id_array = array();
$i = 0;
while ( list($ivr_id) = $sqlpt->sql_next_row($res) )
{
$ivr_id_array[$i++] = $ivr_id;
}

for ( $i = 0; $i < count($ivr_id_array); $i++ )
{
echo "<choice dtmf=\"" . $ivr_id_array[$i] . "\"" . " next=\"category_listing.php?ivr_lang_id=" . $ivr_id_array[$i] . "\"/>\n";
}
?>
<!--######################END####################-->


<!--IF THERE IS NO INPUT FROM CLIENT-->
<noinput>
        Sorry, I did not hear anything. Please choose your language.
        <reprompt/>
      </noinput>


<!--IF THE INPUT FROM CLIENT IS NOT MATCH-->
<nomatch>
        Sorry, I did not recognize your input. Please try again.
        <reprompt/>
      </nomatch>
</menu>
</vxml>

This file works well. But when I add more field in my URI in my menu like this:
<!--GENERATE MENU CHOICE TAGS FOR THE LANGUAGES-->
<?php
$sql = "SELECT ivr_id FROM " . DB_PREFIX . "languages ORDER BY ivr_id";
$res = $sqlpt->sql_query($sql,$db,$err);
if ( !$res )
{
exit();
}
$ivr_id_array = array();
$i = 0;
while ( list($ivr_id) = $sqlpt->sql_next_row($res) )
{
$ivr_id_array[$i++] = $ivr_id;
}

for ( $i = 0; $i < count($ivr_id_array); $i++ )
{
echo "<choice dtmf=\"" . $ivr_id_array[$i] . "\"" . " next=\"category_listing.php?ivr_lang_id=" . $ivr_id_array[$i] . "&is_cat=1&cat_id=0\"/>\n";
}
?>
<!--######################END####################-->

Then my application can not work. Can't I use the URI: category_listing.php?ivr_lang_id=" . $ivr_id_array[$i] . "&is_cat=1&cat_id=0 in the choose tag ?. Because in the next page (category_listing.php) I want to GET more than one variable. Please help me, thank you very much and sorry for my bad english.
pacific_is_me
2/8/2006 9:36 PM (EST)
Sorry because of making you misunderstood me :(. I just don't know how the server side script work with VoiceXML. Because if I use an URL like "www.my-domain.com/myfile.php?variable1=<argument1> in the "next element" of the choice tag then it work well, but when I use more than one variable like "www.my-domain.com/myfile.php?variable1=<argument1>&variable2=<argument2>", then VoiceXML can't recognize my URL. Is it some different from URL and URI ? please help me clarify this. Thanks.
mikethompson
2/8/2006 10:46 PM (EST)
Hello Duong,

It's not that VoiceXML is not recognizing your URL when you use "www.my-domain.com/myfile.php?variable1=<argument1>&variable2=<argument2>".  It's simply the & that is throwing a parse error.  You need to escape the & by using &amp; instead of plain old &.  I went ahead and cooked up a little sample script for you that I have tested to work locally.  You will notice it below, enjoy!

Regards,
Mike Thompson
Voxeo Extreme Support

============Menu with Choice One=============
<?xml version="1.0" encoding="UTF-8"?>

<vxml version = "2.1">

<menu id="M_1">
  <prompt> say choice one to test the choice element </prompt>
  <choice next="variable_puller.php?myvar1=foobarmania&amp;myvar2=deliciousness">
    choice one
  </choice>
</menu>

</vxml>

===========The PHP Variable Puller============

<?php
//grab each variable
$myvar1 = $_REQUEST["myvar1"];
$myvar2 = $_REQUEST["myvar2"];

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
?>

<vxml version="2.1">

<form id="form_main">
<block>
  <prompt>
    This is a test.  You should hear <?=$myvar1?>. Oh Snap.  Did you hear <?=$myvar1?>. 
    <break/> You should also hear <?=$myvar2?>.  As in holy goodness, this dish is beyond <?=$myvar2?>
  </prompt>
</block>
</form>

</vxml>
pacific_is_me
2/9/2006 4:24 AM (EST)
Oh, You're my angel :P, thank you very much. I'm appreciate your help. Thanks again.
kim69
5/4/2006 6:53 AM (EDT)
Hi I've got a problem where I have a mySQL database and a php web page and my voiceXML document posts variables that excutes a query where one then one result is found.

I can get it prompt the result of one them but how do I create it to prompt all of them? 

agonzalez
5/4/2006 11:38 AM (EDT)
well i know this is not a task but im pretty confused with the jsp explanation ill need 3 files to do this example work? first should be an "filename.xml" as this?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE vxml PUBLIC "VoiceXML DTD" "C:\eclipse\plugins\com.hp.ocmp.vxml.cde.vxmlbinplugin_3.1.0.0TP1\dtd\w3c\vxml.dtd">
<vxml version = "2.1">
<var name="id" expr="session.callerid"/>
<form>
  <block>
  <submit next="getdigits.jsp" namelist="id"  method = "get"/>
  </block>
</form>
</vxml>

getdigits.jsp should be as this?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE vxml PUBLIC "VoiceXML DTD" "C:\eclipse\plugins\com.hp.ocmp.vxml.cde.vxmlbinplugin_3.1.0.0TP1\dtd\w3c\vxml.dtd">
<vxml version = "2.1">


<form id="form_Main">

<field name="digit1" type="digits?length=2">
  <prompt bargein="false">Lets add two digit values together</prompt>
  <prompt>Please speak, or key in any two digit value</prompt>
  <filled>
  <log expr="'*** FILLED ***'"/>
  <log expr="'*** digit1 =' + digit1 + '***'"/>
  </filled>
</field>


<field name="digit2" type="digits?length=2">
  <prompt bargein="false">Great.</prompt>
  <prompt>Now speak, or key in the second two digit value</prompt>
  <filled>
  <log expr="'*** FILLED ***'"/>
  <log expr="'*** digit2 =' + digit2 + '***'"/>
  <assign name="MyCallerID" expr="'<%=request.getParameter("id")%>'"/>
  <submit next="AddDigits.jsp" namelist="digit1 digit2 MyCallerID"/>
  </filled>
</field>

</form>

</vxml>

and AddDigits.jsp should be as this?

<%
int digit1 = 0;
int digit2 = 0;

try {
//get int value for our digit1
digit1 = Integer.parseInt(request.getParameter("digit1"));
} catch (Exception e) {}

try {
//get int value for digit2
digit2 = Integer.parseInt(request.getParameter("digit2"));
} catch (Exception e) {}

//get the sum of our digits
int digitTotal = digit1 + digit2;

//grab callerID from our submitted namelist
String callerID = request.getParameter("MyCallerID");
%>
<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.1">

<form id="form_main">
<block>
  <prompt>
    <%=digit1%> plus <%=digit2%> equals <%=digitTotal%>.
      <break/>
  </prompt>

  <prompt>
    Just for kicks, let's count up to the total.
      <break/>
<%
for (int i = 0; i < digitTotal; ++i) {
out.println( (i+1) + " mississippi" );
}
%>
<break/>
  </prompt>

  <prompt>
    See ya later, <say-as interpret-as="telephone"><%=CallerID%></say-as>.
  </prompt>

</block>
</form>

</vxml>


should be very clarifier if you get a link to 4 files os source code for asp jsp coldfusion and php it would be magic if you do that thank you for the support
mikethompson
5/4/2006 11:41 AM (EDT)
Hey Kim,

I think that there might be some confusion that I should clear up regarding our abilities to offer support in this regard.

Generally speaking, we don't offer too much in the way of support and debugging of server-side code; this would ential an enormous resource drain on our part, and would likely slow our support responses to a grinding halt. As we are an IVR provider, all that we are concerned with is the XML output of your code, and how it interacts with our voice gateway:

http://docs.voxeo.com/voicexml/2.0/gettingsupport.htm

Database queries, stored procedures, and functions on the server side is simply something that we cannot offer support for; even assuming that we did offer support for this, there would be no way that we could offer an accurate response to developer inquiries, as we don't have the database mappings, and have no way of recreating the code locally to test.

As such, I think that your best course of action would be to search for assiatnce on this matter by visiting a PHP-specific site, (such as http://www.php.net), to see if you can find advice and support in this inquiry.

Hope this helps,
Mike Thompson
Voxeo Extreme Support
Michael.Book
5/4/2006 12:56 PM (EDT)
kim69,

Mike is right...  Although we welcome our developers to discuss server-side topics as they related to CCXML/VoiceXML, PHP.net and/or other PHP user forums would really be your best bet for timely feedback on PHP specific questions.  :-)

But...

What it sounds like you are trying to do is simply loop through multiple returns from your DB query..?

You are using mysql_fetch_assoc() which is going to build an associative array containing each returned row.  So, you can simply loop through the values, like so:

---------------
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
  <form>
    <block>

<?php

while ($time = mysql_fetch_assoc($row_time)) {
echo "<prompt> time is" . $time . "</prompt>";
}

?>

    </block> 
  </form>
<vxml/>
---------------

Have Fun,

~ Michael
Michael.Book
5/4/2006 1:06 PM (EDT)
agonzalez,

As the example shows, you only need two files to complete the operation...

First, a client-side, VoiceXML document containing a field that gathers digits.  Then you <submit> to a second, server-side, JSP document that grabs the needed parameters from the query-string, performs server-side logic, and dynamically outputs/returns VoiceXML.  Viola!

If I am misunderstanding your request, please do clarify.  We will gladly assist...


Cheers,

~ Michael
agonzalez
5/5/2006 5:26 AM (EDT)
well as i was folowin' your example there were two diferent jsp files and in the first one in that you get the caller id from the querystring so that is cause another file is qettin' the session.callerid value and sending in a form with the get method so theres the third file well i haver fortunately got this example rolling as i posted in the last message so thanks for the support youre doing kindly well first file the one where you map you app has to be an xml? or could it be direclty a jsp extension with xml embedded
agonzalez
5/5/2006 6:22 AM (EDT)
sorry for the disturb and my low level skills i checked it does'nt matter the extension only the code inside the file
ryokan01
9/28/2006 6:11 PM (EDT)
Yes...yet another programming newbie here, so please forgive my ignorance (or at least don't laugh about it around the office).

Unless I am reading something wrong here, on the Voxeo development system it is NOT possible for me to pass a variable in a URL string and use it in my VXML document, correct?

I am trying to pass through the name of an XML file ("orderid, in my case) to use for the application argument, but it seems as though I would need server-side scripting in order to do this.

http://session.voxeo.net/VoiceXML.start?numbertodial=1234567890&tokenid=(tokenIDhere)&callerid=9876543210&orderid=1234

Then, in my VXML document I would have something like:

<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1" application=$orderid".xml">

This ain't gonna work, is it?
MattHenry
9/28/2006 8:29 PM (EDT)


Hi there,

Most VXML platforms do not expose a way to capture querystring parameters without using a server-side markup, this is correct. In order to do anything of this nature, you will indeed need to code a "catcher" page using ASP/JSP/etc.

Cheers,

~Matthew Henry
hirennagar
11/30/2006 2:23 AM (EST)
hi..guys need your help new to VXML....

Thanks for such a nice way to enable sharing of information.

I want to be able to call an ASP page from .vxml file. I know howw to pass variables from .vxml to .asp.

but I want to process the passed variables in the called .asp file and want to get them back in the .vxml file to present them to the user.

I have gone through the examples on http://www.voicexmlguide.com/frame.jsp?page=qs_vars.htm

there are two files with asp extensions:

GetDigits.asp
AddDigits.asp

The GetDigits.asp file calls Adddigits.asp and then finally adddigits.asp file presents the data to user through voice.

Both the asp files have .vxml embedded in them.

"my question is that i am supossed to run these .asp files over asp server, will asp server support vxml and present the content through voice to the user ? "

I am very much thankful to you for maintaining such a good place where people can share knowladge.

jbassett
11/30/2006 4:05 AM (EST)
Hello,

Thanks for all the positive feedback.

To address your question.

If you are using our free hosted environment for testing. You could host the embedded ASP files on your server, and then just Map the application URL(via our "Application Manager" tool) to that file. Our XML browsers will process all of the XML. Keep in mind that this is only because our free hosting environment does not support anything other than xXML, .wav, and .grammar extensions. Our production hosting can be modified to fit your needs and you could be given ASP support without having to host the files yourself.

Second, you could always just download Prophecy and do all of the XML and ASP locally.

I hope this answers your question.

Thanks
Jesse Bassett
Voxeo Support
sarika
3/2/2007 9:17 AM (EST)
i am creating a voice survey application. For this application i need to store a vxml variable in a database. Am using mysql database here and embeding vxml code in php.
can some one help me out here to store data in database from the vxml document...
mikethompson
3/2/2007 5:54 PM (EST)
Hello Sarika,

Server-side troubleshooting is a bit beyond our scope of support.  However, we would be more than happy to help you out with the VoiceXML portion of your application.  It's actually quite easy to submit your VoiceXML variables off to a database, once your server-side page is ready to accept them.  Here's a quick and dirty example on how to do that:


<?xml version="1.0" encoding="UTF-8"?>

<vxml version = "2.1">

<meta name="author" content="Matthew Henry"/>
<meta name="copyright" content="2005 voxeo corporation"/>
<meta name="maintainer" content="YOUR_EMAIL@HERE.COM"/>

<form id="F1">
 
  <block>
    <var name="SomeCoolVar" expr="'SomeCoolMoeDeeValue'"/>

    <submit next="MyDestinationPage.jsp" namelist="SomeCoolVar" method="post"/>
  </block>

</form>

</vxml>

You can see, the <submit> element is what you're looking for, where the next="" attribute should be the fully qualified URL of your server-side script.

Hope this helps,
Mike Thompson
Voxeo Corporation
danielvinson
3/19/2007 6:03 PM (EDT)
Hi

Could I use the 'submit' command to submit variables to a static php website such as www.txtlocal.com/sendsmspost.php for SMS purposes ? or do you need to submit them via an ASP, PHP, CF etc website. Thanks

Regards

Daniel
VoxeoTony
3/19/2007 8:03 PM (EDT)
Hello Daniel,

For your question on if you can send variables to a static page using submit.  You can send the variables to a static page or a server-side page if you choose.  However, once the variable is sent the page that receives it will need to process it accordingly.  As mentioned in the documentation, the ability to send delimited variables via namelist is a perk of using submit.

In your posting you mention a site www.txtlocal.com/sendsmspost.php, and this is not a site that we are familiar with or support.  Our recommendation would be to try out your theory and let us know if that site does support the ability to handle the variables being sent to it for your SMS testing.

I'm sure the VoiceXML forum would gain from your feedback.

Tony~
kave
8/22/2007 1:24 AM (EDT)
Hi,

I didn't get II parts of this, on JSP files, i have seen when the caller say or key the first and the second numbers you have specifed that it would be exactly 2 digits at least (type="digits?length=2") ? what would it happend if the caller key just one (digit per var)? also when i submit these variables to another JSP, automatically the server would response with this one (AddDigits.jsp)?

thanks in avance, waiting for any answer

Kave'
jbassett
8/22/2007 5:17 AM (EDT)
Hello,

I will try and address your question as best I can. If you only keyed in one of the two digits the field is expecting, it will throw a nomatch event because the field is explicitly expecting two entries. If you did not enter anything at all it would throw a noinput and re prompt you.

Let me know if you need any more info about this.

Thanks,
Jesse Bassett
Voxeo Support
kave
8/22/2007 12:00 PM (EDT)
Hi Jbassett, thanks for help me, maybe i wasn't clear about my question, ok... i know the field is expecting for 2 digits = digit1, i suppose that it is expecting for example on the field number one (digit1) = two chars, for example 3 and then 4 , digit1 = 34 isn't? also i'm still waiting for knowing about when you submit in the first JSP file you directly go through the second one? or the server sends the second JSP when the caller has said the digit1 and digit2 after submitting these vars?

thanks in avance
have a nice day

kave
mikethompson
8/22/2007 2:32 PM (EDT)
Kave,

Yes, your understanding is correct regarding the digit input. 

As for your second question, I must apologize, but I don't quite understand what you're asking.

Regardless, I will explain the JSP process for you:

1) Part 1 collects the two digits and callerID then sends them off to the second JSP page as parameters in the namelist.

2) Part 2 grabs the parameters from the resulting querystring and assigns them to JSP variables.

3)  Math logic is performed to get the total of the digits and then the values are echoed in the VoiceXML

Let me know if you have additional questions surrounding this, as I'm glad to help.

Best,
Mike Thompson
Voxeo Corporation
kave
8/22/2007 5:25 PM (EDT)
Hi Matt,

Now it's totally clear for me, i've understood, thanks for helping me out about these doubts, i'm developing a game app. by phone with JSP and VXML, and I thought that this tech (VXML) was implemented away from JSPs, like they should be separated , and now, i've seen that VXML is embedded in JSP pages.

Jesse and you have been so kind to me, thanks a lot and any question about i'll let you know.

Have a nice day and best regards

Kave


bradley.holt
11/5/2007 4:53 PM (EST)
Perhaps you are trying to simplify things for the reader, but in the article you say, "The primary purpose of using POST is to hide our sensitive querystring data from prying eyes, and nosy neighbors." This is not the primary purpose of using POST. There is a more important difference between GET and POST. According to the HTTP specifications, GET requests should be idempotent. If you're simply reading a resource, use GET. If you're request will write data, make a change, or have some sort "side-effect" (that the user is requesting) then use POST. See <http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html> for more information.
koti
11/8/2007 7:00 PM (EST)
Hi,

Iam developing IVR application in java, Spring Framework and TOMCAT server ..My basic step will invoke a jsp at http://67.12.10.20:8080/IVR/welcome.jsp, this will redirect to a Action Controller and the controller will forward the call to welcome.vxml file at /WEB-INF/welcome.vxml. I want the next to call  getCallTreeFactory.jsp from welcome.vxml which is residing next to welcome.vxml. But it is searching out side of WEB-INF. How can i use the getCallTreeFactory.jsp from inside of WEB-INF.

And how can i perform the action to invoke a Controller again from the getCallTreeFactory.jsp

Please give me a sample exmaple on this.

Thanks in advance
koti
MattHenry
11/9/2007 2:14 PM (EST)


Hi there Koti,


I'm really sorry, but this question seems to be specific to the JSP markup, which is somewhat outside the bounds of what Voxeo offers direct application support for: the support team here is available to help address any vxml/cxml/ccxml inquiries that you might have, but for JSP/PHP/ASP sort of questions, these are really better suited to websites and forums dedicated to supporting these server-side markups.

Best of luck,

~Matthew Henry
mohamine
12/5/2007 10:24 AM (EST)
hi
how to use the functions of php mysq_connect and mysql_select_db..... n the program voicexml.
is what it necessite a configuration of prophecy or the call of a certain file
thank you.
mikethompson
12/5/2007 10:36 AM (EST)
Hello,

I think that there might be some confusion that I should clear up regarding our abilities to offer support in this regard.

Generally speaking, we don't offer too much in the way of support and debugging of server-side code; this would entail an enormous resource drain on our part, and would likely slow our support responses to a grinding halt. As we are an IVR provider, all that we are concerned with is the XML output of your code, and how it interacts with our voice gateway:

http://docs.voxeo.com/voicexml/2.0/gettingsupport.htm

Database queries, stored procedures, and functions on the server side is simply something that we cannot offer support for; even assuming that we did offer support for this, there would be no way that we could offer an accurate response to developer inquiries, as we don't have the database mappings, and have no way of recreating the code locally to test.  The above examples were put in place to give our readers a basic understanding of how you can nest server-side scripting within VoiceXML.  Beyond that, the subject matter gets thick quite quickly.

As such, I think that your best course of action would be to search for assistance on this matter by visiting a PHP/SQL specific site (such as php.net), to see if you can find advice and support in this inquiry.

Best,
Mike Thompson
Voxeo Corporation
winravi
2/28/2008 11:30 AM (EST)
Hi Sir,
From the above sample; GetDigits.jsp and AddDigits.jsp ; Since the Voxeo hosting Server will not support any Server-Side scripting like a JSP; how to test the above sample; Assuming I have a tomcat 6.x environment and using your Voxeo Hosting Services; or Netbeans GlassFish Server 6.x: Where/How do I place the files in Voxeo Application Manager generate to Application calling number
Thanks in advance for your knowledge sharing
mikethompson
2/28/2008 3:25 PM (EST)
Hello,

Our voice browsers work just like a web-browser, in the sense it simply fetches URLs, and processes the output.  This being said, if you have a web-server on your end which supports PHP, simply host your application document on there, then place its URL in your Application Manager as the Start URL for your application mapping.  For more information, check out our Quick start guide:

https://evolution.voxeo.com/docs/quickStart.jsp

Hope this helps,
Mike Thompson
Voxeo Corporation
winravi
2/29/2008 7:14 AM (EST)
Thanks Mike; got this sample done - I need more help - will come back soon, Ravi
azeta_ambrose
3/2/2008 6:04 PM (EST)
Thanks Voxeo,

I was able to send data through voice/phone to mysql database using php code. The tutorial was of great help.

But i have problems retrieving data from the same mysql using php code to my phone.

Maybe someone can volunteer to assist.

Ambrose
mikethompson
3/2/2008 6:34 PM (EST)
Hello,

I think that there might be some confusion that I should clear up regarding our abilities to offer support in this regard.

Generally speaking, we don't offer too much in the way of support and debugging of server-side code; this would entail an enormous resource drain on our part, and would likely slow our support responses to a grinding halt. As we are an IVR provider, all that we are concerned with is the XML output of your code, and how it interacts with our voice gateway:

http://docs.voxeo.com/voicexml/2.0/gettingsupport.htm

Database queries, stored procedures, and functions on the server side is simply something that we cannot offer support for; even assuming that we did offer support for this, there would be no way that we could offer an accurate response to developer inquiries, as we don't have the database mappings, and have no way of recreating the code locally to test.

As such, I think that your best course of action would be to search for assiatnce on this matter by visiting a PHP-specific site, (such as http://www.php.net), to see if you can find advice and support in this inquiry.

Best,
Mike Thompson
Voxeo Corporation
azeta_ambrose
3/12/2008 10:50 PM (EDT)
Hello voxeo.

Thanks for all the support. I just like to know if your platform support database queries?
I have been having some problems for over 2 weeks trying to post or retrieve from mysql database using php. I have tried submit and data/cdata statement but i keep getting either "this application have an internal error or error in the gateway software"
Here is my vxml and php code. Normally, I write php/mysql applications for other projects, but I can simplying integrate it with vxml using this platform. I have already upload my php files and mysql database to a web server, which my submit/data statement put to.
Please a member of the forum may offer to assist me, probably with some sample code. Thanks to you all in advance.
vmlx code
=========
<vxml version = "2.1">

  <meta name="maintainer" content="YOUREMAILADDRESS@HERE.com"/>

  <form id="MainMenu">
<field name="uname">
    <prompt>
      user name.
    </prompt>
      <grammar type="text/gsl">
  [cartman phillip] 
</grammar>

    <noinput>
    no user name.
        <reprompt/>
    </noinput>

    <nomatch>
    name not recognized. 
      <reprompt/>
    </nomatch>

</field>
      <field name="pword">
    <prompt>
      password.
    </prompt>
      <grammar type="text/gsl">
  [big hat] 
</grammar>
<noinput>
      no password.
        <reprompt/>
      </noinput>
<nomatch>
        password not recognized. 
      <reprompt/>
      </nomatch>

  </field>
<filled>
  <submit next="http://www.autosp.byethost13.com/am6.php" method="get" namelist = "=uname pword"/>
</filled>


  </form>
</vxml>


php coe
=======

<?php
include "connect.php";
$myvar1 = $_REQUEST["uname"];
$myvar2 = $_REQUEST["pword"];

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";


$query = "insert into paper1 set
userid = \"$myvar1\",
passwd = \"$myvar2\"";


$result = mysql_query($query) or die('<br><br><center> <?=OUT?> </center>');

?>

Thanks.

Ambrose
VoxeoDustin
3/12/2008 11:19 PM (EDT)
Hey Ambrose,

This is certainly possible, as pretty much anything you can do with server side is as long as what is returned is valid. In the case of <submit>, you will need to return a valid VoiceXML document, as the browser will transition to the document and attempt to parse it. For <data>, it's more of a 'fire and forget' function, but will expect the return to be valid XML data. I recommend sticking with submit for this case, as accessing the data will likely be easier.

Hope this helps,
Dustin
hsc
3/28/2008 11:49 AM (EDT)
hi, sorry if this is a really silly question.

Im trying to access a sql database via jsp in a vxml document. how exactly do i run the jsp code to parse the information and does anyone have a clue what the jsp code would be?

ricarjos
4/15/2008 4:30 PM (EDT)
Hi,

mmm.php
<?php
$db = mysql_connect("localhost", "xxxxx", "xxxxxx");
mysql_select_db("xxxx",$db);
$result = mysql_query("SELECT * FROM prop ",$db);
$myrow = mysql_fetch_array($result);
$Nintentos = $myrow['Nintentos'];
mysql_close($db);
?>

I've  this code in my server (usuarios.lycos.es) i need send the variable $Nintentos to an application in vxml, I need this variable to decide how action do it. For example, if $Nintentos = 1 the application play MySoundFile1 with <audio src="MySoundFile1.wav"/>, but if $Nintentos = 2 the application play MySoundFile2 with <audio src="MySoundFile2.wav"/>.

Please help me is very necesary for i finish my application, it's urgent.

Ricardo

VoxeoDustin
4/15/2008 6:17 PM (EDT)
Hey Ricardo,

This is pretty simple, as integrating server side into your voice apps is simple as long as the output is valid VoiceXML. Using the code above, you could simply do something like:

<audio src="MySoundFile<%php echo $Nintento%>.wav"/>

Cheers,
Dustin
ricarjos
4/15/2008 7:09 PM (EDT)
Hi, thanks for your quickly answer, but I believe that i expresse bad my example, the problem is that them name of the archives to reproduce is going to be very different, nonsingle will change the number, and in addition I don't know if is my bad English, but I'm not understood in that place I must put the audio element, this goes in the file .xml or in file .php?

Thanks for your help.

Ricardo
VoxeoDustin
4/15/2008 7:29 PM (EDT)
Hey Ricardo,

You'll want to fetch your PHP document via the <submit> attribute. This will transition control to this document. As long as the output of the document is valid VoiceXML, any PHP will be processed and the VXML browser will execute the VXML content. By doing this, we can basically use PHP to echo any strings we want back to the VXML that will be output when this document is fetched. Below is basic sample based on the code you provided.

<!-- Initial VXML document performs a <submit> and fetches this PHP doc -->
<?php
$db = mysql_connect("localhost", "xxxxx", "xxxxxx");
mysql_select_db("xxxx",$db);
$result = mysql_query("SELECT * FROM prop ",$db);
$myrow = mysql_fetch_array($result);
$Nintentos = $myrow['Nintentos'];
mysql_close($db);
?><?xml version="1.0"?>
<vxml version="2.1">

  <form>
    <block>
      <audio src="<%php echo $Nintentos%>"/>
    </block>
  </form>
</vxml>

http://docs.voxeo.com/voicexml/2.0/intro_serverside.htm

Cheers,
Dustin

login

  Intro to Server Side  |  TOC  |  tutorial Dynamic Grammars  

© 2003-2008 Voxeo Corporation  |  Voxeo IVR  |  VoiceXML & CCXML IVR Developer Site