Excerpt: Early Adopter VoiceXML: VoiceXML with XSLT (HTML and WML), Part 2
</noinput> <block> <assign name="form_pointer" expr="'mainMenu'"/> </block> <field name="userSaid"> <prompt bargein="true" timeout="3s"> This is the main menu. <break msecs="500"/> You can say product list to hear a list of products. <break msecs="500"/> You can say order status to check your order status. <break msecs="500"/> You can say frequently asked questions to get more information. <break msecs="500"/> You can always say main menu to return to this menu, or help for additional help. </prompt> <grammar type="application/x-jsgf"> list product list | more information | frequently asked questions | questions | order status </grammar>
In order to keep track of the currently active form, the global variable form_pointer is set. This could be used to implement specific navigation logic, for example, by changing the behavior of a command slightly depending on where the command originated. Once the prompt has been played, and the user has responded with an utterance matching the inline grammar, the <filled> handler for this <field> is entered. This copies the value returned by the grammar to the global variable user_command, which is used by the navigator form to direct control flow to the required form. We could also use <subdialog> and pass a parameter, but this is simpler, and sufficient for this application.
<filled> <assign name="user_command" expr="userSaid"/> <goto next="#navigator"/> </filled> </field> </form>Now our main menu form is finished, we can start to implement the dialogs that provide the application's basic functionality. First up is the orderStatus form that makes the most extensive use of dynamic content generation:
<form id="orderStatus"> <noinput> <assign name="user_command" expr="'main menu'"/>
Page 4 of 5