The inputmodes Property


Background

The inputmodes property determines which sources of input a VoiceXML script will accept. Its value is a space-separated list of which input modes will be allowed. The possible entries for this list are dtmf, voice, and tdd. Input from sources not included in the specified list will not be accepted.

This property causes the following behaviour: If inputmodes is set to dtmf, the VoiceXML script will simply ignore any voice input, regardless of what grammars for handling voice input are active. However, if inputmodes is set to voice, the script will not ignore dtmf input. Rather, dtmf input will generate nomatch events, regardless of what dtmf grammars are active.

Workarounds

The behaviour of simply ignoring dtmf input is not available, but there are a number of workarounds that can approximate it in many cases.

Substituting a noinput Event

Some users find having dtmf input in a voice-only script cause a noinput event preferable to having it cause a nomatch event. This substitution can be achieved by making a small addition to all nomatch event handlers.

Take some nomatch event handler:

  <nomatch>
    I am handling a nomatch event.
  </nomatch>

This handler could be made to throw a noinput event in response to all dtmf input by changing it to:

  <nomatch cond="application.lastresult$.inputmode == 'dtmf'">
    <throw event="noinput" />
  </nomatch>

  <nomatch cond="application.lastresult$.inputmode == 'voice'">
    I am handling a nomatch event.
  </nomatch>

Note that this does not prevent the dtmf input from barging in on the prompt. It just means that when dtmf input barges in on the prompt, the caller gets the behaviour defined by the noinput handler.

Using audiooffset

An VoiceXML script can check and see if input was voice or dtmf. When recorded audio prompts are being used, this ability can be used to make the script essentially ignore dtmf bargeins:

<?xml version="1.0"?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">

  <form>

    <var name="path" expr="'http://developer.voicegenie.com/libraries/audio/'"/>

    <script>
      <![CDATA[
        var startingOffset = 0;

        function getOffset() {
          return startingOffset;
        }
      
    </script>

    <block>
      This example shows how to use the audio offset attribute to
      cause a VoiceXML script to essentially ignore dtmf input.
      A recording will play, and stop when you say either "yes" or "no".
      Try those words, other words, and dtmf, and try both barging in
      and letting the recording finish.
    </block>

    <field name="f1">
      <grammar src="builtin:grammar/boolean"/>
      <prompt bargein="true">
        <audio expr="path + 'examples/books/frankenstein_desc.vox'"
               offsetexpr="startingOffset" />
      </prompt>

      <nomatch cond="application.lastresult$.inputmode == 'dtmf'">
        <assign name="startingOffset" expr="application.lastresult$.audiooffset" />
        <reprompt />
      </nomatch>

      <nomatch cond="application.lastresult$.inputmode == 'voice'">
        I'm sorry; I do not recognize that input.
        <assign name="startingOffset" expr="0" />
        <reprompt />
      </nomatch>

      <filled>
        Goodbye.
        <disconnect />
      </filled>
    </field>

  </form>

</vxml>	

If the caller barges in with dtmf input, the recording will pause while the interpreter checks this, and then continue on from where it left off.

Thanks to Francis Bakos for providing this tip.