VoiceXML 2.1 Development Guide Home  |  Frameset Home

  SRGS:SISR Grammar Tips & Tricks  |  TOC  |  SRGS-SISR: Built-in Grammars  

grXML DTMF grammars

Since there are many ways to write an XML- DTMF grammar, there should probably be a good starting point for all us folks ready to switch over from the Good Old Days of GSL. As the W3C Grammar specification can indeed be a bit murky when it comes to a few finer points of grammar design, there is a bit of leeway in regards to what certain platform vendors allow, especially when it comes to DTMF grammars. By taking the following examples as Gospel, your grammar files will retain maximum compliance to the spec, and still be able to have multi-platform compatibility should you decide to switch to another voice browser.

To start off with, let's take a look at a standard GrXML grammar that uses DTMF as it's mode of input:


<grammar xml:lang="en-US" root = "TOPLEVEL">
    <rule id="TOPLEVEL" scope="public">
<one-of>
          <item> dtmf-1 <tag> out.F_1="1";  </tag> </item>
          <item> dtmf-2 <tag> out.F_1="2";  </tag> </item>
          <item> dtmf-star <tag> out.F_1="3";  </tag> </item>
        </one-of>
</rule>
</grammar>


Say, that looks alright, doesn't it? Well, yes, and no. While this grammar will work, it isn't really up to par with the spec. Let's take another look at a compliant grammar, with the significant differences highlighted for convenience:


<grammar xml:lang="en-US" root = "TOPLEVEL" mode="dtmf" >
    <rule id="TOPLEVEL" scope="public">
<one-of>
          <item> 1 <tag> out.F_1="1";  </tag> </item>
          <item> 2 <tag> out.F_1="2";  </tag> </item>
          <item> * <tag> out.F_1="3";  </tag> </item>
        </one-of>
</rule>
</grammar>


The first thing to note is that we have explicitly set the 'mode' attribute of the <grammar> element. This is good coding practice, and really should be made a habit if we don't want to look like hacks. Just imagine what The Neighbors would think if they saw you write a grammar without the 'mode' being set....The Horror!

Secondly, you'll realize that we haven't declared the utterance as 'dtmf-(number)'......that stuff is for amateurs. Instead, we are going to follow the spec, and declare these by their pure numeric values. In the long run, this saves us a bit of code, and makes us all compliant-like to the specification.


So Who Cares About Being Compliant, Anyhow?

While it's certainly healthy to Question Authority, you should care about being compliant to the W3C spec. Like the idea of revisiting code that you wrote two years ago so that you can make it work on a new platform? Neither do we, and sticking to the spec allows you to 'keep it real' and not have to worry about porting code later on, homie. We write sample code that sticks close to the way things should be done to save you hassle down the road.


Mixed-Mode Grammars

Okay, so what if you need a grammar that accepts both dtmf AND voice input? Well, hacks would undoubtedly do something like this:


<grammar xml:lang="en-US" root = "TOPLEVEL">
    <rule id="TOPLEVEL" scope="public">
<one-of>
          <item> 1 <tag> out.F_1="1";  </tag> </item>
          <item> yes <tag> out.F_1="1";  </tag> </item>
          <item> 2<tag> out.F_1="2";  </tag> </item>
          <item> no <tag> out.F_1="2";  </tag> </item>
        </one-of>
</rule>
</grammar>


But the compliant way to do this would be to break up our grammars, and have two grammars active. Note that in the case of external grammar structures, multiple grammar references <grammar src> will be needed within your voice reco fields:


<grammar xml:lang="en-US" root = "TOPLEVEL" mode="dtmf" >
    <rule id="TOPLEVEL" scope="public">
<one-of>
          <item> 1 <tag> out.F_1="yes";  </tag> </item>
          <item> 2 <tag> out.F_1="no";  </tag> </item>
        </one-of>
</rule>
</grammar>



<grammar xml:lang="en-US" root = "TOPLEVEL" mode="voice" >
    <rule id="TOPLEVEL" scope="public">
<one-of>
          <item> yes <tag> out.F_1="yes";  </tag> </item>
          <item> no <tag> out.F_1="no";  </tag> </item>
        </one-of>
</rule>
</grammar>




Also note that if we try to get clever, and mix up our syntax, then errors will definitely crop up. For instance, the following will have compilation errors, as having a 'mode' set to 'dtmf' and explicitly having 'dtmf-1' or other derivatives will not be stomached by the browser:


<grammar xml:lang="en-US" root = "TOPLEVEL" mode="dtmf" >
    <rule id="TOPLEVEL" scope="public">
<one-of>
          <item> dtmf-1 <tag> out.F_1="one";  </tag> </item>
          <item> dtmf-2 <tag> out.F_1="two";  </tag> </item>
          <item> dtmf-star <tag> out.F_1="star";  </tag> </item>
        </one-of>
</rule>
</grammar>







  ACCOUNT LOGIN
Username:  
Password:  
  You must login with your Voxeo developer account prior to posting or editing your existing posts. If you aren't a member of Voxeo's developer community, click here to register.
  ANNOTATIONS: EXISTING POSTS
beta
3/22/2006 11:30 AM (EST)
I'm currently testing on Voxeo Prophecy.
It seems that with mode="dtmf" in an embedded gramamr

<item> dtmf-1 <tag> <![CDATA[  <F_1 "one"> ]]>  </tag> </item>
works fine, which contradicts the last statement
"Also note that if we try to get clever, and mix up our syntax, then errors will definitely crop up"

but
<item> 1 <tag> <![CDATA[  <F_1 "one"> ]]>  </tag> </item>
as stated above, which should work, does not work.

I tried to use
<item> dtmf-1 <tag> <![CDATA[  <F_1 "one"> ]]>  </tag> </item>
without  mode="dtmf" and this works fine as well.

I'm confused.
MattHenry
3/22/2006 2:43 PM (EST)


Hi there,

I should point out that this set of documentation was written for the Voice Center 5.5 release, and is not meant to be used specifically for Prophecy application development. As such, discrepancies will exist between the documentation, and how Prophecy behaves.

As Prophecy is still a Beta product, we have not written a dedicated set of documentation for it, but we plan on doing so sometime in the next few months.

Hope this clears things up,

~Matthew Henry

yana
6/27/2006 7:38 AM (EDT)
I still don't understand how DTMF grammar looks for any x digits (for example - enter you ID)
MattHenry
6/27/2006 12:56 PM (EDT)


Hello Yana,

As I understand it, you want to capture a variable length digit input from your callers. Your choices are as follows:


1) Create a grxml grammar using one-of/item/ruleref that allows you to capture the string. Examples that illustrate the general subgrammar structure to use can be found in the below link:


http://docs.voxeo.com/voicexml/2.0/grxmlsubg.htm


2) Use the predefined 'num2sixteen' GSL grammar in our downloadables section:

http://evolution.voxeo.com/library/grammar/library.jsp


3) Leverage the field type grammars, as illustrated in the below link:

http://docs.voxeo.com/voicexml/2.0/gslbuiltins.htm


Chances are that if you find yourself stuck on a particular concept specific to VXML, our documentation has this fully detailed already, and more than likely has sample code that illustrates this plainly to minimize confusion.


Regards,

~Matthew Henry





Jenny
1/10/2007 12:43 AM (EST)
Hi All
  I need a grxml grammar to accept 4 digits from the user
Can any body help ASAP????


Thanks in advance
jbassett
1/10/2007 3:58 AM (EST)
Hello,

Have you tried something like utilizing the built-in field type grammars like the example below?

<field name="pin" type="digits?length=4">

Let me know if this is what you were looking for.

Thanks
Jesse Bassett
Voxeo Support
Jenny
1/10/2007 5:13 AM (EST)
Thanks Jesse..
Actually I want grxml grammar to work in different platform.
I could not use built-in types.

My expectation solved with the following grammar

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN" "http://www.w3.org/TR/speech-grammar/grammar.dtd">
<grammar version="1.0" root ="Pin" xmlns="http://www.w3.org/2001/06/grammar">
   
    <rule id = "Pin" scope ="public">
    <item repeat = "4"><ruleref uri="#digit"/></item>
    </rule>
<rule id = "digit">
<one-of>
<item>one</item>
<item>two</item>
<item>three</item>
<item>four</item>
              ......

</one-of>
    </rule>
</grammar>


Thanks,
Jenny
jbassett
1/10/2007 6:51 AM (EST)
Hello,

I am glad things worked out for you. I will go ahead and mark this ticket as closed. Feel free to re-open it, or ask any further questions.

Thanks
Jesse Bassett
Voxeo Support
Jenny
1/25/2007 2:17 AM (EST)
Hi,

Thanks for ur support. As per my requirement I modified the previous grammar to either accept any 4 digit number or "0" as user input.

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN" "http://www.w3.org/TR/speech-grammar/grammar.dtd">
<grammar version="1.0" root ="Pin" xmlns="http://www.w3.org/2001/06/grammar">
 
    <rule id = "Pin" scope ="public">
    <one-of>
          <item repeat = "4"><ruleref uri="#digit"/></item>
          <item>0</item>
    </one-of>
    </rule>

    <rule id = "digit">
          <one-of>
              <item>one</item>
              <item>two</item>
              <item>three</item>
              <item>four</item>
              ......

          </one-of>
    </rule>

</grammar>



when I am using with in vxml as inline grammar within "field" element it is ok. But if I want to use this grammar in some other tool so I want to return back the slots filled. The slot might be either any four digit number or "0".

Using Tag with in Grammar how could I achieve that?

I need to collect the user values in particular slot...or particular variable...
How could I do that?




Jenny
2/2/2007 2:36 AM (EST)
Hi,

Can any body tell me with one user input how can i fill two slots?
if we are getting the input as "12 Main street" how can I fill the slots <streetNumber> as "12" and <streetName> as "Main Street"

This grammar need to be dynamic enough to accept different street numbers and street names?

I need this to be a grxml grammar..
Can anybody help.

Thanks in Advance,
Jenny
jefo12
6/24/2008 2:06 AM (EDT)
how to enable dynamic grammar using dtmf...



<prompt> The appointments are </prompt>


          <foreach item="applist" array="myarr">
            <prompt><value expr="applist"/><break/></prompt>
        </foreach>

//palys all the appointments the callerid has.....

<prompt> Do you want to cancelorreschedule any of those appointments say cancel or
    reschedule or
    if you want to take an new appointment say schedule..
</prompt>
If the user selects cancel...then
<prompt>To cancel any of the appointments press the corresponding dtmf button to cancel </prompt>
//how can i do this dynamiclaly....

plz suggest me.....
vikesh
7/9/2008 8:10 AM (EDT)
Hi,
I need to take username (e.g xyz123) and password input through touch tone (DTMF), how can I do that, that user enter his username and press # to end it and password and store it in variable to submit it in database. I read the grammar rules but didn't understand how to do that.
Please help, as i have to complete my task very soon.

michael_ty
2/3/2009 10:40 PM (EST)
Hello.

I need recognized 6-digits account number. But if user press the asterisk in middle of account number I should redirect him to the operator immidiatly.

Can anyone help me?
kenny2000
3/1/2009 6:55 PM (EST)
I am currently testing an Application that will verify a user log in name with inline grammer,"<form id="get_info">
  <catch event="exit">
    <reprompt/>
    <goto nextitem="confirm_exit"/>
  </catch>
    <block>Wellcome to gmobile lottery in association with citi bank.
  winners of gmobile lottery draw must claim
  and transfer there funds here.</block>
    <field name="name_type">
      <prompt count="1">What is your log on name?</prompt>
      <prompt count="2">Your log on name please?</prompt>
        <!-- This is an inline grammar. -->
      <grammar>
          <rule id="r2" scope="public">
            <one-of>
            <item>Ken</item>
            <item>john</item>
            </one-of>
          </rule>
      </grammar>
        <filled>
            <if cond="name_type != 'ken' || name_type != 'john'">
                Please say the correct log on name.
                <clear namelist="name_type"/>
              <else/>
        You have been logged in as <value expr="name_type"/> and your account is one million dollar.
          </if>
        </filled>
    </field>
      <prompt>We are going to proceed on the fund transfer into your bank account.
        </prompt>
    <field name="bank_number" type="digits">
      <prompt count="1">What is your bank account number?</prompt>
        <prompt count="2">bank account number?</prompt>
          </field>
            <field name="confirm" type="boolean">
          <prompt>
              <voice gender='female' age='26'>
                The account number is <value expr="bank_number"/>
              Is this correct?
              </voice>
          </prompt>
          </field>
        <block>For the final money transfer. A transfer pin code is required</block>
          <field name="tranfer_pin" type="digits">
            <prompt count="1">
                Enter your transfer pin code please.</prompt>
            <prompt count="2">transfer pin code?</prompt>
                <grammar mode="dtmf">
                  <rule id="root" scope="public">
                    <one-of>
                      <item> 193 </item>
                      <item> #23 </item>
                    </one-of>
                  </rule>
                </grammar>
                  <filled>
                      <if cond="tranfer_pin != '193' || tranfer_pin != '#23'">
                      Invalid pin. Please consult the gmobile for the code.
                      <else/>
                        Account logged out
                      </if>
                    </filled>
            </field>
  </form>
</vxml> but I was getting an error that states:[Error]:The content of element type "form" must match "(grammar|catch|help|noinput|nomatch|error|filled|initial|object|link|property|record|script|subdialog|transfer|block|field|var|data|bevocal:dbdata|bevocal:listen|register|bevocal:register|verify|bevocal:verify|bevocal:enroll)*".


Please klindly advice me on the track to follow inorder to avoid the error



sreenivasan
3/6/2009 2:07 PM (EST)
Hi,
  In the below grammar snippet, how do I change have a varible for repeat value.

    <rule id = "Pin" scope ="public">
    <one-of>
          <item repeat = "4"><ruleref uri="#digit"/></item>
          <item>0</item>
    </one-of>
    </rule>


Instead of always having the repeat to tbe 4, I need to use variable (different for different clients) whose value comes from a database

Thanks,
Sreeni.
quaseer
6/5/2009 10:04 AM (EDT)
I trying to create a DTMF GRXML grammar which will take an input of a date in form of MMDDYYYY as well as take input of 0.
Also, the date is greater than 1850.
Can someone please help me...
mikethompson
11/5/2009 4:07 PM (EST)
Hello,

I happen to have a straight forward GRXML DTMF grammar I can share with you which achieves this.  I will paste it for you below:

[code]
<?xml version= "1.0"?>
<grammar xmlns="http://www.w3.org/2001/06/grammar" xml:lang="en-US" root="NUMBER" mode="dtmf">

<rule id="NUMBER" scope="public">

        <item repeat="0-8">
            <item>
<ruleref uri="#ZERO_TO_NINE_1"/>

             
            </item>
            <tag> out = out + rules.ZERO_TO_NINE_1.subSlot </tag>
        </item>
    </rule>


<rule id="ZERO_TO_NINE_1"> 
<one-of>
<item>0 <tag>out.subSlot="0";</tag></item>
<item>1 <tag>out.subSlot="1";</tag></item>
<item>2 <tag>out.subSlot="2";</tag></item>
<item>3 <tag>out.subSlot="3";</tag></item>
<item>4 <tag>out.subSlot="4";</tag></item>
<item>5 <tag>out.subSlot="5";</tag></item>
<item>6 <tag>out.subSlot="6";</tag></item>
<item>7 <tag>out.subSlot="7";</tag></item>
<item>8 <tag>out.subSlot="8";</tag></item>
<item>9 <tag>out.subSlot="9";</tag></item>

</one-of>
</rule>
</grammar>
[/code]

This will take your digit input for MMDDYYYY, and allow the users to simply press 0.

Hope this helps,
Mike Thompson
Voxeo Corporation
muks
6/14/2010 7:58 AM (EDT)
In our application, we are going to be getting a lot of data as DTMF. The data is going to be dynamic and too big, so it is impossible for me to list out the data to match.

In such a scenario, how do I ensure that the data stream is ended so that I can start processing the data.

I was thinking of having a pattern that would represent end of data and once i get that, it means that the entire data stream is got and we can start processing.

In order to do this, we should be able to match pattern matching of a part of the data. Is this possible using grXML?

e.g :
Incoming data : 123456789ABCD*#13223232*#*#*#
End of stream delimiter: *#*#*#

Can you please suggest a better solution?

Thanks
Muks
VoxeoDante
6/14/2010 9:56 AM (EDT)
Hello,

The way that DTMF, and even voice processing works, you would have to allow the user to complete the input on their own.  The issue here is that you will not get the result from the grammar until the user has finished input.  They need to signal the end of input in one of two ways, either they need to hit some termination character, or end input for long enough for an input to fire.  In your case, we would need to have then simply stop entering digits until the timeout fires as it looks like you want to use all of the Keys.

The good news here is that I believe that we can do what you want with GRXML.  My idea here would be to have a grammar that allowed the user to enter any key a number of time (up to the maximum number of Digits you would allow.)  The good thing about GRXML and Grammars in general is that they allow you to write a very simple rule that takes in any key press, then repeat that rule any number of times.  With that method, you would allow the user to enter what they need to, then post process the data.

The below grammar should allow any DTMF input up to 20 times.  Note that you will need to set the termchar property to something like dtmf-A in order to use # inside of your grammar.
[code]
<grammar xml:lang="en-US" root = "TOPLEVEL" mode="dtmf">
<rule id="TOPLEVEL" scope="public">
        <item repeat="0-20">
<one-of>
<item> dtmf-1</item>
<item> dtmf-2</item>
<item> dtmf-3</item>
<item> dtmf-4</item>
<item> dtmf-5</item>
<item> dtmf-6</item>
<item> dtmf-7</item>
<item> dtmf-8</item>
<item> dtmf-9</item>
<item> dtmf-pound</item>
<item> dtmf-star</item>
</one-of>
        </item>
    </rule>
</grammar>
[/code]

Please let me know if there are any remaining questions.

Regards,
Dante Vitulano
Customer Engineer II
Voxeo Customer Obsession Team
vishnumishra88
7/8/2010 5:16 AM (EDT)
Hi,

Need urgent help...

If we want to play a prompt on the basis of user dtmf input(Key Input through phone 1 to 5) when already one prompt is playing then what procedure should be followed...
voxeoJeffK
7/8/2010 6:53 AM (EDT)
Hello,

If your first prompt is in a <field> with a grammar that accepts those numbers, the user will be able to barge-in with input provided the barge-in is set to true (the default). In the <filled> of that field then play the next prompt you wish, or <goto> another section, and play the prompt from there.

If you're question also concerns how to accept that input, do you mean that you want to accept 1-5 of any digits, or do you mean to accept only one digit of keys 1-5?

Regards,
Jeff Kustermann
Voxeo Support
ssa_peregrin
10/19/2010 11:59 AM (EDT)
Hi guys,
I'm having some trouble accomplishing a grammar with a certain behavior.

I'm looking to be able to input as many as needed DTMF 0-9 + *, using # as a 'termchar' at any point in the field.

What I have works for the most part, but if # is hit prior to any DTMF entries the generic error message is given 'I did not understand what you said please try again'.  This pressing # prior to any DTMF can be done indefinitely, which is the opposite of what I want to occur.

What I have so far:

[code]
<form id="dummy">
<field name="enterNum">
<property name="termchar" value="#"/>

<prompt> Enter some numbers </prompt>

<grammar mode="dtmf" root="dtmf_entry" version="1.0" xml:lang="en-US">

<rule id="dtmf_entry" scope="public">
<one-of>
<item repeat="0-75">
<ruleref uri="#digit"/>
</item>
</one-of>
</rule>
<rule id="digit">
<one-of>
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
<item>*</item>
</one-of>
</rule>
</grammar>

<noinput>
<disconnect />
</noinput>

<filled>
<assign name="passedField" expr="enterNum" />

<submit next="doc2.cfm" namelist="face" method="post"/>

</filled>

</field>
</form>
[/code]

if I enter any digit(s), then hit # the expected behavior occurs, the field immediately terminates and forwards to doc2.cfm, where I read and confirm the DTMF entered.  But again, if # is pressed first the generic "I did not understand..." is played, and this can be repeated indefinitely by continually pressing #.

Any help is appreciated!
Thanks,
Russ
VoxeoDustin
10/19/2010 5:55 PM (EDT)
Hey Russ,

Here's a grXML digit grammar of mine I modified for you that ought to do the trick:

<grammar version="1.0" xmlns="http://www.w3.org/2001/06/grammar" root="TOPLEVEL" mode="dtmf">

  <rule id="TOPLEVEL">
    <tag> out.main = "" </tag>
    <one-of>
    <item repeat="0-75">
      <ruleref uri="#DIGITS"/>
      <tag> out.main = out.main + rules.DIGITS.slot </tag>
    </item>
    <item>
    </one-of>
  </rule>

  <rule id="DIGITS" scope="public">
    <item>
          <one-of>
            <item> 1 <tag> out.slot="1" </tag></item>
            <item> 2 <tag> out.slot="2" </tag></item>
            <item> 3 <tag> out.slot="3" </tag></item>
            <item> 4 <tag> out.slot="4" </tag></item>
            <item> 5 <tag> out.slot="5" </tag></item>
            <item> 6 <tag> out.slot="6" </tag></item>
            <item> 7 <tag> out.slot="7" </tag></item>
            <item> 8 <tag> out.slot="8" </tag></item>
            <item> 9 <tag> out.slot="9" </tag></item>
            <item> 0 <tag> out.slot="0" </tag></item>
        </one-of>
    </item>
  </rule>
</grammar> 


Within your VoiceXML <filled> you can grab the result with the variable lastresult$.interpretation.main, which is the concatenation of all input digits.

Let me know if this does the trick for you.

Regards,
Dustin Hayre
Solutions Engineer
Voxeo Corporation
ssa_peregrin
10/20/2010 9:19 AM (EDT)
Hey Dustin, it looks like there was an additional <item> tag in there below the </item>.  I took that out, and in addition added

<item> * <tag> out.slot="*" </tag></item>

which made the final code:

<grammar version="1.0" xmlns="http://www.w3.org/2001/06/grammar" root="TOPLEVEL" mode="dtmf">

<rule id="TOPLEVEL">
<tag> out.main = "" </tag>
<one-of>
<item repeat="0-75">
<ruleref uri="#DIGITS"/>
<tag> out.main = out.main + rules.DIGITS.slot </tag>
</item>
</one-of>
</rule>

<rule id="DIGITS" scope="public">
<item>
<one-of>
<item> 1 <tag> out.slot="1" </tag></item>
<item> 2 <tag> out.slot="2" </tag></item>
<item> 3 <tag> out.slot="3" </tag></item>
<item> 4 <tag> out.slot="4" </tag></item>
<item> 5 <tag> out.slot="5" </tag></item>
<item> 6 <tag> out.slot="6" </tag></item>
<item> 7 <tag> out.slot="7" </tag></item>
<item> 8 <tag> out.slot="8" </tag></item>
<item> 9 <tag> out.slot="9" </tag></item>
<item> 0 <tag> out.slot="0" </tag></item>
<item> * <tag> out.slot="*" </tag></item>
</one-of>
</item>
</rule>
</grammar>

This however appears to have the same behavior that my initially posted code did.  A # pressed as a termchar does work, but only after at least one other NON termchar has been pressed.  I need pressing the termchar at any time to count as a filled.  Currently the termchar acts as a filled when at least one other number has been pressed, this is similar to what i need, however i need the # to count as a filled if pressed <i>prior</i> to any other keys, basically a way to "<filled>" the field or bypass it by means of a # key.

Does that make any sense?  Is it possible to accomplish this?

Thanks,
Russ

VoxeoDustin
10/20/2010 5:06 PM (EDT)
Hey Russ,

Sure. You'll just need to remove # as the default VXML term character:

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

This will map the term character to an extended DTMF character that is not used. Then, in your grammar, you will need to add an extra item to allow the # to terminate input. Specifying it at as an item in the root rule as I have will not include the # in the returned interpretation:

<grammar version="1.0" xmlns="http://www.w3.org/2001/06/grammar" root="TOPLEVEL" mode="dtmf">

<rule id="TOPLEVEL">
<tag> out.main = "" </tag>
<one-of>
<item repeat="0-75">
<ruleref uri="#DIGITS"/>
<tag> out.main = out.main + rules.DIGITS.slot </tag>
</item>
<item repeat="0-1">
#
</item>
</one-of>
</rule>

<rule id="DIGITS" scope="public">
<item>
<one-of>
<item> 1 <tag> out.slot="1" </tag></item>
<item> 2 <tag> out.slot="2" </tag></item>
<item> 3 <tag> out.slot="3" </tag></item>
<item> 4 <tag> out.slot="4" </tag></item>
<item> 5 <tag> out.slot="5" </tag></item>
<item> 6 <tag> out.slot="6" </tag></item>
<item> 7 <tag> out.slot="7" </tag></item>
<item> 8 <tag> out.slot="8" </tag></item>
<item> 9 <tag> out.slot="9" </tag></item>
<item> 0 <tag> out.slot="0" </tag></item>
<item> * <tag> out.slot="*" </tag></item>
</one-of>
</item>
</rule>
</grammar>

Let me know if this does the trick for you.

Regards,
Dustin Hayre
Solutions Engineer
Voxeo Corporation
ssa_peregrin
10/21/2010 8:06 AM (EDT)
Hey Dustin, this last one was very close.  I am now able to use a # to get an immediate <filled> if no DTMF have been input.  However, I am no longer able to use a # to end the dialog after entering a number.

1. Enter some numbers:
#

>>You said [nothing]
(lastresult should be '')

2. Enter some numbers:
123 [wait 5 seconds]

>>You said 123
(lastresult should be 123)

3. Enter some numbers:
123#

>>You said 123
(lastresult should be 123)

The initial grammar I posted and the one prior to the last that you posted accomplished 2 and 3, but not 1.  The last grammar you posted accomplished 1 and 2, but not 3.  I basically need # to count as a <filled> no matter what (if anything) was entered prior to it.

Sorry for all the confusion, grammars are quite new to me and it doesn't seem like anyone has wanted exactly this in a grammar before, or I have been uncertain on how to find it :)

Is there anything further that can be done to accomplish all three scenarios?
ssa_peregrin
10/21/2010 8:07 AM (EDT)
I forgot to mention, scenario 3 from the previous grammar returned a 'I did not understand what you said, please try again'
VoxeoDustin
10/21/2010 9:30 AM (EDT)
Hey Russ,

Sorry about that, the <one-of> in the root rule was the culprit there. I ran a few quick test calls against this version, and it should work the way you're expecting:

<grammar version="1.0" xmlns="http://www.w3.org/2001/06/grammar" root="TOPLEVEL" mode="dtmf">

<rule id="TOPLEVEL">
<tag> out.main = "" </tag>
<item repeat="0-75">
<ruleref uri="#DIGITS"/>
<tag> out.main = out.main + rules.DIGITS.slot </tag>
</item>
<item repeat="0-1">
#
</item>
</rule>

<rule id="DIGITS" scope="public">
<item>
<one-of>
<item> 1 <tag> out.slot="1" </tag></item>
<item> 2 <tag> out.slot="2" </tag></item>
<item> 3 <tag> out.slot="3" </tag></item>
<item> 4 <tag> out.slot="4" </tag></item>
<item> 5 <tag> out.slot="5" </tag></item>
<item> 6 <tag> out.slot="6" </tag></item>
<item> 7 <tag> out.slot="7" </tag></item>
<item> 8 <tag> out.slot="8" </tag></item>
<item> 9 <tag> out.slot="9" </tag></item>
<item> 0 <tag> out.slot="0" </tag></item>
<item> * <tag> out.slot="*" </tag></item>
</one-of>
</item>
</rule>
</grammar>


Regards,
Dustin Hayre
Solutions Engineer
Voxeo Corporation
ssa_peregrin
10/21/2010 9:43 AM (EDT)
That seems to have done it, thanks for the assistance and patience :)

VoxeoDustin
10/21/2010 9:48 AM (EDT)
Hey Russ,

Don't mention it, always happy to help. :) Don't hesitate to let me know if you have any other questions.

Cheers,
Dustin Hayre
Solutions Engineer
Voxeo Corporation
monica.r.costa
11/18/2010 7:59 AM (EST)
Good morning,

I'm doing a code that recognizes that the User type (DTMF) and would recognize only the numbers 0 to 9.
The characters * and # I would not recognize, I hope that if the User typed it returned me error (UED).
I got that * he did, but the # it converts to an ASCII character.

How can I do?
Following is the snippet of code I made:

<?xml version="1.0"?>
<vxml version="2.0" application="http://##MY_IP##/cgi-bin/vxml_server.cgi?fluxo=1" xmlns="http://www.w3.org/2001/vxml" xml:lang="pt-BR">

  <var name="CallId" expr="##CallId##"/>
  <property name="inputmodes" value="dtmf"/>
<property name="termchar" value="*"/>
  <form id="SolicitaCEP">
    <block>
      <prompt>
        <audio expr="PromptPath + '##PROMPT1##'"/>
      </prompt>
    </block>
    <field name="numero" type="digits?length=8">
<nomatch>
<assign name="routing" expr="'UED'"/>
<submit next="vxml_server.cgi" method="get" namelist="CallId routing"/>
</nomatch>
<noinput>
<assign name="routing" expr="'UED'"/>
<submit next="vxml_server.cgi" method="get" namelist="CallId routing"/>
</noinput>
<filled> 
        <assign name="routing" expr="'null'"/>
        <submit next="vxml_server.cgi" method="get" namelist="CallId numero routing"/>
      </filled>
  </field>
  </form>
</vxml>

Thank you.
VoxeoDustin
11/18/2010 11:12 AM (EST)
Hey Monica,

The termchar property will only allow you to specify one termination character. If you want to disallow certain input, you may want to specify a grammar instead of the built-in digits grammar, then disable the termchar property:

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

Then:

<grammar version="1.0" xmlns="http://www.w3.org/2001/06/grammar" root="TOPLEVEL" mode="dtmf">

<rule id="TOPLEVEL">
<tag> out.main = "" </tag>
<item repeat="1-8">
<ruleref uri="#DIGITS"/>
<tag> out.main = out.main + rules.DIGITS.slot </tag>
</item>
</rule>

<rule id="DIGITS" scope="public">
<item>
  <one-of>
<item> 1 <tag> out.slot="1" </tag></item>
<item> 2 <tag> out.slot="2" </tag></item>
<item> 3 <tag> out.slot="3" </tag></item>
<item> 4 <tag> out.slot="4" </tag></item>
<item> 5 <tag> out.slot="5" </tag></item>
<item> 6 <tag> out.slot="6" </tag></item>
<item> 7 <tag> out.slot="7" </tag></item>
<item> 8 <tag> out.slot="8" </tag></item>
<item> 9 <tag> out.slot="9" </tag></item>
<item> 0 <tag> out.slot="0" </tag></item>
  </one-of>
</item>
</rule>
</grammar>

Regards,
Dustin Hayre
Solutions Engineer
Voxeo Corporation
vishaljha
1/13/2011 3:55 AM (EST)
When I am running this example it is uttering object object when I prompt the field value in filled section.

Please let me know.
vishaljha
1/13/2011 4:51 AM (EST)
Hi,

I need to take alphanumeric input. Let say I need to have the value "BAD2". So I need to input it like '222#22#33#2##'.


I want to passs this input to a javascript function to parse the '222#22#33#2##' and will return BAD2. Please let me know how this can be achieved.

If you have some other solution to achive this please let me know.
I need a sample to understand this and will modify according to my further requirenments.

Thanks in advance.
Vishal
VoxeoDustin
1/13/2011 8:11 AM (EST)
Hey Vishal,

To grab the returned value from the above grammar, you can use the variable [b]lastresult$.interpretation.main[/b], as [b]main[/b] is the slot name used in the grammar.

For your second question, I'm not sure I understand the logic you'd want to use in your function. If you could give us a better idea of what you'd like to achieve, we may be better able to assist you.

Regards,
Dustin Hayre
Solutions Engineer
Voxeo Corporation

[url=http://voxeo.com/prophecy]Download Prophecy 10[/url] | [url=http://docs.voxeo.com/prophecy/10.0/home.htm]Prophecy 10 Docs[/url]

  SRGS:SISR Grammar Tips & Tricks  |  TOC  |  SRGS-SISR: Built-in Grammars  

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