ZVON > References > VoiceXML Reference
Element:vxml
Attributes: | application | base | lang | version |
Children: | catch | error | form | help | link | menu | meta | noinput | nomatch | property | script | var |
Description:

Go to Standard

Examples:


<vxml version="1.0">
     <meta name="maintainer" content="jpdoe@anycompany.example"/> …
</vxml>


<vxml version="1.0">
     <property name="example.acme.endpointing.record_init_silence" value="1s"/> … dialogs that make recordings go here …
</vxml>


<vxml version="1.0">
     <form>
          <block>Hello World!</block>
     </form>
</vxml>


<vxml version="1.0">
     <meta http-equiv="Expires" content="0"/>
     <meta http-equiv="Date" content="Thu, 12 Dec 1999 23:27:21 GMT"/> …
</vxml>


<vxml version="1.0">
     <var name="bye" expr="'Ciao'"/>
     <link next="operator_xfer.vxml">
          <grammar> operator </grammar>
     </link>
</vxml>


<vxml version="1.0">
     <property name="caching" value="fast"/> …
     <form id="test">
          <block>
               <audio src="http://www.weather4U.example/vxml/welcome.wav"/>
               <audio caching="safe" src="http://www.onlineads.example/weather4U/ad17"/>
          </block> …
     </form> …
</vxml>


<vxml version="1.0">
     <form>
          <field name="birthday" type="date"> What is your birthday? </field>
          <subdialog name="result" src="/cgi-bin/getlib#getdriverslicense" namelist="birthday">
               <filled>
                    <submit next="http://myservice.example/cgi-bin/process"/>
               </filled>
          </subdialog>
     </form>
</vxml>


<vxml version="1.0">
     <form>
          <field name="drink">
               <prompt>Would you like coffee, tea, milk, or nothing?</prompt>
               <grammar src="drink.gram" type="application/x-jsgf"/>
          </field>
          <block>
               <submit next="http://www.drink.example/drink2.asp"/>
          </block>
     </form>
</vxml>


<vxml version="1.0">
     <meta name="author" content="John Doe"/>
     <meta name="maintainer" content="hello-support@hi.example"/>
     <var name="hi" expr="'Hello World!'"/>
     <form>
          <block>
               <value expr="hi"/>Goodbye!
          </block>
     </form>
</vxml>


<vxml version="1.0">
     <form id="basic">
          <field name="acctnum" type="digits">
               <prompt> What is your account number? </prompt>
          </field>
          <field name="acctphone" type="phone">
               <prompt> What is your home telephone number? </prompt>
               <filled>
                    <return namelist="acctnum acctphone"/>
               </filled>
          </field>
     </form>
</vxml>


<vxml version="1.0" application="app-root.vxml">
     <form id="say_goodbye">
          <field name="answer" type="boolean">
               <prompt>Shall we say
                    <value expr="application.bye"/>?
               </prompt>
               <filled>
                    <if cond="answer">
                         <exit/>
                    </if>
                    <clear namelist="answer"/>
               </filled>
          </field>
     </form>
</vxml>


<vxml version="1.0">
     <script> function factorial(n) { return (n <= 1)? 1 : n * factorial(n-1); } </script>
     <form id="form">
          <field name="fact" type="number">
               <prompt> Tell me a number and I'll tell you its factorial. </prompt>
               <filled>
                    <prompt>
                         <value expr="fact"/> factorial is
                         <value expr="factorial(fact)"/>
                    </prompt>
               </filled>
          </field>
     </form>
</vxml>


<vxml version="1.0">
     <meta name="author" content="John Doe"/>
     <meta name="maintainer" content="hello-support@hi.example"/>
     <var name="hi" expr="'Hello World!'"/>
     <form>
          <block>
               <value expr="hi"/>
               <goto next="#say_goodbye"/>
          </block>
     </form>
     <form id="say_goodbye">
          <block> Goodbye! </block>
     </form>
</vxml>


<vxml version="1.0">
     <form id="billing_adjustment">
          <var name="account_number"/>
          <var name="home_phone"/>
          <subdialog name="accountinfo" src="acct_info.vxml#basic">
               <filled>
                    <assign name="account_number" expr="accountinfo.acctnum"/>
                    <assign name="home_phone" expr="accountinfo.acctphone"/>
               </filled>
          </subdialog>
          <field name="adjustment_amount" type="currency">
               <prompt> What is the value of your account adjustment? </prompt>
               <filled>
                    <submit next="/cgi-bin/updateaccount"/>
               </filled>
          </field>
     </form>
</vxml>


<vxml version="1.0">
     <form id="getdriverlicense">
          <var name="birthday" expr="'1980-02-10'"/>
          <field name="drivelicense">
               <grammar src="http://grammarlib/drivegrammar.gram" type="application/x-jsgf"/>
               <prompt> Please say your driver’s license number. </prompt>
               <filled>
                    <if cond="validdrivelicense(drivelicense,birthday)">
                         <var name="status" expr="true"/>
                         <else/>
                         <var name="status" expr="false"/>
                    </if>
                    <return namelist="drivelicense status"/>
               </filled>
          </field>
     </form>
</vxml>


<vxml version="1.0">
     <form>
          <record name="greeting" beep="true" maxtime="10s" finalsilence="4000ms" dtmfterm="true" type="audio/wav">
               <prompt> At the tone, please say your greeting. </prompt>
               <noinput> I didn't hear anything, please try again. </noinput>
          </record>
          <field name="confirm" type="boolean">
               <prompt> Your greeting is
                    <value expr="greeting"/>.
               </prompt>
               <prompt> To keep it, say yes. To discard it, say no. </prompt>
               <filled>
                    <if cond="confirm">
                         <submit next="save_greeting.pl" method="post" namelist="greeting"/>
                    </if>
                    <clear/>
               </filled>
          </field>
     </form>
</vxml>


<vxml version="1.0">
     <form>
          <transcribe name="message" beep="true" maxtime="30s">
               <prompt> What is the message you want to leave? </prompt>
               <nomatch count="2"> Try to make your message simpler. </nomatch>
               <nomatch count="3"> Transferring to operator.
                    <goto next="queue_caller.pl"/>
               </nomatch>
          </transcribe>
          <field name="confirm" type="boolean">
               <prompt> Your message is
                    <value expr="message"/>.
               </prompt>
               <prompt> To send it, say yes. To discard it, say no. </prompt>
               <filled>
                    <if cond="confirm">
                         <submit next="send_page.pl" namelist="message"/>
                    </if>
                    <clear/>
               </filled>
          </field>
     </form>
</vxml>


<vxml version="1.0">
     <form>
          <var name="hours"/>
          <var name="minutes"/>
          <var name="seconds"/>
          <block>
               <script> var d = new Date(); hours = d.getHours(); minutes = d.getMinutes(); seconds = d.getSeconds(); </script>
          </block>
          <field name="hear_another" type="boolean">
               <prompt> The time is
                    <value expr="hours"/> hours,
                    <value expr="minutes"/> minutes, and
                    <value expr="seconds"/> seconds.
               </prompt>
               <prompt>Do you want to hear another time?</prompt>
               <filled>
                    <if cond="hear_another">
                         <clear/>
                    </if>
               </filled>
          </field>
     </form>
</vxml>


<vxml version="1.0">
     <form id="getcredit">
          <var name="status" expr="'no_result'"/>
          <var name="username"/>
          <field name="creditcardnum">
               <prompt> What is your credit card number? </prompt>
               <help> I am trying to collect your credit card information.
                    <reprompt/>
               </help>
               <nomatch>
                    <return namelist="status"/>
               </nomatch>
               <grammar/>
          </field>
          <field name="expirydate" type="date">
               <prompt> What is the expiry date of this card? </prompt>
               <help> I am trying to collect the expiry date of the credit card number you provided.
                    <reprompt/>
               </help>
               <nomatch>
                    <return namelist="status"/>
               </nomatch>
          </field>
          <block>
               <assign name="status" expr="'result'"/>
               <return namelist="status creditcardnum expirydate"/>
          </block>
     </form>
</vxml>


<vxml version="1.0">
     <var name="username"/>
     <form id="buysoftware">
          <var name="ccn"/>
          <var name="exp"/>
          <grammar/>
          <initial name="start">
               <prompt> Please tell us the software product you wish to buy and the operating system on which it must run. </prompt>
               <noinput>
                    <assign name="start" expr="true"/>
               </noinput>
          </initial>
          <field name="product">
               <prompt> Which software product would you like to buy? </prompt>
          </field>
          <field mname="operatingsystem">
               <prompt> Which operating system does this software need to run on? </prompt>
          </field>
          <subdialog name="cc_results" src="http://somedomain.example/ccn.vxml">
               <filled>
                    <if cond="cc_results.status=='no_result'"> Sorry, your credit card information could not be Obtained. This order is cancelled.
                         <exit/>
                         <else/>
                         <assign name="ccn" expr="cc_results.creditcardnum"/>
                         <asssign name="exp" expr="cc_results.expirydate"/>
                    </if>
               </filled>
          </subdialog>
          <block> We will now process your order. Please hold.
               <submit namelist="username product operatingsystem ccn exp"/>
          </block>
     </form>
</vxml>


<vxml version="1.0">
     <property name="caching" value="safe"/>
     <property name="audiofetchhint" value="safe"/>
     <property name="confidence" value="0.75"/>
     <form>
          <property name="confidence" value="0.5"/>
          <property name="bargein" value="false"/>
          <grammar src="address_book.gram" type="application/x-jsgf"/>
          <block>
               <prompt> Welcome to the Voice Address Book </prompt>
          </block>
          <initial name="start">
               <property name="timeout" value="5s"/>
               <prompt> Who would you like to call? </prompt>
          </initial>
          <field name="person">
               <prompt> Say the name of the person you would like to call. </prompt>
          </field>
          <field name="location">
               <prompt> Say the location of the person you would like to call. </prompt>
          </field>
          <field name="confirm" type="boolean">
               <prompt> You said to call
                    <value expr="person$.utterance"/> at
                    <value expr="location$.utterance"/>. Is this correct?
               </prompt>
               <filled>
                    <if cond="confirm">
                         <submit next="http://www.messagecentral.example/voice/make_call" namelist="person location"/>
                    </if>
                    <clear/>
               </filled>
          </field>
     </form>
</vxml>