The pizza ordering application is going to need to do more than just get a phone number from the caller. It should probably also have the ability to find out the type of pizza that the caller wants and the address for delivery. Typically, this will necessitate the use of multiple forms within a document and the ability to transition between these forms as dictated by the dialog. A schematic diagram of what this application might look like is shown below:
The three forms are named “telephone” (contains dialog for obtaining the user’s telephone number), “pizzaType” (obtains the type of pizza), and “address” (gets the caller’s delivery address). To transition between forms, one typically uses the <goto> tag. Execution begins in the next portion of the dialog (contained in another form) as dictated by the logic of the application. The Form Interpretation Algorithim* (FIA) will then begin execution at the top of the new form. If control is not explicitly passed from the current form, execution will stop upon reaching the end of the form, ending the application.
The <goto> element:
The <goto> element can be used to transition to another form item in a current form, another <form> (dialog) in the current document, to another document, or to another form in another document. The syntax for the use of this element is as follows:
Transitioning to a form item within a form
<goto nextitem="some_form_items_var_name" />
Transitioning to another form in the current document
<goto next="#some_form_id" />
Transitioning to another document
<goto next="http://www.some_url.com/some_doc.vxml" />
One may also dynamically resolve the URI and URI fragments by using the expr attribute and an ECMAScript expression:
<goto expr="'../some_app/' + filenamevar + '.vxml'" />
Exercise for the student
In the following code, select the appropriate command from the pulldown menu to transition from the “telephone” form to the “pizzaType” form.
<?xml version="1.0"?> <vxml version="2.0"> <form id="getPhoneNumber"> <field name="PhoneNumber" type="phone" > <grammar src="../grammars/phone.gram" type="application/srgs+xml" /> <prompt>What's your phone number?</prompt> <help> Please say your ten digit phone number. </help> </field> <block>
</block> </form> <form id="pizzaType"> <field name="pizzaTopping" > <prompt>What type of pizza do you want?</prompt> <grammar src="../grammars/pizzas.gram" type=""application/srgs+xml"/> </field> </form> </vxml>
</block> </form> <form id="pizzaType"> <field name="pizzaTopping" > <prompt>What type of pizza do you want?</prompt> <grammar src="../grammars/pizzas.gram" type=""application/srgs+xml"/> </field> </form> </vxml>