VoiceXML 2.1 Development Guide Home  |  Frameset Home


<assign>  element


The assign element is used to explicitly assign a value to a variable. The Prophecy implementation ignores the requirement where a variable must be pre-declared in order to assign a value to it, for ease of development. See the documentation on ‘variables’ for detailed information on scooping, assignment, and session variables.


usage

<assign expr="CDATA" name="NMTOKEN">


attributes

expr Data Type: CDATA Default: Required
The expr defines the new value of the variable in question. Any valid ECMAscript value is considered to be a suitable value.
name Data Type: NMTOKEN Default: Required
The name attribute specifies any currently available variable name within the current scope.



shadow variables

none


parents

<block>   <catch>   <error>   <filled>   <help>   <if>   <noinput>   <nomatch>


children

none


code samples

<Assign name-expr> sample
<?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"/>

<var name="Var1" expr="'sasquatch'"/>

<form id="F_1">
  <block>
    <prompt>here we use the assign elements attributes of
            name and expression.</prompt>
    <prompt>our initial value for the variable is
            <value expr="Var1"/></prompt>
  </block>

  <block>
    <assign name="Var1" expr="'chupacabra'"/>
    <prompt>but after using the assign tag, the value of our
            variable is now <value expr="Var1"/></prompt>
  </block>
</form>

</vxml>



additional links

W3C 2.0 Specification


  ANNOTATIONS: EXISTING POSTS
vinayagan
8/29/2006 9:12 AM (EDT)
Hi,

  I would like to write the vxml certification.I don't know whether is it possible in india.

  If anybody have ideas about the certification centre please inform.

Thanks
nayagan
MattHenry
8/29/2006 11:31 AM (EDT)

Nayagan,

I might suggest that you check the vxml forum, and the prometric site for information regarding VXML developer certification in your region:

http://vxmlforum.com/certification/developer.html
http://www.prometric.com/default.htm

Regards,

~Matthew Henry

vinayagan
8/30/2006 8:45 AM (EDT)
Hi Henry,

  Thanks for you information.

    I entered into http://www.prometric.com/default.htm site.They one option to select testing program in that i couldn't find vxml certification.

  Only xml certification and others are available.

  If possible please tell me what are all the necessary things to complete vxml certification.

Thanks
Nayagan
MattHenry
8/30/2006 12:09 PM (EDT)

Nayagan,

While we have VXML certified developers working in a support capacity, and while our platforms are certified compliant, we don't really have anything to do with the testing process itself.

I would advise that you contact the admins of the vxml forum for test information specific to your region to gather the information that you require.

Regards,

~Matthew henry
vinayagan
8/31/2006 9:34 AM (EDT)
Hi Henry,

  Any specific books are available to prepare for vxml certification.

Thanks
Nayagan
MattHenry
8/31/2006 12:36 PM (EDT)
Nayagan,

The best reference for certification is going to be the w3c specification, and CCXML specification. However, if you prefer to purchase a book, the following link has a few suggestions:

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

Overall, this book is really the best one I have seen, even though it is a few years old:

http://www.amazon.com/exec/obidos/tg/detail/-/0471418935/qid=1034112100/sr=8-1/ref=sr_8_1/102-7415965-6947357?v=glance&n=507846


~Matt
mikethompson
8/31/2006 12:44 PM (EDT)
Nayagan,

When I studied for the VoiceXML Certification Test, I primarily used the w3c VoiceXML specification.  If you're not sure where that is located, you can find it here:

VoiceXML 2.0:
http://www.w3.org/TR/2004/REC-voicexml20-20040316/

VoiceXML 2.1:
http://www.w3.org/TR/voicexml21/

Of course, I was also extremely familiar with this documentation.

Hope this helps,
Mike Thompson
Voxeo Corporation
vinayagan
9/4/2006 5:23 AM (EDT)
Hi,

  I Would like to write free mock voiceXML certification exams first.Is couldn't find any specific sites ..

Please let me know If there is any.

Thanks
Nayagan
vinayagan
9/4/2006 5:24 AM (EDT)
Hi,

  I Would like to write free mock voiceXML certification exams first.I couldn't find any specific sites ..

Please let me know If there is any.

Thanks
Nayagan
MattHenry
9/4/2006 12:18 PM (EDT)


Hello Nayagan,

I might suggest that you take a look at http://www.larson-tech.com/; they have a small amount of publicly available sample tests, (you can purchase the CD, which has a lot more information for getting ready for the test itself).

Regards,

~Matthew Henry
vinayagan
9/8/2006 7:57 AM (EDT)
Hi,

  I am having working experience in vxml and in ECMA Script.. and some syntax knowledge in srgml..

Is that enough to write the vxml certification...What else shall i improve...

Thanks
Nayagan

mikethompson
9/8/2006 2:28 PM (EDT)
Hi Nayagan,

To be quite honest, I spent most of my time reviewing the VoiceXML W3C Specification:
http://www.w3.org/TR/2004/REC-voicexml20-20040316/

If you know the spec like the back of your hand, you will be fine. :)

Best,
Mike Thompson
Voxeo Corporation
optim8
10/1/2006 11:34 AM (EDT)
Hi

I would like to assign a string value containing quotes to a variable.  Part of the string is dynamically determined by another variable value.  How do I go about doing this. (i.e. how do I represent quotes to appear in the final value, within the quotes of the assign tag)

e.g. I would like to assign the following value to a var called 'sql':

"insert into tbl1(Id, Desc) VALUES(13, 'description1 Content')"

the term 'description content' must appear with the quotes (as it is a SQL statement to intert a string value), and the term is held in a variable called descrpt.

I assume it is something like:
<assign name="sql" expr="'insert into tbl1(Id, Desc) VALUES(13, ''' + descrpt + ''')'" />

Thanks.
-c-
MattHenry
10/1/2006 1:47 PM (EDT)


Hi there,

This question borders on an inquiry specific to the dynamic markup that you are using to generate content, which is somewhat outside the scope of the support that we do offer. To be frank, I'm not seeing what good it is going to be to assign a SQL command to a variable in the VXML context: As VXML is a static markup, the only interactions with a DB that can be done are on the side of your JSP/PHP/whatever. For what it's worth, your syntax in assigning this value *looks* correct, although you may want to enclose the value inside of a CDATA block to ensure that no parsing errors occur.

Regards,

~Matthew Henry
vinayagan
12/11/2006 4:36 AM (EST)
Hi,

  Any one can help me in this....

  I would like to know the VXML CERTIFICATION Qustion pattern..

  Whether most of the questions from vxml or it can have ccxml,ssml,srgms,ecma script as well.

  Thanks
  Nayagan
MattHenry
12/11/2006 10:53 AM (EST)

Nayagan,

I should make clear that we don't really have too much to do with the VXML certification testing: Really, questions in this sort of vein should be directed at the VXML Forum, (www.vxmlforum.com), for definitive answers to these sort of questions. While I can't help you out with the specific questions on the certification, I can say that you can expect the majority of the questions, (maybe 80%), to be on VXML. The rest, you can certainly expect to see questions on CCXML, SRGS/SISR grammars, SSML, and ECMAScript.

Good luck,

~Matthew henry
vinayagan
12/26/2006 10:52 AM (EST)
Hi,
  For the following grammar, the utterance "I want to fly to Boston" will return the result "BOS".
<grammar version="1.0" xmlns="http://www.w3.org/2001/06/grammar"
        xml:lang="en-US" tag-format="semantics/1.0-literals" root="flight">
  <rule id="flight" scope="public">
    I want to fly to
    <ruleref uri="#airports"/>
  </rule>
  <rule id="airports" scope="private">
    <one-of>
      <ruleref uri="#USairport "/>
      <ruleref uri="#otherairport"/>
    </one-of>
  </rule>
  <rule id="USairport" scope="private">
    <one-of>
      <item>Boston<tag>BOS</tag></item>
      <item>New York<tag>JFK</tag></item>
      <item>Chicago<tag>ORD</tag></item>
    </one-of>
  </rule>
  <rule id="otherairport" scope="private">
    <one-of>
      <item>Brussels<tag>BRU</tag></item>
      <item>Paris<tag>CDG</tag></item>
      <item>Rome<tag>FCO</tag></item>
    </one-of>
  </rule>
</grammar>
Can anyone help me in understanding the above pgm..
Where i want to fly will store and how the interpretation is happening here.
<rule id = "name">only text</rule>--is that valid rule?

Thanks
Nayagan
sidvoxeo
12/26/2006 1:15 PM (EST)
Hi there,

We would really appreciate if you open support tickets when you have issues with VXML scripts.
I have opened a support ticket with your question (Account Ticket #203443), so that we may be able to track this issue.

Thanks

Sid
ashutosh_gautam
6/18/2007 2:05 AM (EDT)
Hello nayagan,

could u please give me the information about VXML test center in bangalore or anywhere in india.
i have also checked up with these links

http://vxmlforum.com/certification/developer.html
http://www.prometric.com/default.htm

but couldnt found test center in india .

thanks
ashutosh
georgelai
8/22/2007 5:36 AM (EDT)
This is a simple question. I defined a variable, and then assigned it.  I passed this variable to another vxml file, but it defaulted to the defined variable expression.

Is there a way to pass a variable from one vxml file to another?

Here's my code:

### Initial Code #####
<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1">
<meta name="maintainer" content="YOUREMAILADDRESS@HERE.com"/>

<var name="Var1" expr="'sasquatch'"/>

<form id="mainmenu">
  <block>
      <prompt bargein="false">
      Start with <value expr="Var1"/>. <!-- sasquatch -->
      </prompt>
  </block>

  <field name="F_1">
  <grammar src="VoiceGrammar3.php#MYNAME" type="text/gsl"/>

  <prompt bargein="false" timeout="20s">
Give me a name.
  </prompt>
  </field>

  <filled namelist="F_1">
<prompt>
I heard <value expr="F_1"/>.
</prompt>
  </filled>

  <block>
    <assign name="Var1" expr="F_1"/>
    <prompt>Is the following correct? <value expr="Var1"/></prompt>
  </block>
 
 
  <field name="F_2" type="boolean">
<prompt>
      Yes or No?
  </prompt>
  </field>
 
  <filled>
<if cond="F_2 == true">
<!-- USER SAID YES -->
<prompt>
Glad to help.  Goodbye!
</prompt>
<else/>
<!-- USER SAID NO -->
<clear namelist="F_1 F_2"/>
<goto next="callflowB2.xml" /> <!-- this is where Var1 isn't passed -->
</if>
  </filled>
</form>
</vxml>



#### callflowB2.xml ########
<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1" application="callflowB1.xml">
<meta name="maintainer" content="YOUREMAILADDRESS@HERE.com"/>
  <form>
    <block>
      You said <value expr="application.Var1"/>
<!-- repeats 'sasquatch' -->
    </block>
  </form>
</vxml>
MattHenry
8/22/2007 12:54 PM (EDT)


George,

I thionk that what you really want to do here is this:

[color=blue]
<block>
    [b]<assign name="application.Var1" expr="F_1"/>[/b]
    <prompt>Is the following correct? <value expr="application.Var1"/></prompt>
  </block>
[/color]

Let me know if this doesn't work out for you.

~Matt
jefo12
6/17/2008 9:42 AM (EDT)
i need to check whether caller id is present or not...

<var name="callerid"/>
<assign name="callerid" expr ="session.callerid"/>
<submit next="mypage.jsp"method="post" namelist="callerid"/>
if caller id is present i hav to check when he had an appointment and play it...

plz giv me vxmlcode and also related examples...

VoxeoDustin
6/17/2008 10:17 AM (EDT)
Hey Jefo,

Here is a basic example to check that the caller ID is present(a 10 digit number) and not unknown or restricted.

<?xml version="1.0"?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
<var name="callerid" expr="session.callerid"/>

<form id="welcome">
  <block>
      <if cond="callerid.length == 10 &amp;&amp; callerid != 'restricted'">
          <log expr="'***** CALLER ID: ' + callerid"/>
      <else/>
          <log expr="'***** CALLER ID NOT PRESENT'"/>
      </if>
  </block>
</form>
</vxml>

Cheers,
Dustin
jefo12
6/18/2008 11:28 AM (EDT)
I need to check if callerid is first valid. IF it is anonymous or unknown, the caller should be prompted to enter his caller id.if the callerid is present check what is the date of his appointment and announce it also ask him whether cancel or reschedule the appointment...
To cancel or to reschedule use subdialog call a jsp and parses the o/p.

FOR CALLERS WHO ARE CALLING FOR THE FIRST TIME SHOULD GO TO NEW APPOINTMENT FORM ID.

PLZ GIVE ME THE VXML CODE FOR THIS.I NEED IT VERY URGENT...
PLZ CAN ANY ONE HELP ME OUT ......
SUGGEST ME ANY RELATED SITES.....






VoxeoDustin
6/18/2008 11:32 AM (EDT)
Hey Jefo,

Here's a basic example that should get you started.

<?xml version="1.0"?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
<var name="callerid" expr="session.callerid"/>

<form id="welcome">
  <block>
      <if cond="callerid.length == 10 &amp;&amp; callerid != 'restricted'">
          <log expr="'***** CALLER ID: ' + callerid"/>
          <submit next="mydoc.jsp" namelist="callerid"/>
      <else/>
          <log expr="'***** CALLER ID NOT PRESENT'"/>
          <goto nextitem="enterPhone"/>
      </if>
  </block>

  <field name="enterPhone" type="digits?length=10">
      <prompt> Please enter your phone number </prompt>
      <filled>
          <submit next="mydoc.jsp" namelist="enterPhone"/>
      </filled>
  </field>

</form>
</vxml>

Cheers,
Dustin
jefo12
8/6/2008 5:49 AM (EDT)
hi,

Is there any way to store the array of elements in a variable in voice xml.


<var name="Myarray" expr="new Array()"/>
<assign name="Myarrray" expr="sunday"/>
<assign name="myarrray" expr="monday"/>

i want to store sunday,monday.. in Myarray.Is it possible!if possible give me the reply.

voxeojohnq
8/6/2008 5:55 AM (EDT)
Hi jefo,

In order to manipulate elements within an array, you will have to use the <script> element.  Within the script tags, you can pretty much do anything you can normally do with JavaScript.  I hope this helps!

Regards,

John Quinn
Voxeo Support
sathez
8/22/2008 3:42 AM (EDT)
Hi,
    i am planing to take vxml certification,kindly suggest me what are the things i had to do, wethere any E-books are avaliable for certification








Thanks
sathez
voxeojohnq
8/22/2008 3:52 AM (EDT)
Hello,

There are many resources online that you could use to study up for the certification test.  Other than the documentation and tutorials that we have available, a quick search on google returned http://www.vxmlguide.com/ which seems like it has a study guide and a book available to help you prepare for the test.  If you have any further questions, please don't hesitate to ask.

Regards,

John Quinn
Voxeo Support
mtatum111
9/11/2008 10:03 AM (EDT)
It looks like name is also missing as an attribute of <assign>
Thanks
VoxeoDustin
9/11/2008 10:17 AM (EDT)
Hey,

Thanks for pointing that out. I have corrected the documentation and an updated build should push over soon to the website.

Thanks,
Dustin
dhawansalil
9/17/2008 6:11 AM (EDT)
Hello

I am looking to send my audio data to VXML Server in G.711uLaw format but i have GSM compressed file as input.How can i do GSM--->ULaw conversion so that VXML server understands it?

Also can anyone can really tell me exact significance of EMMA in interpreting user input.
How can i take the application.$lastresult structure and creates an EMMA document out of it.
voxeojeremyr
9/17/2008 2:32 PM (EDT)
Hi,

Are you looking to change the format of a audio recording?  If so any sound editing software out there should work such as Goldwave or Audacity.  Here are the formats we support:
    *  8bit, 8Khz, u-law Wave files (Riff Format)
    * 16bit, 8Khz, PCM Wave files (Riff Format)
    * 8bit, 8Khz, u-law Sphere files
    * 16bit, 8Khz, PCM Sphere files

If this is not the case if you could give us a bit more information we could try to figure something out. 

As far as EMMA documentation, I am not familiar with it but maybe somebody else out there could help you out.

Thanks,
Jeremy Richmond
Voxeo Support
pppeter
1/28/2009 12:29 AM (EST)
Hello, I'm having some issues with assigning to variables at application scope, when using a leaf document.

I saw a similar post in this thread, and tried to follow the advice of "MattHenry", but to no avail. Basically, I have a variable named "henrr" that is re-assigned inside form "hello", recited inside form "hello2" (correctly), but then when it's recited again inside "hello3" (in a different document), it defaults to the original value of the variable. How do I reassign the variable in one form, and then pick up that reassignment in a subsequent form?

Thanks,

Peter


Root Document (for_demo.vxml):
------------------------------

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

  <var name="henrr" expr="'3333'"/>

  <form id="hello">
    <block>
      <prompt> hello <break size="small"/></prompt>
      <assign name="application.henrr" expr="'2323'"/>
      <goto next="#hello2"/>
    </block>
  </form>

  <form id="hello2">
    <block>
      <prompt> hello two <break size="small"/><value expr="henrr"/></prompt>
      <goto next="three.vxml#hello3"/>
    </block>
  </form>

</vxml>

Leaf Document (three.vxml):
---------------------------
<?xml version="1.0"?>
<vxml version="2.1" application="for_demo.vxml">

  <form id="hello3">
    <block><prompt> hello three <break size="small"/><value expr="application.henrr"/><break size="small"/><value expr="henrr"/></prompt></block>
  </form>

</vxml>
voxeoJeffK
1/28/2009 2:49 AM (EST)
Hi Peter,

When using application scoped variables and leaf documents you will want to use your root document strictly for variable declarations and not form level interaction and assignations. Application level variables can be assigned to from leaf documents. So to use your code as an example we should have the root document and two leafs. The first leaf makes a change to the application variable, and that change is reflected when the second leaf accesses it:

Root Document (for_demo.vxml):
------------------------------

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

  <var name="henrr" expr="'3333'"/>

<form id="root">
    <block>
      <goto next="FirstLeaf.vxml#hello"/>
    </block>
  </form>

</vxml>

Leaf Document (FirstLeaf.vxml):
---------------------------
<?xml version="1.0"?>
<vxml version="2.1" application="for_demo.vxml">

  <form id="hello">
    <block>
    <prompt> Inside First leaf document <break size="small"/><value expr="application.henrr"/><break size="small"/><value expr="henrr"/></prompt>
    <assign name="application.henrr" expr="'2323'"/>
    <goto next="SecondLeaf.vxml#hello"/>
    </block>
  </form>
</vxml>

Leaf Document (SecondLeaf.vxml):
---------------------------
<?xml version="1.0"?>
<vxml version="2.1" application="for_demo.vxml">

  <form id="hello">
    <block>
    <prompt> Inside second leaf document <break size="small"/><value expr="application.henrr"/><break size="small"/><value expr="henrr"/></prompt>
    </block>
  </form>
</vxml>

Regards,
Jeff K.
Voxeo Support
pppeter
1/28/2009 4:16 PM (EST)
That did it! Thanks, Jeff!
achoy
3/25/2009 8:12 PM (EDT)
Hi Jeff,

In reference to your post at 1/28/2009 2:49 AM (EST), but what if in the case you have a catch disconnect event defined in the application root, and you wish to do a <submit> to pass to your server the new value of henrr, which is "2323"?

I'm finding that the value of henrr in my catch event is back at "3333" (whatever it was initialized to in the application root).

Is there a way to catch the disconnect in the application root, and pass the new values that henrr was assigned to in the leaf vxml?

Thanks,
Andrew
voxeo_chris
3/25/2009 10:40 PM (EDT)
Hello Andrew,

I would like to make an alteration to Jeff K's post just to improve it for better practice and to add the catch handler.  When I tested this application, it was returning the value of
[code]LOG: the value of henrr is - 2323[/code] so if you are still getting 3333, we will need to look further into your setup to determine what is going wrong. 

Just to explain the main differences:
1.  the root.xml no longer has a <goto> included as it is best to have the FirstLeaf as your starting document.  Therefore we set the application to call up FirstLeaf.xml, however as both leafs reference root.xml, it will still be included. 

2.  I added a disconnect event to the FirstLeaf.xml just to cause the catch in the root.xml to occur and commented out the <goto> to prevent the application from going to the SecondLeaf.xml before disconnecting as that would put a dent in our plans to test the catcher.

You can of course remove the <disconect> and add the <goto> back into the FirstLeaf application and it will behave like normal.  Please let us know if this makes sense and if you have any other problems as we would be happy to help.
[code]
[b]root.xml[/b]

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

<var name="henrr" expr="'3333'"/>

<catch event="connection.disconnect">
<log expr="'*********************************************************'"/>
<log expr="'the value of henrr is - ' + henrr"/>
<log expr="'*********************************************************'"/>
</catch>

</vxml>


[b]FirstLeaf.xml[/b]

<?xml version="1.0"?>
<vxml version="2.1" application="root.xml">

  <form id="hello">
    <block>
    <prompt> Inside First leaf document <break size="small"/><value expr="application.henrr"/><break size="small"/><value expr="henrr"/></prompt>
    <assign name="application.henrr" expr="'2323'"/>
    <!-- <goto next="SecondLeaf.xml#hello"/> -->
    <disconnect/>
    </block>
  </form>
</vxml>


[b]SecondLeaf.xml[/b]

<?xml version="1.0"?>
<vxml version="2.1" application="root.xml">

  <form id="hello">
    <block>
    <prompt> Inside second leaf document <break size="small"/><value expr="application.henrr"/><break size="small"/><value expr="henrr"/></prompt>
    </block>
  </form>
</vxml>
[/code]
Regards,

Chris Bruckart
Customer Engineer
Voxeo Support
achoy
3/26/2009 12:56 AM (EDT)
Hi Chris,

  Thanks for the follow up.  I realized what the issue was.  I was attempting to do the <assign> to the application scoped 'henrr' variable from within a subdialog that was called in my first leaf.  If i'm understanding correctly, subdialog sort of has it's own application root 'instance', that can't be shared across subdialogs, even if it has the same application root, unless the data is passed to it.  Please correct me if my analysis is wrong.
voxeoJeffK
3/26/2009 4:00 AM (EDT)
Hello,

Yes, you are correct. The W3C spec puts it this way:

"From a programming perspective, subdialogs behave differently from subroutines because the calling and called contexts are independent. While a subroutine can access variable instances in its calling routine, a subdialog cannot access the same variable instance defined in its calling dialog."

"In this particular context, we'll need to pass in the variable value via the <param> element nested within the subdialog tag and return the updated value via the <return namelist.../> attribute. Once back in the main dialog, we should be able to reset our application level variable with the returned value from the subdialog."

  http://www.w3.org/TR/voicexml20/#dml2.3.4

Regards,
Jeff Kustermann
Voxeo Support
Sarah_hasanlo
6/17/2012 2:49 AM (EDT)
Hi everybody
after years that anybody haven't sent message to this forum
I decide to send a message about useability of arrays in vxml!
if we use function that returns array we can have an array variable so we can access to it with this syntax:
<assign name="X" expr="func()"/>
<assign name="firstElement" expr="X[0]"/>

good luck
Sara

login



© 2013 Voxeo Corporation  |  Voxeo IVR  |  VoiceXML & CCXML IVR Developer Site