We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

Limit menu input to a single digit?

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Re: Limit menu input to a single digit?

Post by support »

Yes, you must specify in your grammar that you expect a one digit input. There are many ways to do this, but here an example:

Code: Select all

<form id="my_form">
  <field name="my_field" type="digits?length=1">
    <prompt>
      Your prompt here.
    </prompt>

    <filled>
      One digit was entered.
    </filled>

  </field>
</form>
You can find more info about grammars here: http://www.plumvoice.com/docs/dev/voicexml:tags:grammar

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Re: Limit menu input to a single digit?

Post by support »

In your code example, you are loading two grammars. The 'type="digits?length=1"' is a built-in grammar (see: http://www.plumvoice.com/docs/dev/devel ... n_grammars), and then you declared your own JSGF grammar below that. You should only do one or the other as now your application is checking the user's input against two different grammars, which may be causing the small delay.

Also take care to declare the grammar rules within parenthesis, like this:

Code: Select all

<field name="confirm">
    <grammar type="application/x-jsgf" mode="dtmf">(1|2|3)</grammar>

    <prompt>
      You entered <value expr="morningReading"/>. If that's correct, press 1, otherwise press 2.
    </prompt>

Post Reply