« CTIN405 Spring 07 — Course Reader & Syllabus | Main | Backyard SMT Work »

VXML Grammar Support

Here's an example of a VXML using a grammar with options:

<!DOCTYPE vxml 
   PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN"
   "http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd">
 <vxml version="2.0" 
   xmlns="http://www.w3.org/2001/vxml"
   xml:lang="en-US">
<property name="nuance.core.tts.ResourceName" value="en-US.English-Male2"/>
<property name="inputmodes" value="voice"/>
<!-- this is generated dynamically during the IVR session -->
<!-- it's the caller id, essentially -->
<var name="caller_min" expr="session.telephone.ani"/>
<var name="number_dialed" expr="session.telephone.dnis"/>
<property name="termtimeout" value="0.1"/>
<!--property name="interdigittimeout" value=".5"/-->
<!--property name="termchar" value=""/-->
<property name="bargein" value="true"/>
 <link next="/class/index.jsp">
 <grammar version="1.0" mode="voice">
  [ (again) ]
 </grammar>
</link>
<link next="alav_intro.jsp">
  <grammar type="text/gsl">
    [ (reload) (dtmf-1 dtmf-1 dtmf-1) ]
  </grammar>
</link>
<link next="hangupandcleanup.jsp">
  <grammar type="text/gsl">
    [ (reset) ]
  </grammar>
</link>
<catch event="connection.disconnect.hangup">
    <data name="hangupandcleanup" src="http://alavs.techkwondo.com/hangupandcleanup.jsp"/>
</catch>
<catch event="error">
    <data name="hangupandcleanup" src="http://alavs.techkwondo.com/hangupandcleanup.jsp"/>
</catch>
<form id="question_1_friend_individual">
 <property name="timeout" value="15s"/>  
 <catch event="nomatch" cond="true" count="1">
<prompt bargein="true">Sorry, I can only recognize numbers between two and seven feet. Please try again.</prompt>
 </catch>
 <catch event="nomatch" cond="true" count="2">
<prompt bargein="true">Sorry, I didn't understand you. I am assuming you are three two.</prompt>
   <goto next="question_2_friend_individual.jsp?feet=3&amp;inches=2"/>
 </catch>
   <field name="F_1">
       <!-- Can you tell me how tall you are in feet and inches?.. -->
<prompt bargein="true">Can you tell me how tall you are in feet and
inches? For example, say five seven.</prompt>
   <grammar xml:lang="en-US" root="TOPLEVEL">
    <rule id="TOPLEVEL" scope="public">
      <item>
          <ruleref uri="#FEET"/>
      <tag>assign(feet $return)</tag>
          <ruleref uri="#INCHES"/>
      <tag>assign(inches $return)</tag>
      </item>
       <!-- TOP LEVEL RETURN -->
       <!--tag><![ CDATA[ <F_1 strcat($feet, $inches)> ]]></tag-->
       <tag><![CDATA[ <F_1 (strcat(strcat("feet=" $feet) strcat("&amp;inches=" $inches)))> ]]></tag>
     </rule>
   <rule id="FEET" scope="public">
     <one-of>
          <item> two 
            <tag> return (2) </tag>
          </item>
          <item> three 
            <tag> return (3) </tag>
          </item>
          <item> four 
            <tag> return (4) </tag>
          </item>
          <item> five 
            <tag> return (5) </tag>
          </item>
          <item> six 
            <tag> return (6) </tag>
          </item>
          <item> seven 
            <tag> return (7) </tag>
          </item>
       </one-of>
     </rule>
     <rule id="INCHES" scope="public">
        <one-of>
          <item> one 
            <tag> return (1) </tag>
          </item>
          <item> two 
            <tag> return (2) </tag>
          </item>
          <item> three 
            <tag> return (3) </tag>
          </item>
          <item> four 
            <tag> return (4) </tag>
          </item>
          <item> five 
            <tag> return (5) </tag>
          </item>
          <item> six 
            <tag> return (6) </tag>
          </item>
          <item> seven 
            <tag> return (7) </tag>
          </item>
          <item> eight 
            <tag> return (8) </tag>
          </item>
          <item> nine 
            <tag> return (9) </tag>
          </item>
          <item> ten 
            <tag> return (10) </tag>
          </item>
          <item> eleven 
            <tag> return (11) </tag>
          </item>
        </one-of>
      </rule>
   </grammar> 
   <filled>
     You said you are <value expr="$feet"/> <value expr="$inches"/> <value expr="F_1"/> tall.
     <!--goto expr="'question_2_friend_individual.jsp?'+F_1"/-->
   </filled>
  </field>
 </form>
   <!--choice next="question_2_friend_individual.jsp?feet=2&amp;inches=7">2 feet 7 inches</choice-->
<!--/menu-->
<form>
 <block>
    <data name="hangupandcleanup" src="http://alavs.techkwondo.com/hangupandcleanup.jsp"/>
 </block>
</form>
</vxml>

Post a comment