1

I am new to VXML and trying to construct an inline dtmf grammar that will allow any sequence of digits between 1 and 5 terminated with digit 6 be returned.

So all three of the following sequences should result in a fill:

1123236, 236, 55555555552342346

I've tried implementing the grammar like so:

<grammar mode="dtmf">
  <rule>
    <item>
      <item repeat"0-">1|2|3|4|5<item>6</item>
    </item>
  </rule>
</grammar>

and also like so:

<grammar mode="dtmf">
  <rule>
    <item repeat"0-">1|2|3|4|5</item>
    <item>6</item>
  </rule>
</grammar>

I am out of ideas and would greatly appreciate your help

dmitri
  • 3,183
  • 23
  • 28
Hendrik Botha
  • 13
  • 1
  • 4
  • Not clear what you are trying to achieve. Do you mean that when a user enters a single digit "6" the recogniser should return to the application a random sequence of 1-5 digits? – dmitri Oct 03 '14 at 03:57
  • The recognizer shouldn't return any random digits. It must collect all the valid (1,2,3,4 and 5) numbers the user entered and return to to the application as soon as it detects the user enters the number 6. The recognizer has no idea how many numbers will be entered and must return as soon as a 6 is entered. – Hendrik Botha Oct 03 '14 at 06:00

1 Answers1

2

Here is a grammar you may use:

<grammar mode="dtmf" version="1.0" root="oneToFiveSequence">

    <rule id="onetofive">
        <one-of>    
            <item>1</item>
            <item>2</item>
            <item>3</item>
            <item>4</item>
            <item>5</item>
        </one-of>   
    </rule>

    <rule id="oneToFiveSequence" scope="public" >
        <one-of>    
            <item repeat="0-">
                <ruleref uri="#onetofive"/>
            </item>     
        </one-of>   
    </rule>
</grammar>

To stop recognition with digit "6" set a property in your VXML form:

<property name="termchar" value="6" />

In the form while processing "filled" event you will know that the sequence was terminated with "6" so you may append it to data if it needs be.

An equivalent single rule grammar as requested in comments

 <grammar mode="dtmf" version="1.0" root="oneToFiveSequence">
    <rule id="oneToFiveSequence" scope="public" >
        <one-of>    
            <item repeat="0-">      
                <one-of>                
                    <item>1</item>          
                    <item>2</item>          
                    <item>3</item>          
                    <item>4</item>          
                    <item>5</item>          
                </one-of>               
            </item>                 
        </one-of>   
    </rule>
</grammar>

Both variants are tested with Holly Connects Voice Platform

Here is an app you may use for quick testing.

<?xml version="1.0" encoding="utf-8"?>
<vxml version="2.1" xmlns="http://www.w3.org/2001/vxml">
  <property name="inputmodes" value="dtmf"/>
  <form id="welcome">
    <field name="option">
      <property name="termchar" value="6"/>
      <grammar mode="dtmf" version="1.0" root="oneToFiveSequence">
          <rule id="oneToFiveSequence" scope="public" >
        <one-of>                
            <item repeat="0-">      
          <one-of>                      
              <item>1</item>                
              <item>2</item>                
              <item>3</item>                
              <item>4</item>                
              <item>5</item>                
          </one-of>                     
            </item>                 
        </one-of>               
          </rule>           
      </grammar>        
        <prompt>Enter digits</prompt>
      <filled>          
        <log> You entered <value expr="option"/></log>
      </filled>         
    </field>    
  </form>
</vxml>
dmitri
  • 3,183
  • 23
  • 28
  • My VXML browser (Voiceglue v0.14) does not support multiple rules in a grammar. Your answer looks right but I do not know how to test it so that I can tick the accepted mark. I should probably raise a separate question on how to achieve the same thing using a single rule (ie does not use the ruleref element). I did not know that this was a limitation of the browser when I posted the question. – Hendrik Botha Oct 07 '14 at 04:28