Transitions
Execution within a VoiceXML document flows in document order until a dialog (form or menu) is entered. Execution flows from the current dialog to a different dialog or document, based on either:
-
An explicit transition statement in the current dialog:
-
Speech recognition in the current dialog that transitions to a different dialog:
Execution can leave the current dialog temporarily to execute a subdialog, returning to the current dialog when execution of the subdialog is complete.
If the current dialog completes execution without transitioning to a different location, the application exits. In addition, you can use an <exit> element to end the application explicitly.
Explicit transition
You can set up explicit transitions to other dialogs or documents in your application using <goto> or <submit> tags. These transition elements can be placed inside <block> or <filled> elements or event handlers. For example:
<filled>
<assign name="PizzaSize" expr="size"/>
<goto next="GetPizzaToppings.vxml"/>
</filled>
The <goto> element lets you transition to another input item in the current form, to another dialog in the current document, or to another document. When you make the transition to the new location, the local variables from the old form or document are lost. This happens even if you transition to the same form you were in before. However, the values of local variables are not affected when you use <goto> to transition between items within a form.
The <submit> tag lets you pass values to another document using an HTTP GET or POST request. Since you use a URI to specify the next document, it need not be a VoiceXML document; for example, it could be a CGI script document.
Transition triggered by recognition
User input to a dialog may cause a transition to a different location:
If the recognition engine matches the grammar of a menu <choice> element that has a next or expr attribute, the interpreter transitions to the destination specified by that attribute. In the example below, pressing “1” transitions to the MovieForm item:
<menu>
<prompt> Please choose one of <enumerate/></prompt>
<choice dtmf="1" next="#MovieForm">
local movies
</choice>
...
-
Similarly, if the recognition engine matches the grammar of a <link> element that has a next or expr attribute, the interpreter transitions to the destination specified by that attribute. In the example below, saying “goodbye” exits the application, while saying “cancel” returns the caller to an appropriate point in the main pizza.vxml document:
<link next="Goodbye.vxml">
<grammar src="../grammars/universals.grxml#Goodbye" weight="0.01"/>
</link>
<link next="pizza.vxml">
<grammar src="../grammars/universals.grxml#Cancel" weight="0.01"/>
</link>
-
If the recognition engine matches a document or application scope grammar that is defined in a different dialog, the interpreter transitions to that dialog.
Subdialogs
A subdialog is a reusable VoiceXML dialog to which you can pass data and from which you can get return values from:
-
The current dialog passes control to a subdialog with a <subdialog> element. It can pass data to the subdialog with <param> elements inside the <subdialog> element.
-
A subdialog returns control to the calling dialog with the <return> element. It can pass values back using the namelist attribute of the <return> element.