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

vars between docs

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
brent.russell
Posts: 50
Joined: Wed Oct 04, 2006 1:34 pm
Location: SOCAL
Contact:

vars between docs

Post by brent.russell »

I am trying to use a variable set in one vxml doc, in another vxml doc.

here is what I am doing so far:

VXML Doc 1 which later leads to vxml doc 2:

Code: Select all

<var name="url" expr="'http://www.site.com'" />
vxml doc 2:

Code: Select all

<var name="url" expr="'http address'" />
<var name="voiceovers" expr="'voice over location'" />
<form>
<block>
<assign name="url" expr="application.url"/>
<assign name="voiceovers" expr="application.voiceovers"/>
<goto next="#processEnd"/>
</block>
</form>

<form id="processEnd">
<field name="confirmMenuChoice">
<grammar type="application/x-jsgf">1|2</grammar>
<property name="interdigittimeout" value="4s" />
<audio expr="'url+'/goodbye.mp3'">
</field>
</form>

Here is the error log I get when I try:
VXI::var_element(name="url" expr = "'http address'")
VXI::assign_element(name="url" expr = "application.url"
VXI::queue_prompts()
errmsg unterminated string literal line 1 linetxt 'url+'/goodbye.mp3' tokentxt '
errmsg SyntaxError: unterminated string literal line 1 linetxt 'url+'/goodbye.mp3' tokentxt '
received event: error.semantic.ecmascript
All I want is a common place to put a url variable and use it throughout the entire script on all docs without using php. Using php will require a rewrite of everything which I don't have time for.

Thank you very much for your help,
Brent

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

IVR ex-2 pgs have same root doc and data persistently stored

Post by support »

Brent,

The IVR code error you are receiving is due to a typo in your expr attribute, there is an extra single quote in front of url. It should be

Code: Select all

<audio expr="url+'/goodbye.mp3'"/>
If you want persistent variables to be stored across all documents you should use a "root document". The root document is specified in each of your VoiceXML scripts and is in itself a VoiceXML script and can be used to store information that will be retained across page transitions (assuming all pages specify the same root document). Here is a simple IVR example where 2 pages have the same root document and data is persistently stored:

root.vxml

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0">
    <var name="url"/>
</vxml>
page1.vxml

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0" application="root.vxml">
    <assign name="url" expr="'http://someurl'"/>
    <form>
        <block>
            <prompt>
                <audio expr="url+'/hello.mp3'"/>
            </prompt>
            <goto next="page2.vxml"/>
        </block>
    </form>
</vxml>
page2.vxml

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0" application="root.vxml">
    <form>
        <block>
            <prompt>
                <audio expr="url+'/goodbye.mp3'"/>
            </prompt>
        </block>
    </form>
</vxml>
It is also possible to just assign the variable in your root document and then only read it in your leaf documents. For an IVR example root.vxml could assign url, and then both page1.vxml and page2.vxml could access the url variable.

Regards,
Plum Support
Last edited by support on Sat Feb 20, 2010 3:34 pm, edited 3 times in total.

brent.russell
Posts: 50
Joined: Wed Oct 04, 2006 1:34 pm
Location: SOCAL
Contact:

Post by brent.russell »

This does not seem to work for me. I dont even get the hello world prompt as shown below. I can't see what i am doing different

root.vxml:

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0">
    <var name="url"/>
    <var name="unsubscribe_file"/>
    <var name="voiceovers"/>
    <var name="source"/>
    <var name="ivr_user_name"/>
    <var name="ivr_password" />
    <var name="request_type"/>
    <var name="GVphone"/>
    <var name="document.phone_number"/>
    <var name="document.tempPhoneNumber"/>
</vxml>


index.vxml

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0" application="root.vxml">
<form id="assign">
  <block>
        <assign name="url" expr="'http://site.com:8080'" />
        <assign name="voiceovers" expr="'voice_overs'" />
  </block>
</form>


<form id="mainstart">
 <property name="interdigittimeout" value="2s"/> 
  <block>
   <prompt bargein="false">
   <audio expr="url+'/'+voiceovers+'/VO1_.mp3'">hello world</audio>
   </prompt>
  </block>
</form>
</vxml>


The error I am getting:
Thu 08 Feb 2007 04:38:06 PM EST:
Call Start Event: ANII 3104257331 DNIS 2016 VURL http://hosting.plumgroup.com/plumvp/director.vxml
DocumentParser::FetchDocument()
DocumentParser::FetchDocument(http://hosting.plumgroup.com/plumvp/director.vxml)
Cache Hit: http://hosting.plumgroup.com/plumvp/director.vxml
VXI::var_element(name="dnis" expr = "session.telephone.dnis")
DocumentParser::FetchDocument(director.php)
Posted form data is URL encoded
Attempting to fetch http://hosting.plumgroup.com/plumvp/director.php
Click here to view saved VoiceXML script
DocumentParser::FetchDocument(scratchpad.php/mmsc/us_index.vxml)
Cache Miss: http://hosting.plumgroup.com/plumvp/scr ... index.vxml
Attempting to fetch http://hosting.plumgroup.com/plumvp/scr ... index.vxml
Click here to view saved VoiceXML script
DocumentParser::FetchDocument(root.vxml)
Cache Miss: http://hosting.plumgroup.com/plumvp/scr ... /root.vxml
Attempting to fetch http://hosting.plumgroup.com/plumvp/scr ... /root.vxml
Click here to view saved VoiceXML script

Thu 08 Feb 2007 04:38:07 PM EST:
Loading Builtin grammar: builtin:grammar/digits?length=10
Loading Builtin grammar: builtin:dtmf/digits?length=10
GrammarManager::CreateGrammarFromString(application/x-jsgf):
---------

<?xml version='1.0'?>
<grammar xml:lang="en-us" mode="voice">
1|2
</grammar>

---------

GrammarManager::CreateGrammarFromString(application/x-jsgf):
---------

<?xml version='1.0'?>
<grammar xml:lang="en-us" mode="dtmf">
1|2
</grammar>

---------

VXI::var_element(name="url" expr = "")
VXI::var_element(name="unsubscribe_file" expr = "")
VXI::var_element(name="voiceovers" expr = "")
VXI::var_element(name="source" expr = "")
VXI::var_element(name="ivr_user_name" expr = "")
VXI::var_element(name="ivr_password" expr = "")
VXI::var_element(name="request_type" expr = "")
VXI::var_element(name="GVphone" expr = "")
VXI::var_element(name="document.phone_number" expr = "")
bargein set to true
INPUTMODES set to "DTMF VOICE"
Audio segment added to prompt queue from TTS text/plain;charset=wchar_t for:
---------

A serious error of type
---------
bargein set to true
INPUTMODES set to "DTMF VOICE"
Audio segment added to prompt queue from TTS text/plain;charset=wchar_t for:
---------
error.semantic.ecmascript
---------
bargein set to true
INPUTMODES set to "DTMF VOICE"
Audio segment added to prompt queue from TTS text/plain;charset=wchar_t for:
---------
has occurred. Exiting.

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

IVR script fails and throws an error

Post by support »

Brent,

You can not reference the "document." scope applications inside of a root document. This is also clear because the IVR script fails and throws an IVR error right after it attempts to create "document.phone_number". You should either remove the "document." prefix in the root document or set them inside your leaf document.

Regards,
Plum Support

Post Reply