Volume 1, Issue 3 - Mar. 2001
   
 

Your First Pizza

By Rob Marchand

(Continued from Part 1)

Changing Your Mind

What if the user decides to change his or her mind in the midst of ordering a pizza? VoiceXML includes built-in support for the cancel event as well. Cancel is thrown whenever the interpreter is collecting input, and the caller says 'cancel'. In our example, we're going to add an event handler at the form level. This means that the cancel event handler will be in scope for the entire form (i.e., all of the fields). So if the caller decides to back out, or retry while being prompted for the number of pizzas they want, they can say 'cancel', and the interpreter will generate the cancel event. Here is a fragment of the new application that includes this support:

<form>
      <catch event="cancel">
        Cancelling your order.
        <clear namelist="orderItem orderCount"/>
        <reprompt/>
      </catch>

      <block>
        <prompt>
          Welcome to the VoiceXML Review pizza franchise
        </prompt>
      </block>
.
.
.
</form>

 

The event handler can do any of a variety of things. In this case, we clear the contents of the form variables we might have collected thus far (orderItem, orderCount), and then inform the interpreter that it should reissue the prompts when next collecting input. The end result of this is that the form interpretation algorithm of the interpreter will start to collect the fields again. We might also have thanked the caller for calling us before hanging up, , or transferred them to an operator.

Although VoiceXML 1.0 defines behavior for 'help', 'cancel', and 'exit', there is no way to turn off these global commands. A future version of the language, and a number of current interpreters, should allow you to turn off this default behavior using the new universals property.

Improving Accessibility

What if the system is having difficulty recognizing the callers input? It is always a good idea to have a fallback to DTMF (touch-tone) input, if feasible. In this case, we can add a DTMF grammar to the item selection field:

<dtmf>
   1 {pizza} | 2 {drinks} | 3 {salad} | 4 {wings}
</dtmf>

  


The dtmf tag defines acceptable DTMF input for the field. In this case, we're also returning tags so that the results are a bit easier to deal with. So, when the caller types '1' on their phone's keypad, the field variable will receive the value 'pizza'.

How about the second field? Well, with the built in grammar types (such as number or digit), we get both ASR and DTMF grammars, so we don't have to define a DTMF grammar. In other words, we get one for free! We could also use the option tag in the first field to provide similar functionality. We'll have a peek at this next month.

The Current Version

Here is a complete version of the current script, with the enhancements we've made:

<?xml version="1.0"?>
<vxml version="1.0">
<meta name="MAINTAINER" content=""/>
<property name="caching" value="safe"/>

<form>
     <catch event="cancel">
        Cancelling your order.
        <clear namelist="orderItem orderCount"/>
        <reprompt/>
     </catch>

     <block>
        <prompt>
          Welcome to the VoiceXML Review pizza franchise.
        </prompt>
     </block>

     <field name="orderItem">

        <grammar>
          pizza | drinks | salad | wings
        </grammar>

        <dtmf>
          1 {pizza} | 2 {drinks} | 3 {salad} | 4 {wings}
        </dtmf>

        <prompt>
          What would you like to order?
          We have pizza, drinks, salad or wings.
        </prompt>

        <noinput>
          Say pizza, drinks, salad, or wings.
        </noinput>

        <nomatch>
          You can say pizza, drinks, salad, or wings.
        </nomatch>

        <help>
          <reprompt/>
        </help>

      </field>

      <field name="orderCount" type="number">

        <prompt>
          How many <value expr="orderItem"/> would you like?
        </prompt>

        <noinput>
          I need to know how many <value expr="orderItem"/> you want.
        </noinput>

        <nomatch>
          Please say how many <value expr="orderItem"/> you want.
        </nomatch>

        <help>
          You should tell me how many items you want.
        </help>

      </field>

      <block>
        One moment while I add
            <value expr="orderCount"/>
            <value expr="orderItem"/>
        to your order.

        <submit next="/cgi-bin/pizzaCart.pl" namelist="orderItem orderCount"/>
      </block>
</form>
</vxml>        

 

Further Improvements

Here are some actions we could take to improve the current version:

  • Alter the prompts to inform the user that they can use DTMF;
  • Make use of different prompts to better inform the caller of what their options are;
  • Handle 'cancel' in a more reasonable way.

And I'm sure you can think of lots of other things.

What's Next

Next month we're going to build this application out, and take advantage of even more VoiceXML features. While we may never show a profit on our pizza dot-com, we will be learning more about VoiceXML!

back to the top

 

Copyright © 2001 VoiceXML Forum. All rights reserved.
The VoiceXML Forum is a program of the
IEEE Industry Standards and Technology Organization (IEEE-ISTO).