We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

Passing a variable from one xml file to another - (Scope)

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

ucsur
Posts: 12
Joined: Wed Feb 14, 2007 11:00 am
Location: University of Pittsburgh
Contact:

Passing a variable from one xml file to another - (Scope)

Post by ucsur »

Support,

How do I set a Global variable in my "application root" xml file and then reference it in my "leaf" xml file?

1. In the application root I set a global var called "vSubjID" and assign it "0"
2. In the application root I change "vSubjID" inside a form construct
3. I would like to reference this variable in a "leaf" xml file, but it keeps reporting the initial value of "vSubjID?"
4. Clearly I am not properly "assigning" the application root "vSubjID" var.

=============================================

<!-- test3.xml (Application Root) -->
<?xml version="1.0"?>
<vxml version="2.0">

<property name="inputmodes" value="dtmf" />

<var name="vSubjID" expr="0"/>

<!-- Enter Subject ID -->
<form id="frmSubjID">
<block>
<assign name="vSubjID" expr="1289"/>
The Subject ID is now set to <value expr="vSubjID"/>.
<goto next="test4.xml#frmQ001" maxage="0" maxstale="0"/>
</block>
</form>
</vxml>


<!-- test4.xml (Leaf) -->
<?xml version="1.0"?>
<vxml version="2.0" application="test3.xml">

<form id="frmQ001">
<block>
<prompt>
The Subject ID from test three dot ex em el is <value expr="application.vSubjID"/>
</prompt>
</block>
</form>
</vxml>

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Passing variable from one xml file to another in IVR system

Post by support »

Hi,

Unfortunately, we don't maintain the scope of root document variables for this type of root-to-leaf transition, even though the VoiceXML spec says we should. We expect to address in a future revision of the IVR platform.

In the meantime, you can work around this by creating a root document that simply holds variables and does contain any navigable code (forms, menus, etc.).

Regards,
Plum Support
Last edited by support on Mon Jan 11, 2010 2:27 pm, edited 2 times in total.

pkeogan
Posts: 4
Joined: Thu Jun 26, 2008 4:07 pm

assigning a global variable

Post by pkeogan »

We seem to be having an issue with your VXML interrupter assigning a global variable. We’ve run this file on three other platforms without any issues.

Has this been corrected yet? Our root document doesn’t contain any navigable code.

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR code change for assigning a global variable

Post by support »

Hi,

This is a known issue in the current IVR platform.

From the IVR code above, the root document, test3.xml, would have to be edited to this IVR code:

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0">

<property name="inputmodes" value="dtmf" />
<var name="vSubjID" expr="0"/>
<!-- Enter Subject ID -->
<form id="frmSubjID">
<block>
<assign name="application.vSubjID" expr="1289"/>
The Subject ID is now set to <value expr="application.vSubjID"/>.
<goto next="test4.xml#frmQ001" maxage="0" maxstale="0"/>
</block>
</form>
</vxml>
So, if you are referring to your global variable as "application.[variablename]", you will have to make an edit to your root document, as shown in the IVR example above.

Regards,
Plum Support
Last edited by support on Thu Feb 18, 2010 3:42 pm, edited 3 times in total.

Chris
Posts: 64
Joined: Wed Jul 23, 2008 12:50 pm

Doesn't work past the first document

Post by Chris »

I followed this code to the letter, and it works well.
Trouble is, it ONLY plays <value expr="application.ProgramName"/> in the FIRST.vxml document following the ROOT.php

The same <value expr="application.ProgramName"/> does not work in the SECOND.vxml or any SUBSEQUENT.vxml documents.

Even though all documents are indeed set to the same root.
<vxml version="2.0" application="ROOT.php">

Also, I've noticed a contradiction in the instructions from Support,
and I don't know how to follow confilcting advice.
Posted: Wed Feb 21, 2007 4:29 pm
<I>"... a root document that simply holds variables and does contain any navigable code (forms, menus, etc.). "</I>

When Support said "<B>and does contain any navigable code (forms,</B>",
did Support actually mean to say "<B>does not contain</B>"?
Or was that just a strange sentence, since the very next posting included a <B>form</B>?

Posted: Fri Jun 27, 2008 4:42 pm
"<?xml version="1.0"?>
<vxml version="2.0">

<property name="inputmodes" value="dtmf" />
<var name="vSubjID" expr="0"/>
<!-- Enter Subject ID -->
<B><form id="frmSubjID"> </B>
<block>
<assign name="application.vSubjID" expr="1289"/>
The Subject ID is now set to <value expr="application.vSubjID"/>.
<goto next="test4.xml#frmQ001" maxage="0" maxstale="0"/>
</block>
<B></form></B>
</vxml>"


So, my question is, how can we make this thing work in the SECOND.vxml and all other SUBSEQUENT.vxml documents?
Thanks,
Chris

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR code change for assigning a global variable

Post by support »

Hi Chris,

We've just tried the following IVR code and have gotten the variable to carry over past the first leaf document:

test1.xml

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0">
	
	<property name="inputmodes" value="dtmf" />
	<var name="vSubjID" expr="0"/>
	<!-- Enter Subject ID -->
	<form id="frmSubjID">
		<block>
			<assign name="application.vSubjID" expr="1289"/>
			The Subject ID is now set to <value expr="application.vSubjID"/>.
			<goto next="test2.xml#frmQ001" maxage="0" maxstale="0"/>
		</block>
	</form>
</vxml>
test2.xml

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0" application="test1.xml">

<form id="frmQ001">
<block>
<prompt>
The Subject ID from test one dot ex em el is <value expr="application.vSubjID"/>.
</prompt>
<goto next="test3.xml#frmQ002" maxage="0" maxstale="0"/>
</block>
</form>
</vxml>
test3.xml

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0" application="test1.xml">

<form id="frmQ002">
<block>
<prompt>
The Subject ID from test two dot ex em el is <value expr="application.vSubjID"/>.
</prompt>
</block>
</form>
</vxml>
If you are having problems getting the variable to carry over to subsequent leaf documents, please post your IVR code here so we can help you take a look at it.

Also, disregard the post from Feb 21, 2007 as this was an older post.

Regards,
Plum Support
Last edited by support on Thu Feb 18, 2010 3:43 pm, edited 3 times in total.

Chris
Posts: 64
Joined: Wed Jul 23, 2008 12:50 pm

Post by Chris »

Okay,
For some strange reason it seems to be working into the third leaf.
But something new is happening. It's inconsistent!

When I call in it does play the FIRST.vxml and then plays the SECOND.vxml

So all is correct.

But the next time I call in, it skips the FIRST.vxml and goes to the middle of SECOND.vxml at the point of <menu id="EnrollmentUpdateSwitch">.
It skips <form id="switch">
<block>
Welcome!
<goto next="#EnrollmentUpdateSwitch"/>
</block>
</form>

The next time I call in it skips to SECOND.vxml and plays the document properly.

Another call returns all the documents correctly, in their entirety!

I am always calling in to ROOT.php

How could any of this be happening???

The code follows.

ROOT.vxml

Code: Select all

<?php

$dbhost='hhhhhhhhhhhhhhh';
$dbusername='uuuuuuuuuu';
$dbuserpass='ppppppppppp';
$dbname='nnnnnnnnnnnnnn';
$dbTable='web_enrollment';

$conn = mysql_connect($dbhost, $dbusername, $dbuserpass) or die('Error connecting to mysql'.mysql_error());
mysql_select_db($dbname);

	$Program_query="SELECT program_name FROM web_enrollment WHERE  trx_agent='".MASTER."' ";
	$Program_result=mysql_query($Program_query)or die(mysql_error());
	$Program_row=mysql_fetch_array($Program_result)or die(mysql_error());

	$Product_query="SELECT product_id FROM web_enrollment WHERE  trx_agent='".MASTER."' ";
	$Product_result=mysql_query($Product_query)or die(mysql_error());
	$Product_row=mysql_fetch_array($Product_result)or die(mysql_error());

mysql_close($conn);
?>
<vxml version="2.0">
<form id="SetGlobalVariables">
<block>
<var name="program_name" expr=" '<? echo ($Program_row[0]) ?>' " />
<assign name="application.ProgramName" expr="program_name"/>

<var name="product_id" expr=" '<? echo ($Product_row[0]) ?>' " />
<assign name="application.ProductName" expr="product_id"/>

<goto next="FIRST.vxml"/>
</block>
</form>
</vxml>
FIRST.vxml

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0" application="ROOT.php">


<form>
<block>
<prompt bargein="false">Hello! Thanks for calling <value expr="application.ProgramName"/> . 
This is a free service for people who bought <value expr="application.ProductName"/> , 
and requires a touch tone phone. 

</prompt>
<goto next="SECOND.vxml"/>

</block>
</form>
</vxml>
SECOND.vxml

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0" application="ROOT.php">

  <form id="switch">
     <block>
        Welcome!
        <goto next="#EnrollmentUpdateSwitch"/>
     </block>
  </form>

  <menu id="EnrollmentUpdateSwitch">
    <prompt>
If you are calling to enroll for the first time, 
press 1, or just say Enroll. 
If you have already enrolled in the program, and want to make changes to your <value expr="application.ProgramName"/> account,
press 2, or say Make Changes.  
    </prompt>

 <choice dtmf="1" next="e03_ContinueEnrollmentMenu.php" accept="approximate">enroll</choice> 

 <choice dtmf="2" next="#PasswordRequest" accept="approximate">make changes</choice>

   <catch event="nomatch noinput help">
      <reprompt />
    </catch>
  </menu>


<form id="PasswordRequest">
    <block>
    <goto next="../UPDATE/u01_PasswordRequest.vxml"/>
    </block>
  </form>

</vxml>
[/code]
Thanks,
Chris

Chris
Posts: 64
Joined: Wed Jul 23, 2008 12:50 pm

ROOT.php

Post by Chris »

I made an error in my last post.
The name of the ROOT document is always ROOT.php
In my last post I named it ROOT.vxml incorrectly.
Sorry for any confusion.
Thanks,
Chris

Chris
Posts: 64
Joined: Wed Jul 23, 2008 12:50 pm

Post by Chris »

Wrong again.
Give it a little time, then call back and it no longer passes the variables to SECOND.vxml
So it not only skips FIRST.vxml, but also skips
<form id="switch">
<block>
Welcome!
<goto next="#EnrollmentUpdateSwitch"/>
</block>
</form>

And in the end, does not return the variable in SECOND.vxml
<value expr="application.ProgramName"/>

One additional suggestion about posting in this forum.
It would be helpful if end-users could edit their posts after submitting them.
Thanks,
Chris

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Put IVR code between prompt tags and make it nonbargeable

Post by support »

Hi Chris,

Do you have an IVR call log that demonstrates this behavior? It seems a bit strange that FIRST.vxml is being skipped since you made it nonbargeable.

As for this block of IVR code being skipped:

Code: Select all

<form id="switch">
<block>
Welcome!
<goto next="#EnrollmentUpdateSwitch"/>
</block>
</form> 
You could try placing it in between the IVR tags, <prompt>, and make it nonbargeable:

Code: Select all

<form id="switch">
<block>
<prompt bargein="false">
Welcome!
</prompt>
<goto next="#EnrollmentUpdateSwitch"/>
</block>
</form> 
Regards,
Plum Support
Last edited by support on Wed Feb 24, 2010 3:24 pm, edited 5 times in total.

Chris
Posts: 64
Joined: Wed Jul 23, 2008 12:50 pm

Post by Chris »

Yes I have the error log file.
But, I can not figure out what the log file is telling me regarding the skipping of FIRST.vxml.
Maybe you can.
This is the file for today:

error no_ani 4 [07/Aug/2008:10:47:01 -0400] 5734 000000;004;1218118917 HTTP/1.1 404 Not Found - http://www.PHARMACALL.mobi/VXML/INBOUND/ROOT.php
error no_ani 4 [07/Aug/2008:10:47:01 -0400] 5734 000000;004;1218118917 DocumentParser::FetchBuffer - could not open URL: http://www.PHARMACALL.mobi/VXML/INBOUND/ROOT.php
error no_ani 4 [07/Aug/2008:10:47:01 -0400] 5734 000000;004;1218118917 DocumentParser::FetchDocument - exiting with error result 2
error no_ani 4 [07/Aug/2008:10:47:01 -0400] 5734 000000;004;1218118917 errno: 203 uri http://www.PHARMACALL.mobi/VXML/INBOUND/ROOT.php
error no_ani 11 [07/Aug/2008:11:06:28 -0400] 5734 000000;011;1218120455 DocumentParser::FetchDocument - Parse error in file "http://www.PHARMACALL.mobi/VXML/INBOUND/ROOT.php", line 11, column 15 - Expected end of tag 'block'
error no_ani 11 [07/Aug/2008:11:06:28 -0400] 5734 000000;011;1218120455 errno: 205 uri http://www.PHARMACALL.mobi/VXML/INBOUND/ROOT.php
error no_ani 0 [07/Aug/2008:12:03:39 -0400] 5734 000001;000;1218123820 DocumentParser::FetchDocument - Parse error in file "../UPDATE/u01_PasswordRequest.vxml", line 30, column 15 - Expected end of tag 'if'
error no_ani 0 [07/Aug/2008:12:03:39 -0400] 5734 000001;000;1218123820 errno: 205 uri ../UPDATE/u01_PasswordRequest.vxml
error no_ani 10 [07/Aug/2008:12:12:18 -0400] 5734 000001;010;1218124322 DocumentParser::FetchDocument - Parse error in file "../UPDATE/u01_PasswordRequest.vxml", line 30, column 15 - Expected end of tag 'if'
error no_ani 10 [07/Aug/2008:12:12:18 -0400] 5734 000001;010;1218124322 errno: 205 uri ../UPDATE/u01_PasswordRequest.vxml
error no_ani 8 [07/Aug/2008:11:09:57 -0400] 5734 000000;008;1218120591 DocumentParser::FetchDocument - Parse error in file "http://www.PHARMACALL.mobi/VXML/INBOUND/ROOT.php", line 12, column 7 - Expected end of tag 'block'
error no_ani 8 [07/Aug/2008:11:09:57 -0400] 5734 000000;008;1218120591 errno: 205 uri http://www.PHARMACALL.mobi/VXML/INBOUND/ROOT.php
error no_ani 3 [07/Aug/2008:11:10:57 -0400] 5734 000000;003;1218120658 HTTP/1.1 404 Not Found - http://www.PHARMACALL.mobi/VXML/INBOUND/FIRST.vxml
error no_ani 3 [07/Aug/2008:11:10:57 -0400] 5734 000000;003;1218120658 DocumentParser::FetchBuffer - could not open URL: FIRST.vxml
error no_ani 3 [07/Aug/2008:11:10:57 -0400] 5734 000000;003;1218120658 DocumentParser::FetchDocument - exiting with error result 2
error no_ani 3 [07/Aug/2008:11:10:57 -0400] 5734 000000;003;1218120658 errno: 203 uri FIRST.vxml
error no_ani 20 [07/Aug/2008:11:13:54 -0400] 5734 000000;020;1218120763 DocumentParser::FetchDocument - Parse error in file "../UPDATE/u01_PasswordRequest.vxml", line 30, column 15 - Expected end of tag 'if'
error no_ani 20 [07/Aug/2008:11:13:54 -0400] 5734 000000;020;1218120763 errno: 205 uri ../UPDATE/u01_PasswordRequest.vxml
error no_ani 7 [07/Aug/2008:12:16:13 -0400] 5734 000000;007;1218124497 DocumentParser::FetchDocument - Parse error in file "../UPDATE/u01_PasswordRequest.vxml", line 30, column 15 - Expected end of tag 'if'
error no_ani 7 [07/Aug/2008:12:16:13 -0400] 5734 000000;007;1218124497 errno: 205 uri ../UPDATE/u01_PasswordRequest.vxml
Thanks,
Chris

Chris
Posts: 64
Joined: Wed Jul 23, 2008 12:50 pm

Post by Chris »

So I made the changes to SECOND.vxml that you suggested.
<form id="switch">
<block>
<prompt bargein="false">
Welcome!
</prompt>
<goto next="#EnrollmentUpdateSwitch"/>
</block>
</form>

But it still skips it and does not play the variable.
And when it does play the <form id="switch"> it puts a 5 to 10 second pause between it and the targeted <menu id="EnrollmentUpdateSwitch">

It also persists in skipping FIRST.vxml

And sometimes it works properly.

Now if it works properly once shouldn't it work correctly every time?

Oh yeah, it also pauses a good 5 to 10 seconds before the ROOT.php answers the phone.

What's happening here???
Thanks,
Chris

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

IVR developer finds problem with user's web server

Post by support »

Hi Chris,

There seems to be a problem with your web server since when we try to view http://www.pharmacall.mobi/VXML/INBOUND/FIRST.vxml on a web browser, we get a Page Not Found error. This is the reason why FIRST.vxml is being skipped. It does not appear to be an IVR system error.

Regards,
Plum Support
Last edited by support on Sun Dec 27, 2009 3:54 pm, edited 2 times in total.

Chris
Posts: 64
Joined: Wed Jul 23, 2008 12:50 pm

Still Screwey!

Post by Chris »

Sorry about that.
I changed the name of the file for another little test.
I just put FIRST.vxml back and it's still screwey.

I have been trying to make a similar 2 document series with a root doc (e00_OpenDB_Globals.php) work and am having the same problems.

I made 4 calls.

1. Worked well playing all documents, but did not play the variable in the third document.

2. Skipped immediately to e02g_Switch_EnrollOrUpdate.vxml (the equivelant of SECOND.vxml) Did not play the variable.

3. Played the first file e01_Enrollment-r.vxml.
Skipped the first form in e02g_Switch_EnrollOrUpdate.vxml
that is it ignored <form id="switch"> even with bargein set to false,
and after a 15 second pause
then played the <menu id="EnrollmentUpdateSwitch">
but did not play the variable.

4. Started with e02g_Switch_EnrollOrUpdate.vxml
Played <form id="switch">
Paused for 15 seconds then played <menu id="EnrollmentUpdateSwitch">
but again did not play the variable.

I know this is hard to believe. You are welcome to call in yourself.

Below is the code for each. You'll see that its practically identical to the original development documents "ROOT.php" "FIRST.vxml" and "SECOND.vxml".

e00_OpenDB_Globals.php

Code: Select all

<?php

$dbhost='H';
$dbusername='U';
$dbuserpass='P';
$dbname='N';
$dbTable='web_enrollment';

$conn = mysql_connect($dbhost, $dbusername, $dbuserpass) or die('Error connecting to mysql'.mysql_error());
mysql_select_db($dbname);

	$Program_query="SELECT program_name FROM web_enrollment WHERE  trx_agent='".MASTER."' ";
	$Program_result=mysql_query($Program_query)or die(mysql_error());
	$Program_row=mysql_fetch_array($Program_result)or die(mysql_error());

	$Product_query="SELECT product_id FROM web_enrollment WHERE  trx_agent='".MASTER."' ";
	$Product_result=mysql_query($Product_query)or die(mysql_error());
	$Product_row=mysql_fetch_array($Product_result)or die(mysql_error());

	$Generic_query="SELECT generic_name FROM web_enrollment WHERE  trx_agent='".MASTER."' ";
	$Generic_result=mysql_query($Generic_query)or die(mysql_error());
	$Generic_row=mysql_fetch_array($Generic_result)or die(mysql_error());

mysql_close($conn);
?>
<vxml version="2.0">
<form id="SetGlobalVariables">
<block>

<var name="program_name" expr=" '<? echo ($Program_row[0]) ?>' " />
<assign name="application.ProgramName" expr="program_name"/>

<var name="product_id" expr=" '<? echo ($Product_row[0]) ?>' " />
<assign name="application.ProductName" expr="product_id"/>

<var name="generic_name" expr=" '<? echo ($Generic_row[0]) ?>' " />
<assign name="application.GenericName" expr="generic_name"/>

<goto next="e01_Enrollment-r.vxml"/>
</block>
</form>
</vxml>
e01_Enrollment-r.vxml

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0" application="e00_OpenDB_Globals.php">

<form>
<block>
<prompt bargein="false">Hello! Thanks for calling <value expr="application.ProgramName"/> . 
This is a free service for people who bought <value expr="application.ProductName"/> ,  <value expr="application.GenericName"/> , 
and requires a touch-tone phone. 


<!-- ///////////   OR OFFER A LANGUAGE CHOICE  /////////////
To continue in English press (1),  for Spanish, press (2). 
<choice  dtmf="1"  next="e02_EnrollmentUpdateSwitch.vxml"></choice>
<choice  dtmf="2" next="es02_EnrollmentUpdateSwitch.vxml"></choice>

<audio src="http://www.pharmacall.mobi/VXML/audio/mobile?code=12s4"/>
-->

</prompt>
<goto next="e02g_Switch_EnrollOrUpdate.vxml"/>

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

e02g_Switch_EnrollOrUpdate.vxml

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0" application="e00_OpenDB_Globals.php">

<meta name="robots" content="noindex,nofollow"/>
<property name="interdigittimeout" value="3s"/> 
<property name="caching" value="safe"/>

<property name="sensitivity" value="0.3"/>
<property name="confidencelevel" value="0.3"/>
<property name="voicegender" value="male"/> 


  <form id="switch">
     <block>
      <prompt bargein="false">
Welcome!
</prompt>
        <goto next="#EnrollmentUpdateSwitch"/>
     </block>
  </form>

  <menu id="EnrollmentUpdateSwitch">
    <prompt>
If you are calling to enroll for the first time, 
press 1, or just say Enroll. 
If you have already enrolled in the program, and want to make changes to your <value expr="application.ProgramName"/> account,
press 2, or say Make Changes.  
    </prompt>

 <choice dtmf="1" next="e03_ContinueEnrollmentMenu.php" accept="approximate">enroll</choice> 

 <choice dtmf="2" next="#PasswordRequest" accept="approximate">make changes</choice>

   <catch event="nomatch noinput help">
      <reprompt />
    </catch>
  </menu>

<form id="PasswordRequest">
    <block>
    <goto next="../UPDATE/u01_PasswordRequest.vxml"/>
    </block>
  </form>

</vxml>
And yes, everything shows up in a web browser.
Thanks,
Chris

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Call log needed for IVR developers to determine problem

Post by support »

Hi Chris,

Can you provide us with an IVR call log of what happens when you call into your IVR application?

Regards,
Plum Support
Last edited by support on Thu Feb 18, 2010 3:45 pm, edited 2 times in total.

Post Reply