1

I'm creating a voicexml appliacation.

I want to store an user input into a global variable.

I wondered, the input should be stored in the fieldvar. shouldn't it? After I tried it with this, i tried to store it in an global variable:

<assign name="myvar" expr="'myinput'"/>

but somehow it didn't work. I used value expr="var" as expr.

<?xml version="1.0" encoding="UTF-8"?> 
<vxml 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"
   version="2.0">


<var name="myProdukt" />


<form id="test">

<field name="var">
<prompt bargein="true" bargeintype="hotword" >Sagen Sie ein Produkt</prompt>

<grammar root="main" version="1.0" xml:lang="de-DE">

  <rule id="main" scope="public">
    <one-of>
      <item> p1 </item>
      <item> p2 </item>
      <item> p3 </item>
      <item> p4   </item>
    </one-of>
  </rule>

</grammar>



<filled>
<assign name="myProdukt" expr="<value expr="var"/>"/>
</filled>

</field>


</form>

<<!--[...] Here i want to use the input.-->

</vxml>

thanks in advance

---------------EDIT:

now i used this:

<filled>
test
<assign name="myProdukt" expr="var" />
</filled>

I only changed that. The Applications says "test" but then there is an error.


It isn'T allowed to use "var" instead I used an other name :-)

David J. Liszewski
  • 10,959
  • 6
  • 44
  • 57
Tyzak
  • 2,430
  • 8
  • 38
  • 52
  • Well it seems to be more or less the same. the application says "test" in the filled tags, but then it says that an error occurred and the the application stops. – Tyzak Jan 06 '11 at 11:25
  • seems to be , but the is correct I think – Tyzak Jan 06 '11 at 11:26
  • @Tyzak. I agree that the answer below is correct. Once the assign has completed, the call will transition to the next unfilled field or the next form. If it reaches the end of the document, most platforms will just hang up. – Jim Rush Jan 06 '11 at 11:29
  • 1
    Got it! it isn't allowed to declare a variabkle with VAR – Tyzak Jan 06 '11 at 11:29
  • @Tyzak Oh yes! I forgot about that constraint. – David J. Liszewski Jan 06 '11 at 14:58

1 Answers1

3

Did you try a simple assignment of field var to the variable myProdukt like so ?

<filled>
    <assign name="myProdukt" expr="var"/>
</filled>

Which would be fine except that according to Section 5.1, Variables and Expressions of the Voice XML specification:

VoiceXML variables, including form item variables, must not contain ECMAScript reserved words.

So, you'll need to rename the field var to something that is not a reserved word in ECMAscript, say productSelection:

<field name="productSelection"> 
    <!-- .. prompt, grammar as before .. -->
    <filled>
        <assign name="myProdukt" expr="productSelection"/>
    </filled>
</field>
David J. Liszewski
  • 10,959
  • 6
  • 44
  • 57
  • that should work, (https://studio.tellme.com/vxml2/ovw/variables.html says so too) but it doesn't ?! I'm very confused :> – Tyzak Jan 06 '11 at 10:02