Telephony Isn't All Talk for Java Developers (cont'd)
Starting the Input Field
We've started an input field now, so we have to define a grammar to tell the processor how to decipher what the user will say to retrieve information. In this simple application, we'll limit the choices to "mail" and "weather," just to keep the size manageable. We'll talk a bit more about the grammar later.
<grammar src="javavxml.gsl#VXMLgrammar"/>
</field>
At this point, the input field is fully defined and we have to tell the processor what to do with the information returned in this field. The tag, appropriately enough, is named "filled" and the name of the input field has to be identified here.
<filled namelist="Destination">">
<if cond="Destination == 'Mail'">
<goto next="#Mail"/>
<elseif cond="Destination == 'Weather'"/>
<goto next="#Weather"/>
</if>
</filled>
</form>
And that's the end of the form. We've defined an input field, how to fill the field, and inserted the branching logic to process each input variation separately.
Now we can write out the actual processing sections, which are also forms. We'll just do stubs to avoid having to worry about thread-safe code and database issues, but you could insert calls to an actual mail application here and a real weather server later on. Since the stubs are also forms, you could even solicit more input from the user in each one.
<form id="Mail">
<block>
<audio src="vxmlnomail.wav" />
</block>
<!-- More logic can be inserted here -->
<block>
<goto next="#Goodbye" />
</block>
</form>
<form id="Weather">
<block>
<audio src="vxmlnoweather.wav" />
</block>
<!-- More logic can be inserted here -->
<block>
<goto next="#Goodbye" />
</block>
</form>
<form id="Goodbye">
<block>
<audio src="vxmlgoodbye.wav" />
<exit />
</block>
</form>