Copyright © 2000
VoiceXML Forum.
All rights reserved.
VoiceXML is a trademark of the VoiceXML Forum.
This document specifies VoiceXML, the Voice Extensible Markup Language. VoiceXML is designed for creating audio dialogs that feature synthesized speech, digitized audio, recognition of spoken and DTMF key input, recording of spoken input, telephony, and mixed-initiative conversations. Its major goal is to bring the advantages of web-based development and content delivery to interactive voice response applications.
This document is a submission to the World Wide Web Consortium from the VoiceXML Forum (see Submission Request, W3C Staff Comment). For a full list of all acknowledged Submission, please see Acknowledged Submissions to W3C.
This document is a Note made available by W3C for discussion only. This work does not imply endorsement by, or the consensus of the W3C membership, nor that W3C has, is, or will be allocating any resources to the issues addressed by the Note. This document is a work in progress and may be updated, replaced, or rendered obsolete by other documents at any time.
Please send comments on this document to submission@voicexml.org.
A list of current W3C technical documents can be found at the Technical Reports page.
The VoiceXML Forum is an industry organization founded by AT&T, IBM, Lucent and Motorola. It was established to develop and promote the Voice eXtensible Markup Language (VoiceXML), a new computer language designed to make Internet content and information accessible via voice and phone.
With the backing and technology contributions of its four world-class founders, and the support of leading Internet industry players, the VoiceXML Forum has made speech-enabled applications on the Internet a reality.
For more information on the VoiceXML Forum please visit the website at http://www.voicexml.org
VoiceXML 1.0 was designed for speech-based telephony applications. Where a specific application environment does not require all the features of v1.0, exceptions should be clearly noted, and publicly documented as a subset of VoiceXML 1.0. Any vendor-specific additions or changes should be similarly noted as proprietary extensions to VoiceXML 1.0. The VoiceXML Forum provides no support for, and make no guarantee of, future compatibility with such changes.
This document is subject to change without notice and may be updated, replaced or made obsolete by other documents at any time.
The VoiceXML Forum disclaims any and all warranties, whether express or implied, including (without limitation) any implied warranties of merchantability or fitness for a particular purpose.
The descriptions contained herein do not imply the granting of licenses to make, use, sell, license or otherwise transfer any technology required to implement systems or components conforming to this specification. The VoiceXML Forum, and its member companies, makes no representation on technology described in this specification regarding existing or future patent rights, copyrights, trademarks, trade secrets or other proprietary rights.
By submitting information to the VoiceXML Forum, and its member companies, including but not limited to technical information, you agree that the submitted information does not contain any confidential or proprietary information, and that the VoiceXML Forum may use the submitted information without any restrictions or limitations.
| Version | Date | Description |
|---|---|---|
|
0.9 |
17 Aug 1999 |
Initial release. Provided as baseline in support of comment period from supporters. |
|
1.0 RC |
02 Mar 2000 |
Release Candidate (released to Forum Supporters) |
|
1.0 |
07 Mar 2000 |
Released to public - editorial corrections from 1.0 RC |
This document introduces VoiceXML, the Voice Extensible Markup Language. VoiceXML is designed for creating audio dialogs that feature synthesized speech, digitized audio, recognition of spoken and DTMF key input, recording of spoken input, telephony, and mixed-initiative conversations. Its major goal is to bring the advantages of web-based development and content delivery to interactive voice response applications.
Here are two short examples of VoiceXML. The first is the venerable “Hello World”:
<?xml version="1.0"?>
<vxml version="1.0">
<form>
<block>Hello World!</block>
</form>
</vxml>
The top-level element is <vxml>, which is mainly a container for dialogs. There are two types of dialogs: forms and menus. Forms present information and gather input; menus offer choices of what to do next. This example has a single form, which contains a block that synthesizes and presents “Hello World!” to the user. Since the form does not specify a successor dialog, the conversation ends.
Our second example asks the user for a choice of drink and then submits it to a server script:
<?xml version="1.0"?>
<vxml version="1.0">
<form>
<field name="drink">
<prompt>Would you like coffee,
tea, milk, or nothing?</prompt>
<grammar src="drink.gram"
type="application/x-jsgf"/>
</field>
<block>
<submit next=
"http://www.drink.example/drink2.asp"/>
</block>
</form>
</vxml>
A field is an input field. The user must provide a value for the field before proceeding to the next element in the form. A sample interaction is:
C (computer): Would you like coffee, tea, milk, or nothing?
H (human): Orange juice.
C: I did not understand what you said.
C: Would you like coffee, tea, milk, or nothing?
H: Tea
C: (continues in document drink2.asp)
This section contains a high-level architectural model, whose terminology is then used to describe the goals of VoiceXML, its scope, its design principals, and the requirements it places on the systems that support it.
The architectural model assumed by this document has the following components:

Figure 1: Architectural Model
A document server (e.g. a web server) processes requests from a client application, the VoiceXML Interpreter, through the VoiceXML interpreter context. The server produces VoiceXML documents in reply, which are processed by the VoiceXML Interpreter. The VoiceXML interpreter context may monitor user inputs in parallel with the VoiceXML interpreter. For example, one VoiceXML interpreter context may always listen for a special escape phrase that takes the user to a high-level personal assistant, and another may listen for escape phrases that alter user preferences like volume or text-to-speech characteristics.
The implementation platform is controlled by the VoiceXML interpreter context and by the VoiceXML interpreter. For instance, in an interactive voice response application, the VoiceXML interpreter context may be responsible for detecting an incoming call, acquiring the initial VoiceXML document, and answering the call, while the VoiceXML interpreter conducts the dialog after answer. The implementation platform generates events in response to user actions (e.g. spoken or character input received, disconnect) and system events (e.g. timer expiration). Some of these events are acted upon by the VoiceXML interpreter itself, as specified by the VoiceXML document, while others are acted upon by the VoiceXML interpreter context.
VoiceXML’s main goal is to bring the full power of web development and content delivery to voice response applications, and to free the authors of such applications from low-level programming and resource management. It enables integration of voice services with data services using the familiar client-server paradigm. A voice service is viewed as a sequence of interaction dialogs between a user and an implementation platform. The dialogs are provided by document servers, which may be external to the implementation platform. Document servers maintain overall service logic, perform database and legacy system operations, and produce dialogs. A VoiceXML document specifies each interaction dialog to be conducted by a VoiceXML interpreter. User input affects dialog interpretation and is collected into requests submitted to a document server. The document server may reply with another VoiceXML document to continue the user’s session with other dialogs.
VoiceXML is a markup language that:
Minimizes client/server interactions by specifying multiple interactions per document.
Shields application authors from low-level, and platform-specific details.
Separates user interaction code (in VoiceXML) from service logic (CGI scripts).
Promotes service portability across implementation platforms. VoiceXML is a common language for content providers, tool providers, and platform providers.
Is easy to use for simple interactions, and yet provides language features to support complex dialogs.
While VoiceXML strives to accommodate the requirements of a majority of voice response services, services with stringent requirements may best be served by dedicated applications that employ a finer level of control.
The language describes the human-machine interaction provided by voice response systems, which includes:
Output of synthesized speech (text-to-speech).
Output of audio files.
Recognition of spoken input.
Recognition of DTMF input.
Recording of spoken input.
Telephony features such as call transfer and disconnect.
The language provides means for collecting character and/or spoken input, assigning the input to document-defined request variables, and making decisions that affect the interpretation of documents written in the language. A document may be linked to other documents through Universal Resource Identifiers (URIs).
VoiceXML is an XML schema. For details about XML, refer to the Annotated XML Reference Manual.
The language promotes portability of services through abstraction of platform resources.
The language accommodates platform diversity in supported audio file formats, speech grammar formats, and URI schemes. While platforms will respond to market pressures and support common formats, the language per se will not specify them.
The language supports ease of authoring for common types of interactions.
The language has a well-defined semantics that preserves the author's intent regarding the behavior of interactions with the user. Client heuristics are not required to determine document element interpretation.
The language has a control flow mechanism.
The language enables a separation of service logic from interaction behavior.
It is not intended for heavy computation, database operations, or legacy system operations. These are assumed to be handled by resources outside the document interpreter, e.g. a document server.
General service logic, state management, dialog generation, and dialog sequencing are assumed to reside outside the document interpreter.
The language provides ways to link documents using URIs, and also to submit data to server scripts using URIs.
VoiceXML provides ways to identify exactly which data to submit to the server, and which HTTP method (get or post) to use in the submittal.
The language does not require document authors to explicitly allocate and deallocate dialog resources, or deal with concurrency. Resource allocation and concurrent threads of control are to be handled by the implementation platform.
This section outlines the requirements on the hardware/software platforms that will support a VoiceXML interpreter.
Document acquisition. The interpreter context is expected to acquire documents for the VoiceXML interpreter to act on. In some cases, the document request is generated by the interpretation of a VoiceXML document, while other requests are generated by the interpreter context in response to events outside the scope of the language, for example an incoming phone call.
Audio output. An implementation platform can provide audio output using audio files and/or using text-to-speech (TTS). When both are supported, the platform must be able to freely sequence TTS and audio output. Audio files are referred to by a URI. The language does not specify a required set of audio file formats.
Audio input. An implementation platform is required to detect and report character and/or spoken input simultaneously and to control input detection interval duration with a timer whose length is specified by a VoiceXML document.
It must report characters (for example, DTMF) entered by a user.
It must be able to receive speech recognition grammar data dynamically. Some VoiceXML elements contain speech grammar data; others refer to speech grammar data through a URI. The speech recognizer must be able to accommodate dynamic update of the spoken input for which it is listening through either method of speech grammar data specification.
It should be able to record audio received from the user. The implementation platform must be able to make the recording available to a request variable.
A VoiceXML document (or a set of documents called an application) forms a conversational finite state machine. The user is always in one conversational state, or dialog, at a time. Each dialog determines the next dialog to transition to. Transitions are specified using URIs, which define the next document and dialog to use. If a URI does not refer to a document, the current document is assumed. If it does not refer to a dialog, the first dialog in the document is assumed. Execution is terminated when a dialog does not specify a successor, or if it has an element that explicitly exits the conversation.
There are two kinds of dialogs: forms and menus. Forms define an interaction that collects values for a set of field item variables. Each field may specify a grammar that defines the allowable inputs for that field. If a form-level grammar is present, it can be used to fill several fields from one utterance. A menu presents the user with a choice of options and then transitions to another dialog based on that choice.
A subdialog is like a function call, in that it provides a mechanism for invoking a new interaction, and returning to the original form. Local data, grammars, and state information are saved and are available upon returning to the calling document. Subdialogs can be used, for example, to create a confirmation sequence that may require a database query; to create a set of components that may be shared among documents in a single application; or to create a reusable library of dialogs shared among many applications.
A session begins when the user starts to interact with a VoiceXML interpreter context, continues as documents are loaded and processed, and ends when requested by the user, a document, or the interpreter context.
An application is a set of documents sharing the same application root document. Whenever the user interacts with a document in an application, its application root document is also loaded. The application root document remains loaded while the user is transitioning between other documents in the same application, and it is unloaded when the user transitions to a document that is not in the application. While it is loaded, the application root document’s variables are available to the other documents as application variables, and its grammars can also be set to remain active for the duration of the application.
Figure 2 shows the transition of documents (D) in an application that share a common application root document (root).

Figure 2: Transitioning between documents in an application.
Each dialog has one or more speech and/or DTMF grammars associated with it. In machine directed applications, each dialog’s grammars are active only when the user is in that dialog. In mixed initiative applications, where the user and the machine alternate in determining what to do next, some of the dialogs are flagged to make their grammars active (i.e., listened for) even when the user is in another dialog in the same document, or on another loaded document in the same application. In this situation, if the user says something matching another dialog’s active grammars, execution transitions to that other dialog, with the user’s utterance treated as if it were said in that dialog. Mixed initiative adds flexibility and power to voice applications.
VoiceXML provides a form-filling mechanism for handling "normal" user input. In addition, VoiceXML defines a mechanism for handling events not covered by the form mechanism.
Events are thrown by the platform under a variety of circumstances, such as when the user does not respond, doesn't respond intelligibly, requests help, etc. The interpreter also throws events if it finds a semantic error in a VoiceXML document. Events are caught by catch elements or their syntactic shorthand. Each element in which an event can occur may specify catch elements. Catch elements are also inherited from enclosing elements "as if by copy". In this way, common event handling behavior can be specified at any level, and it applies to all lower levels.
A link supports mixed initiative. It specifies a grammar that is active whenever the user is in the scope of the link. If user input matches the link’s grammar, control transfers to the link’s destination URI. A <link> can be used to throw an event to go to a destination URI.
| Element | Purpose | Page |
|---|---|---|
| <assign> | Assign a variable a value. | 71 |
| <audio> | Play an audio clip within a prompt. | 46 |
| <block> | A container of (non-interactive) executable code. | 54 |
| <break> | JSML element to insert a pause in output. | 44 |
| <catch> | Catch an event. | 38 |
| <choice> | Define a menu item. | 28 |
| <clear> | Clear one or more form item variables. | 72 |
| <disconnect> | Disconnect a session. | 76 |
| <div> | JSML element to classify a region of text as a particular type. | 44 |
| <dtmf> | Specify a touch-tone key grammar. | 35 |
| <else> | Used in <if> elements. | 72 |
| <elseif> | Used in <if> elements. | 72 |
| <emp> | JSML element to change the emphasis of speech output. | 44 |
| <enumerate> | Shorthand for enumerating the choices in a menu. | 28 |
| <error> | Catch an error event. | 39 |
| <exit> | Exit a session. | 75 |
| <field> | Declares an input field in a form. | 50 |
| <filled> | An action executed when fields are filled. | 64 |
| <form> | A dialog for presenting information and collecting data. | 17 |
| <goto> | Go to another dialog in the same or different document. | 73 |
| <grammar> | Specify a speech recognition grammar. | 35 |
| <help> | Catch a help event. | 39 |
| <if> | Simple conditional logic. | 72 |
| <initial> | Declares initial logic upon entry into a (mixed-initiative) form. | 55 |
| <link> | Specify a transition common to all dialogs in the link’s scope. | 30 |
| <menu> | A dialog for choosing amongst alternative destinations. | 28 |
| <meta> | Define a meta data item as a name/value pair. | 66 |
| <noinput> | Catch a noinput event. | 39 |
| <nomatch> | Catch a nomatch event. | 39 |
| <object> | Interact with a custom extension. | 60 |
| <option> | Specify an option in a <field> | 53 |
| <param> | Parameter in <object> or <subdialog>. | 69 |
| <prompt> | Queue TTS and audio output to the user. | 44 |
| <property> | Control implementation platform settings. | 66 |
| <pros> | JSML element to change the prosody of speech output. | 44 |
| <record> | Record an audio sample. | 61 |
| <reprompt> | Play a field prompt when a field is re-visited after an event. | 73 |
| <return> | Return from a subdialog. | 75 |
| <sayas> | JSML element to modify how a word or phrase is spoken. | 44 |
| <script> | Specify a block of ECMAScript client-side scripting logic. | 77 |
| <subdialog> | Invoke another dialog as a subdialog of the current one. | 56 |
| <submit> | Submit values to a document server. | 74 |
| <throw> | Throw an event. | 38 |
| <transfer> | Transfer the caller to another destination. | 63 |
| <value> | Insert the value of a expression in a prompt. | 46 |
| <var> | Declare a variable. | 71 |
| <vxml> | Top-level element in each VoiceXML document. | 14 |
A VoiceXML document is primarily composed of top-level elements called dialogs. There are two types of dialogs: forms and menus. A document may also have <meta> elements, <var> and <script> elements, <property> elements, <catch> elements, and <link> elements.
Execution within one document. Document execution begins at the first dialog by default. As each dialog executes, it determines the next dialog. When a dialog doesn’t specify a successor dialog, document execution stops.
Here is “Hello World!” expanded to illustrate some of this. It now has a document level variable called “hi” which holds the greeting. Its value is used as the prompt in the first form. Once the first form plays the greeting, it goes to the form named “say_goodbye”, which prompts the user with “Goodbye!” Because the second form does not transition to another dialog, it causes the document to be exited.
<?xml version="1.0"?>
<vxml version="1.0">
<meta name="author" content="John Doe"/>
<meta name="maintainer"
content="hello-support@hi.example"/>
<var name="hi" expr="'Hello World!'"/>
<form>
<block>
<value expr="hi"/>
<goto next="#say_goodbye"/>
</block>
</form>
<form id="say_goodbye">
<block>
Goodbye!
</block>
</form>
</vxml>
Stylistically it is best to combine the forms:
<?xml version="1.0"?> <vxml version="1.0"> <meta name="author" content="John Doe"/> <meta name="maintainer" content="hello-support@hi.example"/> <var name="hi" expr="'Hello World!'"/> <form> <block><value expr="hi"/>Goodbye!</block> </form> </vxml>
Attributes of <vxml> include:
| version | The version of VoiceXML of this document (required). The initial version number is 1.0. |
|---|---|
| base | The base URI. |
| lang | The language and locale type for this document.< |
| application | The URI of this document’s application root document, if any. |
Normally, each document runs as an isolated application. In cases where you want multiple documents to work together as one application, you select one document to be the application root document, and refer to it in the other documents’ <vxml> elements.
When this is done, every time the interpreter is told to load a document in this application, it also loads the application root document if it is not already loaded. The application root document remains loaded until the interpreter is told to load a document that belongs to a different application. Thus one of the following two conditions always holds during interpretation:
The application root document (or a stand-alone document) is loaded and the user is executing in it.
The application root document and one other document in the application are both loaded and the user is executing in the non-root document.
There are two benefits to multi-document applications. First, the application root document’s variables are available for use by the other documents in the application, so that information can be shared and retained. Second, the grammars of the application root document may be set to remain active even when the user is in other application documents, so that the user can always interact with common forms, links, and menus.
Here is a two-document application illustrating this:
Application root document (app-root.vxml)
<?xml version="1.0"?> <vxml version="1.0"> <var name="bye" expr="'Ciao'"/> <link next="operator_xfer.vxml"> <grammar> operator </grammar> </link> </vxml>
Main document (main.vxml)
<?xml version="1.0"?>
<vxml version="1.0" application="app-root.vxml">
<form id="say_goodbye">
<field name="answer" type="boolean">
<prompt>Shall we say <value
expr="application.bye"/>?</prompt>
<filled>
<if cond="answer">
<exit/>
</if>
<clear namelist="answer"/>
</filled>
</field>
</form>
</vxml>
In this example, the application is designed so that main.vxml must be loaded first. Its application attribute specifies that app-root.vxml should be imported as the application root document. So, app-root.vxml is then loaded, which creates the application variable bye and also defines a link that navigates to /operator-xfer.vxml whenever the user says “operator”. The user starts out in the say_goodbye form:
C: Shall we say Ciao?
H: Si.
C: I did not understand what you said. (a platform-specific default message.)
H: Ciao
C: I did not understand what you said.
H: Operator.
C: (Goes to operator_xfer.vxml, which transfers the caller to a human operator.)
Note that when the user is in a multi-document application, at most two documents are loaded at any one time: the application root document, and unless the user is actually interacting with the application root document, one other application document.
If a document refers to a non-existent application root document, or if an application root document itself has a reference to another application root document, an error.semantic event is thrown.
A subdialog is a mechanism for decomposing complex sequences of dialogs to better structure them, or to create reusable components. For example, the solicitation of account information may involve gathering several pieces of information, such as account number, and home telephone number. A customer care service might be structured with several independent applications that could share this basic building block, thus it would be reasonable to construct it as a subdialog. This is illustrated in the example below. The first document, app.vxml, seeks to adjust a customer’s account, and in doing so must get the account information and then the adjustment level. The account information is obtained by using a subdialog element that invokes another VoiceXML document to solicit the user input. While the second document is being executed, the calling dialog is suspended, awaiting the return of information. The second document provides the results of its user interactions using a <return> element, and the resulting values are accessed through the variable defined by the name attribute on the <subdialog> element.
Customer Service Application (app.vxml)
<?xml version="1.0"?>
<vxml version="1.0">
<form id="billing_adjustment">
<var name="account_number"/>
<var name="home_phone"/>
<subdialog name="accountinfo"
src="acct_info.vxml#basic">
<filled>
<!-- Note the variable defined by "accountinfo" is
returned as an ECMAScript object and it contains two
properties defined by the variables specified in the
"return" element of the subdialog. -->
<assign name="account_number"
expr="accountinfo.acctnum"/>
<assign name="home_phone"
expr="accountinfo.acctphone"/>
</filled>
</subdialog>
<field name="adjustment_amount" type="currency">
<prompt>
What is the value of your account adjustment?
</prompt>
<filled>
<submit next="/cgi-bin/updateaccount"/>
</filled>
</field>
</form>
</vxml>
Document Containing Account Information Subdialog (acct_info.vxml)
<?xml version="1.0"?>
<vxml version="1.0">
<form id="basic">
<field name="acctnum" type="digits">
<prompt> What is your account number? </prompt>
</field>
<field name="acctphone" type="phone">
<prompt> What is your home telephone number? </prompt>
<filled>
<!-- The values obtained by the two fields are supplied
to the calling dialog by the "return" element. -->
<return namelist="acctnum acctphone"/>
</filled>
</field>
</form>
</vxml>
Subdialogs add a new execution context when they are invoked. The subdialog could be a new dialog within the existing document, or a new dialog within a new document. The invocation of a subdialog limits the scope of active grammars to the subdialog only.
Figure 3 shows the execution flow when a sequence of documents (D) transitions to a subdialog (SD) and then back.

Figure 3: Execution flow when invoking
a subdialog composed of two documents.
Forms are the key component of VoiceXML documents. A form contains:
A set of form items, elements that are visited in the main loop of the form interpretation algorithm. Form items are subdivided into field items, those that define the form’s field item variables, and control items, those that help control the gathering of the form’s fields.
Declarations of non-field item variables.
Event handlers.
“Filled” actions, blocks of procedural logic that execute when certain combinations of field items are filled in.
Form attributes are:
| id | The name of the form. |
|---|---|
| scope | The default scope of the form’s grammars. If it is dialog then the form grammars are active only in the form. If the scope is document, then the form are active during any dialog in the same document. If the scope is document and the document is an application root document, then the form grammars are active during any dialog in any document of this application. A form grammar that has dialogscope is active only in its form. |
This section describes some of the concepts behind forms, and then gives some detailed examples of their operation.
Forms are interpreted by an implicit form interpretation algorithm (FIA). The FIA has a main loop that repeatedly selects a form item and then visits it. The selected form item is the lexically first whose guard condition is not satisfied. For instance, a field item’s default guard condition tests to see if the field item variable has a value, so that if a simple form contains only field items, the user will be prompted for each field item in turn.
Interpreting a form item generally involves:
Selecting and playing one or more prompts;
Collecting a user input, either a response that fills in one or more fields, or a throwing of some event (help, for instance); and
Interpreting any <filled> actions that pertained to the newly filled in fields.
The FIA ends when it interprets a transfer of control statement (e.g. a <goto> to another dialog or document, a <submit> of data to the document server). It also ends with an implied <exit> when no form item remains eligible to select.
A field item specifies a field item variable to gather from the user. Field items have prompts to tell the user what to say or key in, grammars that define the allowed inputs, and event handlers that process any resulting events. A field item may also have a <filled> element that defines an action to take just after the field item variable is filled in. Field items are subdivided into:
| <field> | A field item whose value is obtained via ASR or DTMF grammars. |
|---|---|
| <record> | A field item whose value is an audio clip recorded by the user. A <record> element could collect a voice mail message, for instance. |
| <transfer> | A field item which transfers the user to another telephone number. If the transfer returns control, the field variable will be set to the result status. |
| <object> | This field item invokes a platform-specific "object" with various parameters. The result of the platform object is an ECMAScript Object with one or more properties. One platform object could be a built-in dialog that gathers credit card information. Another could gather a text message using some proprietary DTMF text entry method. There is no requirement for implementations to provide platform-specific objects, although support for the <object> element is required. |
| <subdialog> | A <subdialog> field item is roughly like a function call. It invokes another dialog on the current page, or invokes another VoiceXML document. It returns an ECMAScript Object as its result. |
There are two types of control items:
| <block> | A sequence of procedural statements used for prompting and computation, but not for gathering input. A block has a (normally implicit) form item variable that is set to true just before it is interpreted. |
|---|---|
| <initial> | This element controls the initial interaction in a mixed initiative form. Its prompts should be written to encourage the user to say something matching a form level grammar. When at least one field item variable is filled as a result of recognition during an <initial> element, the form item variable of <initial> becomes true, thus removing it as an alternative for the FIA. |
Each form item has an associated form item variable, which by default is set to undefined when the form is entered. This form item variable will contain the result of interpreting the form item. A field item’s form item variable is also called a field item variable, and it holds the value collected from the user. A form item variable can be given a name using the name attribute, or left nameless, in which case an internal name is generated.
Each form item also has a guard condition, which governs whether or not that form item can be selected by the form interpretation algorithm. The default guard condition just tests to see if the form item variable has a value. If it does, the form item will not be visited.
Typically, field items are given names, but control items are not. Generally form item variables are not given initial values and additional guard conditions are not specified. But sometimes there is a need for more detailed control. One form may have a form item variable initially set to hide a field, and later cleared (e.g., using <clear>) to force the field’s collection. Another field may have a guard condition that activates it only when it has not been collected, and when two other fields have been filled. A block item could execute only when some condition holds true. Thus, fine control can be exercised over the order in which form items are selected and executed by the FIA, however in general, many dialogs can be constructed without resorting to this level of complexity.
In summary, all form items have the following attributes:
| name& | The name of a dialog-scoped form item variable that will hold the value of the form item. |
|---|---|
| expr | The initial value of the form item variable; default is ECMAScript undefined. If initialized to a value, then the form item will not be executed unless the form item variable is cleared. |
| cond | An expression to evaluate in conjunction with the test of the form item variable. If absent, this defaults to true, or in the case of <initial>, a test to see if any field item variable has been filled in. |
The simplest and most common type of form is one in which the form items are executed exactly once in sequential order to implement a computer-directed interaction. Here is a weather information service that uses such a form.
<form id="weather_info">
<block>Welcome to the weather information
service.</block>
<field name="state">
<prompt>What state?</prompt>
<grammar src="state.gram"
type="application/x-jsgf"/>
<catch event="help">
Please speak the state for which you
want the weather.
</catch>
</field>
<field name="city">
<prompt>What city?</prompt>
<grammar src="city.gram"
type="application/x-jsgf"/>
<catch event="help">
Please speak the city for which you
want the weather.
</catch>
</field>
<block>
<submit next="/servlet/weather" namelist="city state"/>
</block>
</form>
This dialog proceeds sequentially:
C (computer): Welcome to the weather information service. What state?
H (human): Help
C: Please speak the state for which you want the weather.
H: Georgia
C: What city?
H: Tblisi
C: I did not understand what you said. What city?
H: Macon
C: The conditions in Macon Georgia are sunny and clear at 11 AM …
The form interpretation algorithm’s first iteration selects the first block, since its (hidden) form item variable is initially undefined. This block outputs the main prompt, and its form item variable is set to true. On the FIA’s second iteration, the first block is skipped because its form item variable is now defined, and the state field is selected because the dialog variable state is undefined. This field prompts the user for the state, and then sets the variable state to the answer. The third form iteration prompts and collects the city field. The fourth iteration executes the final block and transitions to a different URI.
Each field in this example has a prompt to play in order to elicit a response, a grammar that specifies what to listen for, and an event handler for the help event. The help event is thrown whenever the user asks for assistance. The help event handler catches these events and plays a more detailed prompt.
Here is a second directed form, one that prompts for credit card information:
<form id="get_card_info">
<block> We now need your credit card type,
number, and expiration date.</block>
<field name="card_type">
<prompt count="1">What kind of credit card
do you have?</prompt>
<prompt count="2">Type of
card?</prompt>
<!-- This is an in line grammar. -->
<grammar>
vis {visa}
| master [card] {mastercard}
| amex {amex}
| american [express] {amex}
</grammar>
<help> Please say Visa, Mastercard, or American Express. </help>
</field>
<!-- The grammar for type="digits" is built in. -->
<field name="card_num" type="digits">
<prompt count="1">What is your card number?</prompt>
<prompt count="2">Card number?</prompt>
<catch event="help">
<if cond="card_type =='amex'">
Please say or key in your 15 digit card number.
<else/>
Please say or key in your 16 digit card number.
</if>
</catch>
<filled>
<if cond="card_type == 'amex' card_num.length != 15">
American Express card numbers must have 15 digits.
<clear namelist="card_num"/>
<throw event="nomatch"/>
<elseif cond="card_type != 'amex'
&& card_num.length != 16"/>
Mastercard and Visa card numbers have 16 digits.
<clear namelist="card_num"/>
<throw event="nomatch"/>
</if>
</filled>
</field>
<field name="expiry_date" type="digits">
<prompt count="1">What is your card's expiration date?</prompt>
<prompt count="2">Expiration date?</prompt>
<help>
Say or key in the expiration date, for example one two oh one.
</help>
<filled>
<!-- validate the mmyy -->
<var name="mm"/>
<var name="i" expr="expiry_date.length"/>
<if cond="i == 3">
<assign name="mm" expr="expiry_date.substring(0,1)"/>
<elseif cond="i == 4"/>
<assign name="mm" expr="expiry_date.substring(0,2)"/>
</if>
<if cond="mm == '' || mm < 1 || mm > 12">
<clear namelist="expiry_date"/>
<throw event="nomatch"/>
</if>
</filled>
</field>
<field name="confirm" type="boolean">
<prompt>I have <value
expr="card_type"/> number <value expr="card_num"/>,
expiring on <value
expr="expiry_date"/>. Is this correct?
</prompt>
<filled>
<if cond="confirm">
<submit next="place_order.asp"
namelist="card_type card_num expiry_date"/>
</if>
<clear namelist="card_type card_num expiry_date acknowledge"/>
</filled>
</field>
</form>
The dialog might go something like this:
C: We now need your credit card type, number, and expiration date.
C: What kind of credit card do you have?
H: Discover
C: I did not understand what you said. (a platform-specific default message.)
C: Type of card? (the second prompt is used now.)
H: Shoot. (fortunately treated as “help” by this platform)
C: Please say Visa, Master card, or American Express.
H: Uh, Amex. (this platform ignores “uh”)
C: What is your card number?
H: One two three four … wait …
C: I did not understand what you said.
C: Card number?
H: (uses DTMF) 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 #
C: What is your card’s expiration date?
H: one two oh one
C: I have Amex number 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 expiring on 1 2 0 1. To go on say yes, to reenter say no.
H: Yes
Fields are the major building blocks of forms. A field declares a variable and specifies the prompts, grammars, DTMF sequences, help messages, and other event handlers that are used to obtain it. Each field declares a VoiceXML field item variable in the form’s dialog scope. These may be submitted once the form is filled, or copied into other variables.
Each field has its own speech and/or DTMF grammars, specified explicitly using <grammar> and <dtmf> elements, or implicitly using the type attribute. The type attribute is used for standard built-in grammars, like digits, boolean, or number. The type attribute also governs how that field’s value is spoken by the speech synthesizer.
Each field can have one or more prompts. If there is one, it is repeatedly used to prompt the user for the value until one is provided. If there are many, they must be given count attributes. These determine which prompt to use on each attempt. In the example, prompts are become shorter. This is called tapered prompting.
The <catch event="help"> elements are event handlers that define what to do when the user asks for help. Help messages can also be tapered. These can be abbreviated, so that the following two elements are equivalent:
<catch event="help"> Please say visa, mastercard, or amex. </catch> <help>Please say visa, mastercard, or amex.</help>
The <filled> element defines what to do when the user provides a recognized input for that field. One use is to specify integrity constraints over and above the checking done by the grammars, as with the date field above.
The last section talked about forms implementing rigid, computer-directed conversations. To make a form mixed initiative, where both the computer and the human direct the conversation, it must one or more <initial> form items and one or more form-level grammars.
If a form has form-level grammars:
Its fields can be filled in any order.
More than one field can be filled as a result of a single user utterance.
Also, the form’s grammars can be active when the user is in other dialogs. If a document has two forms on it, say a car rental form and a hotel reservation form, and both forms have grammars that are active for that document, a user could respond to a request for hotel reservation information with information about the car rental, and thus direct the computer to talk about the car rental instead. The user can speak to any active grammar, and have fields set and actions taken in response.
Example. Here is a second version of the weather information service, showing mixed initiative. It has been “enhanced” for illustrative purposes with advertising and with a confirmation of the city and state:
<form id="weather_info">
<grammar src="cityandstate.gram" type="application/x-jsgf"/>
<!-- Caller can't barge in on today's advertisement. -->
<block>
<prompt bargein="false">
Welcome to the weather information service.
<audio src="http://www.online-ads.example/wis.wav"/>
</prompt>
</block>
<initial name="start">
<prompt> For what city and state would you
like the weather? </prompt>
<help> Please say the name of the city and
state for which you you would like a weather
report.</help>
<!-- If user is silent, reprompt once, then
try directed prompts. -->
<noinput count="1"> <reprompt/></noinput>
<noinput count="2"> <reprompt/>
<assign name="start" expr="true"/></noinput>
</initial>
<field name="state">
<prompt>What state?</prompt>
<help>Please speak the state for which you
want the weather.</help>
</field>
<field name="city">
<prompt>Please say the city in <value
expr="state"/> for which you want the
weather.</prompt>
<help>Please speak the city for which you
want the weather.</help>
<filled>
<!-- Most of our customers are in LA. -->
<if cond="city == 'Los Angeles' && state == undefined">
<assign name="state" expr="'California'"/>
</if>
</filled>
</field>
<field name="go_ahead" type="boolean" modal="true">
<prompt>Do you want to hear the weather for
<value expr="city"/>, <value expr="state"/>?
</prompt>
<filled>
<if cond="go_ahead">
<prompt bargein="false">
<audio src="http://www.online-ads.example/wis2.wav"/>
</prompt>
<submit next="/servlet/weather" namelist="city state"/>
</if>
<clear namelist="start city state go_ahead"/>
</filled>
</field>
</form>
Here is a transcript showing the advantages for even a novice user:
C: Welcome to the weather information service. Buy Joe’s Spicy Shrimp Sauce.
C: For what city and state would you like the weather?
H: Uh, California.
C: Please say the city in California for which you want the weather.
H: San Francisco, please.
C: Do you want to hear the weather for San Francisco, California?
H: No
C: What state?
H: Los Angeles.
C: Do you want to hear the weather for Los Angeles, California?
H: Yes
C: Don’t forget, buy Joe’s Spicy Shrimp Sauce tonight!
C: Mostly sunny today with highs in the 80s. Lows tonight from the low 60s …
The go_ahead field has its modal attribute set to true. This causes all grammars to be disabled except the ones defined in the current form item, so that the only grammar active during this field is the built-in grammar for boolean.
An experienced user can get things done much faster (but is still forced to listen to the ads):
C: Welcome to the weather information service. Buy Joe’s Spicy Shrimp Sauce.
C: What …
H (barging in): LA
C: Do you …
H (barging in): Yes
C: Don’t forget, buy Joe’s Spicy Shrimp Sauce tonight!
C: Mostly sunny today with highs in the 80s. Lows tonight from the low 60s …
The form interpretation algorithm can be customized in several ways. One way is to assign a value to a form item variable, so that its form item will not be selected. Another is to use <clear> to set a form item variable to undefined; this forces the FIA to revisit the form item again.
Another method is to explicitly specify the next field item to visit using <goto nextitem>. This forces an immediate transfer to that field item. If the <goto nextitem> occurs in a <filled> action, the rest of the <filled> action and any pending <filled> actions will be skipped.
Here is an example <goto nextitem> executed in response to the exit event:
<form id="survey_2000_03_30">
<catch event="exit">
<goto nextitem="confirm_exit"/>
</catch>
<block>
<prompt>
Hello, you have been called at random to answer questions
critical to U.S. foreign policy.
</prompt>
</block>
<field name="q1" type="boolean">
<prompt>Do you agree with the IMF position on
privatizing certain functions of Burkina Faso’s
agriculture ministry?</prompt>
</field>
<field name="q2" type="boolean">
<prompt>If this privatization occurs, will its
effects be beneficial mainly to Ouagadougou and
Bobo-Dioulasso?</prompt>
</field>
<field name="q3" type="boolean">
<prompt>Do you agree that sorghum and millet output
might thereby increase by as much as four percent per
annum?</prompt>
</field>
<block>
<submit next="register" namelist="q1 q2 q3"/>
</block>
<field name="confirm_exit" type="boolean">
<prompt>You have elected to exit. Are you
sure you want to do this, and perhaps adversely affect
U.S. foreign policy vis-à-vis sub-Saharan Africa for
decades to come?</prompt>
<filled>
<if cond="confirm_exit">
Okay, but the U.S. State Department is displeased.
<exit/>
<else/>
Good, let’s pick up where we left off.
<clear namelist="confirm_exit"/>
</if>
</filled>
</field>
</form>
If the user says “exit” in response to any of the survey questions, an exit event is thrown by the platform and caught by the <catch> event handler. This handler directs that confirm_exit be the next visited field. The confirm_exit field would not be visited during normal completion of the survey because the preceding <block> element transfers control to the registration script.
We’ve presented the form interpretation algorithm (FIA) at a conceptual level. In this section we describe it in more detail.
Whenever a form is entered, it is initialized. Internal prompt counter variables (in the form’s dialog scope) are reset to 1. Each variable (form-level <var> elements and form item variables) is initialized, in document order, to undefined or to the value of the relevant expr attribute.
The main loop of the FIA has three phases:
The select phase: the next form item is selected for visiting.
The collect phase: the next unfilled form item is visited, which prompts the user for input, enables the appropriate grammars, and then waits for and collects an input (such as a spoken phrase or DTMF key presses) or an event (such as a request for help or a no input timeout).
The process phase: an input is processed by filling form items and executing <filled> elements to perform actions such as input validation. An event is processed by executing the appropriate event handler for that event type.
Note that the FIA may be given an input (a set of grammar slot/slot value pairs) that was collected while the user was in a different form’s FIA. In this case the first iteration of the main loop skips the select and collect phases, and goes right to the process phase with that input.
The purpose of the select the next form item to visit. This is done as follows:
If a <goto> from the last main loop iteration’s process phase specified a <goto nextitem>, then the specified form item is selected.
Otherwise the first form item whose guard condition is false is chosen to be visited.
If no guard condition is false, then the last iteration completed the form without encountering an explicit transfer of control, so the FIA does an implicit <exit> operation.
The purpose of the collect phase is to collect an input or an event. The selected form item is visited, which performs actions that depend on the type of form item:
If a field item is visited, the FIA selects and queues up any prompts based on the field item’s prompt counter and the prompt conditions. Then it listens for the field level grammar(s) and any active higher-level grammars, and waits for a grammar recognition or for some event.
If an <initial> is visited, the FIA selects and queues up prompts based on the <initial>’s prompt counter and prompt conditions. Then it listens for the form level grammar(s) and any active higher-level grammars. It waits for a grammar recognition or for an event.
A <block> element is visited by setting its form item variable to true, evaluating its content, and then bypassing the process phase. No input is collected, and the next iteration of the FIA’s main loop is entered.
The purpose of the process phase is to process the input or event collected during the collect phase, as follows:
If an input matches a grammar in this form, then:
After completion of the process phase, interpretation continues by returning to the select phase.
A more detailed form interpretation algorithm can be found in Appendix C.
A menu is a convenient syntactic shorthand for a form containing a single anonymous field that prompts the user to make a choice and transitions to different places based on that choice. Like a regular form, it can have its grammar scoped such that it is active when the user is executing another dialog. The following menu offers the user three choices:
<menu>
<prompt>Welcome home. Say one of: <enumerate/></prompt>
<choice next="http://www.sports.example/vxml/start.vxml">
Sports
</choice>
<choice next="http://www.weather.example/intro.vxml">
Weather
</choice>
<choice next="http://www.stargazer.example/voice/astronews.vxml">
Stargazer astrophysics news
</choice>
<noinput>Please say one of <enumerate/></noinput>
</menu>
This dialog might proceed as follows:
C: Welcome home. Say one of: sports; weather; Stargazer astrophysics news.
H: Astrology.
C: I did not understand what you said. (a platform-specific default message.)
C: Welcome home. Say one of: sports; weather; Stargazer astrophysics news.
H: sports.
C: (proceeds to http://www.sports.example/vxml/start.vxml)
This identifies the menu, and determines the scope of its grammars. Menu attributes are:
| id | The identifier of the menu. It allows the menu to be the target of a <goto> or a <submit>. |
|---|---|
| scope | The menu’s grammar scope. If it is dialog – the default – the menu’s grammars are only active when the user transitions into the menu. If the scope is document, its grammars are active over the whole document (or if the menu is in the application root document, any loaded document in the application). |
| dtmf | When set to true, any choices that do not have explicit DTMF elements are given the implicit ones "1", "2", etc. |
The <choice> element serves several purposes:
It specifies a speech grammar fragment and/or a DTMF grammar fragment that determines when that choice has been selected.
The contents are used to form the <enumerate> prompt string.
It specifies the URI to go to when the choice is selected.
Choice attributes are:
| dtmf | The DTMF sequence for this choice. |
|---|---|
| next | The URI of next dialog or document. |
| event | Specify an event to be thrown instead of specifying a next. |
| expr | Specify an expression to evaluate instead of specifying a next. |
| caching | See Section 12.1. |
| fetchaudio | See Section 12.1. |
| fetchhint | See Section 12.1. This defaults to the documentfetchhint property. |
| fetchtimeout | See Section 12.1. |
DTMF in menus. Menus can rely purely on speech, purely on DTMF, or both in combination by including a <property> element in the <menu>. Here is a DTMF-only menu with explicit DTMF sequences given to each choice, using the choice’s dtmf attribute:
<menu>
<property name="inputmodes" value="dtmf"/>
<prompt>
For sports press 1, For weather press 2, For Stargazer
astrophysics press 3.
</prompt>
<choice dtmf="1"
next="http://www.sports.example/vxml/start.vxml"/>
<choice dtmf="2"
next="http://www.weather.example/intro.vxml"/>
<choice dtmf="3"
next="http://www.stargazer.example/voice/astronews.vxml"/>
</menu>
Alternatively, you can set the <menu>’s dtmf attribute to true to assign sequential DTMF digits to each of the first nine choices: the first choice has DTMF "1", and so on:
<menu dtmf="true">
<property name="inputmodes" value="dtmf"/>
<prompt>
For sports press 1, For weather
press 2, For Stargazer astrophysics press 3.
</prompt>
<choice next="http://www.sports.example/vxml/start.vxml"/>
<choice next="http://www.weather.example/intro.vxml"/>
<choice
next="http://www.stargazer.example/voice/astronews.vxml"/>
</menu>
The <enumerate> element is an automatically generated description of the choices available to the user. It specifies a template that is applied to each choice in the order they appear in the menu. If it is used with no content, a default template that lists all the choices is used, determined by the interpreter context. If it has content, the content is the template specifier. This specifier may refer to two special variables: _prompt is the choice’s prompt, and _dtmf is the choice’s assigned DTMF sequence. For example, if the menu were rewritten as
<menu dtmf="true">
<prompt>
Welcome home.
<enumerate>
For <value expr="_prompt"/>, press <value
expr="_dtmf"/>.
</enumerate>
</prompt>
<choice next="http://www.sports.example/vxml/start.vxml">
sports </choice>
<choice next="http://www.weather.example/intro.vxml">
weather </choice>
<choice next="http://www.stargazer.example/voice/astronews.vxml">
Stargazer astrophysics news
</choice>
</menu>
then the menu’s prompt would be:
C: Welcome home. For sports, press 1. For weather, press 2. For Stargazer astrophysics news, press 3.
The <enumerate> element may also be used analogously in prompts for <field> elements that contain a set of <option> elements as discussed in Section 14.1.3
Any choice phrase specifies a set of words and phrases to listen for. The user may say any phrase consisting of any subset of the words of the choice phrase in the same order in which they occur in the choice phrase. A choice phrase is constructed from the PCDATA of the elements contained directly or indirectly in the <choice> element. For example, in response to the prompt “Stargazer astrophysics news” a user could say “Stargazer”, “astrophysics”, “Stargazer news”, “astrophysics news”, and so on. The equivalent JSGF rule would be “[Stargazer] [astrophysics] [news]” (where […] indicates optionality).
As an example of the use of PCDATA contained in descendants of the <choice> element, consider the following example:
<choice next="http://www.stargazer.example/voice/astronews.vxml">
<prompt>
<audio src="http://www.stargazer.example/space.wav">
Stargazer <emp>astrophysics</emp> news
</audio>
</prompt>
</choice>
This choice would be read from the audio file, or as “Stargazer Astrophysics News” if the file could not be played. The grammar for the choice would be the equivalent of “[Stargazer] [astrophysics] [news] ” gleaned from the PCDATA of the <choice> element’s descendants.
A menu behaves like a form with a single field that does all the work. The menu prompts become field prompts. The menu event handlers become the field event handlers. The menu grammars become form grammars.
Upon entry, the menu’s grammars are built and enabled, and the prompt is played. When the user input matches a choice, control transitions according to the value of the next, expr, or event attribute of the <choice>, only one of which may be specified.
A <link> element has one or more grammars, which are scoped to the element containing the <link>. Grammar elements contained in the <link> are not permitted to specify scope. When one of these grammars is matched, the link activates, and either:
Transitions to a new document or dialog (like <goto>), or
Throws an event (like <throw>).
For instance, this link activates when you say “books” or press “2”.
<link next="http://www.voicexml.org/books/main.vxml">
<grammar type="application/x-jsgf"> books | Voice XML
books </grammar>
<dtmf> 2 </dtmf>
</link>
This link takes you to a dynamically determined dialog in the current document:
<link expr="’#’ + document.helpstate"> <grammar type="application/x-jsgf">help </grammar> </link>
The <link> element can be a child of <vxml>, <form>, or of a form item. A link at the <vxml> level has grammars that are active throughout the document. A link at the <form> level has grammars active while the user is in that form. If an application root document has a document-level link, its grammars are active no matter what document of the application is being executed.
If execution is in a modal form item, then link grammars at the form or document level are not active.
You can also define a link that, when matched, throws an event instead of going to a new document. This event is thrown at the current location in the execution, not at the location where the link is specified. For example, if the user matches this link’s grammar, a help event is thrown in the form item the user was visiting:
<link event="help"> <grammar type="application/x-jsgf"> arrgh | alas all is lost | fie ye froward machine | I don’t get it </grammar> </link>
Attributes of <link> are:
| next | The URI to go to. This URI is a document (perhaps with an anchor to specify the starting dialog), or a dialog in the current document (just a bare anchor). |
|---|---|
| expr | Like next, except that the URI is dynamically determined by evaluating the given ECMAScript expression. |
| event | The event to throw when the user matches one of the link grammars. Note that only one of next, expr, or event may be specified. |
| caching | See Section 12.1. |
| fetchaudio | See Section 12.1. |
| fetchhint | See Section 12.1. This defaults to the documentfetchhint property. |
| fetchtimeout | See Section 12.1. |
VoiceXML variables are in all respects equivalent to ECMAScript variables. The variable naming convention is as in ECMAScript, but names beginning with the underscore character (“_”) are reserved for internal use.
Variables are declared by <var> elements:
<var name="home_phone"/> <var name="pi" expr="3.14159"/> <var name="city" expr="'Sacramento'"/>
They are also declared by form items:
<field name="num_tickets" type="number"> <prompt>How many tickets do you wish to purchase?</prompt> </field>
Variables declared without an explicit initial value are initialized to the ECMAScript undefined value. Variables must be declared before being used.
In a form, the variables declared by <var> and those declared by form items are initialized when the form is entered. The initializations are guaranteed to take place in document order, so that this, for example, is legal:
<form id="test">
<var name="one" expr="1"/>
<field name="two" expr="one+1" type="number"></field>
<var name="three" expr="two+1"/>
<field name="go_on" type="boolean">
<prompt>Say yes or no to continue</prompt>
</field>
<filled>
<goto next="#tally"/>
</filled>
</form>
When the user visits this <form>, the form’s initialization first declares the variable one and sets its value to 1. Then it declares the field item variable two and gives it the value 2. Then the initialization logic declares the variable three and gives it the value 3. The form interpretation algorithm then enters its main interpretation loop and begins at the go_on field.
Variables can be declared in following scopes:
| session | These are read-only variables that pertain to an entire user session. They are declared and set by the interpreter context. New session variables cannot be declared by VoiceXML documents. See Section 9.4. |
|---|---|
| application | These are declared with <var> elements that are children of the application root document's <vxml> element. They are initialized when the application root document is loaded. They exist while the application root document is loaded, and are visible to the root document and any other loaded application leaf document. |
| document | These variables are declared with <var> elements that are children of the document’s <vxml> element. They are initialized when the document is loaded. They exist while the document is loaded, and are visible only within that document. |
| dialog | Each dialog (<form> or <menu>) has a dialog scope that exists while the user is visiting that dialog, and which is visible to the element of that dialog. Dialog variables are declared by <var> child elements of <form>, by <var> elements inside executable content (e.g. <block> content or catch element content), and by the various form item elements. The child <var> elements of <form> are initialized when the form is first visited. The <var> elements inside executable content are initialized when the executable content is executed. The form item variables are initialized when the form item is collected. |
| (anonymous) | Each <block>, <filled>, and catch element defines a new anonymous scope to contain variables declared in that element. |
The following diagram shows the scope hierarchy:

Figure 8: The scope hierarchy.
The curved arrows in this diagram show that each scope contains a variable whose name is the same as the scope that refers to the scope itself. This allows you for example in the anonymous, dialog, and document scopes to refer to a variable Xin the document scope using document.X.
Variables are referenced in cond and expr attributes:
<if cond="city == 'LA'"> <assign name="city" expr="'Los Angeles'"/> <elseif cond="city == 'Philly'"/> <assign name="city" expr="'Philadelphia'"/> <elseif cond="city =='Constantinople'"/> <assign name="city" expr="'Istanbul'"/> </if> <assign name="var1" expr="var1 + 1"/> <if cond="i > 1"> <assign name="i" expr="i-1"/> </if>
The expression language used in cond and expr is precisely ECMAScript. Note that the condoperators “>”, “<”, “>=”, “<=”, and “&&” must be escaped in XML (to “>” and “<” and so on). For clarity, examples in this document do not use XML escapes.
Variable references match the closest enclosing scope according to the scope chain given above. You can prefix a reference with a scope name for clarity or to resolve ambiguity. For instance to save the value of a form field item variable for use later on in a document:
<assign name="document.ssn" expr="dialog.ssn"/>
If the application root document has a variable x, it is referred to as application.x in non-root documents, and either application.x or document.x in the application root document.
The <grammar> element is used to provide a speech grammar that
specifies a set of utterances that a user may speak to perform an action or supply information, and
provides a corresponding string value (in the case of a field grammar) or set of attribute-value pairs (in the case of a form grammar) to describe the information or action.
The <grammar> element is designed to accommodate any grammar format that meets these two requirements. At this time, VoiceXML does not specify a grammar format nor require support of a particular grammar format. This is similar to the situation with recorded audio formats for VoiceXML, and with media formats in general for HTML.
The <grammar> element may be used to specify an inline grammar or an external grammar. An inline grammar is specified by the content of a <grammar> element:
<grammar type="mime-type">
inline speech grammar
</grammar>
It may be necessary in this case to enclose the content in a CDATA section. For inline grammars the type parameter specifies a MIME type that governs the interpretation of the content of the <grammar> tag.
An external grammar is specified by an element of the form
<grammar src="URI" type="mime-type"/>
The MIME type is optional in this case because this information may be obtained via the URI protocol (as in the case of HTTP), and may be inferred from the filename extension. If the type is not specified, and cannot be inferred, the default type is platform specific. However, if the type is specified using the type attribute, it overrides other information about the type.
See Appendix D for notes on using the Java Speech API Grammar Format (JSGF) with VoiceXML. (Note: Java is a trademark of Sun Microsystems Inc.)
Attributes of <grammar> include:
| src | The URI specifying the location of the grammar, if it is external. |
|---|---|
| scope | Either document, which makes the grammar active in all dialogs of the current document (and relevant application leaf documents), or dialog, to make the grammar active throughout the current form. If omitted, the grammar scoping is resolved by looking at the parent element. |
| type | The MIME type of the grammar. If this is omitted, the interpreter context will attempt to determine the type dynamically. |
| caching | See Section 12.1. |
| fetchhint | See Section 12.1. This defaults to the grammarfetchhint property. |
| fetchtimeout | See Section 12.1. |
The <dtmf> element is used to specify a DTMF grammar that
defines a set of key presses that a user may use to perform an action or supply information, and
defines the corresponding string value that describes that information or action.
The <dtmf> element is designed to accommodate any grammar format that meets these two requirements. VoiceXML does not specify nor require support for any particular grammar format: as with <grammar>, it is expected that standards efforts and market pressures will cause each widely used VoiceXML interpreter context to support a common set of formats.
The <dtmf> element can refer to an external grammar:
<dtmf src="URI" type="mime-type"/>
or to an inline grammar:
<dtmf type="mime-type">
<!-- inline dtmf grammar -->
</dtmf>
The attributes of <dtmf> are precisely those of <grammar>:
| src | The URI specifying the location of the grammar, if it is external. |
|---|---|
| scope | Either document, which makes the grammar active in all dialogs of the current document (and relevant application leaf documents), or dialog, to make the grammar active throughout the current form. If omitted, the grammar scoping is resolved by looking at the parent element. |
| type | The MIME type of the grammar. If this is omitted, the interpreter context will attempt to determine the type dynamically. |
| caching | See Section 12.1. |
| fetchhint | See Section 12.1. This defaults to the grammarfetchhint property. |
| fetchtimeout | See Section 12.1. |
Field grammars are always scoped to their fields, that is, they are not active unless the interpreter is visiting that field. Grammars contained in fields cannot specify a scope.
Link grammars are given the scope of the element that contains the link. Thus, if they are defined in the application root document, links are also active in any other loaded application document. Grammars contained in links cannot specify a scope.
Form grammars are by default given dialog scope, so that they are active only when the user is in the form. If they are given scope document, they are active whenever the user is in the document. If they are given scope document and the document is the application root document, then they are also active whenever the user is in another loaded document in the same application. A grammar in a form may be given document scope either by specifying the scope attribute on the form element or by specifying the scope attribute on the <grammar> element. If both are specified, the grammar assumes the scope specified by the <grammar> element.
<menu> grammars are also by default given dialogscope, and are active only when the user is in the menu. But they can be given the document scope and be active throughout the document, and if their document is the application root document, also be active in any other loaded document belonging to the application. Grammars contained in menu choices cannot specify a scope.
Sometimes a form may need to have some grammars active throughout the document, and other grammars that should be active only when in the form. One reason for doing this is to minimize grammar overlap problems. To do this, each individual <grammar> and <dtmf> element can be given its own scope if that scope should be different than the scope of the <form> element itself:
<form scope="document"> <grammar> … </grammar> <grammar scope="dialog"> … </grammar> </form>
When the interpreter waits for input as a result of visiting a field, the following grammars are active:
grammars for that field, including grammars contained in links in that field;
grammars for its form, including grammars contained in links in that form;
grammars contained in links in its document, and grammars for menus and other forms in its document which are given document scope;
grammars contained in links in its application root document, and grammars for menus and forms in its application root document which are given document scope.
In the case that an input matches more than one active grammar, the list above defines the precedence order. If the input matches more than one active grammar with the same precedence, the precedence is determined using document order. Menus behave with regard to grammar activation like their equivalent forms (see Section 7).
If the form item is modal (i.e., its modal attribute is set to true), all grammars except its own are turned off while waiting for input. If the input matches a grammar in a form or menu other than the current form or menu, control passes to the other form or menu. If the match causes control to leave the current form, all current form data is lost.
The platform throws events when the user does not respond, doesn't respond intelligibly, requests help, etc. The interpreter throws events if it finds a semantic error in a VoiceXML document, or when it encounters a <throw> element. Events are identified by character strings.
Each element in which an event can occur has a set of catch elements, which include:
<catch>
<error>
<help>
<noinput>
<nomatch>
An element inherits the catch elements (“as if by copy”) from each of its ancestor elements, as needed. If a field, for example, does not contain a catch element for nomatch, but its form does, the form’s nomatch catch element is used. In this way, common event handling behavior can be specified at any level, and it applies to all descendents.
The <throw> element throws an event. These can be the pre-defined ones:
<throw event="nomatch"/> <throw event="telephone.disconnect.hangup"/>
or application-defined events:
<throw event="com.att.portal.machine"/>
Attributes of <throw> are:
| event | The event being thrown. |
|---|
The catch element associates a catch with a document, dialog, or form item. It contains executable content.
<form id="launch_missiles">
<field name="password">
<prompt>What is the code word?</prompt>
<grammar>rutabaga</grammar>
<help>It is the name of an obscure vegetable.</help>
<catch event="nomatch noinput" count="3">
<prompt>Security violation!</prompt>
<submit next="apprehend_felon" namelist="user_id"/>
</catch>
</field>
<block>
<goto next="#get_city"/>
</block>
</form>
Attributes of <catch> are:
| event | The event or events to catch. |
|---|---|
| count | The occurrence of the event (default is 1). The count allows you to handle different occurrences of the same event differently. Each form item and <menu> maintains a counter for each event that occurs while it is being visited; these counters are reset each time the <menu> or form item's <form> is re-entered. |
| cond | An optional condition to test to see if the event may be caught by this element. Defaults to true. |
The <error>, <help>, <noinput>, and <nomatch> elements are shorthands for very common types of <catch> elements.
The <error> element is short for <catch event="error"> and catches all events of type error:
<error> An error has occurred -- please call again later. <exit/> </error>
The <help> element is an abbreviation for <catch event="help">:
<help>No help is available.</help>
The <noinput> element abbreviates <catch event="noinput">:
<noinput>I didn't hear anything, please try again.</noinput>
And the <nomatch> element is short for <catch event="nomatch">:
<nomatch>I heard something, but it wasn't a known city.</nomatch>
These elements take the attributes:
| count | The event count (as in <catch>). |
|---|---|
| cond | An optional condition to test to see if the event is caught by this element (as in <catch>). Defaults to true. |
An element inherits the catch elements (“as if by copy”) from each of its ancestor elements, as needed. When an event is thrown, the scope in which the event is handled and its enclosing scopes are examined to find the best qualified catch element, according to the following algorithm:
The name of a thrown event matches the catch element event name if it is either an exact match or a prefix match. A prefix match occurs when the catch element event attribute has a prefix in common with the name of the event being thrown. For example,
<catch event="telephone.disconnect">
will prefix match the event telephone.disconnect.transfer.
The interpreter is expected to provide implicit default catch handlers for the noinput, help, nomatch, cancel, exit, and error events if the author did not specify them.
The system default behavior of catch handlers for various events and errors is summarized by the definitions below that specify (1) whether any audio response is to be provided, and (2) how execution is affected. Note: where an audio response is provided, the actual content is platform dependent.
| Event Type | Audio Provided | Action |
|---|---|---|
| cancel | no | don’t reprompt |
| error | yes | exit interpreter |
| exit | no | exit interpreter |
| help | yes | reprompt |
| noinput | no | reprompt |
| nomatch | yes | reprompt |
| telephone.disconnect | no | exit interpreter |
| all others | yes | exit interpreter |
Specific platforms and locales will differ in the default prompts presented.
There are pre-defined events and application-defined events. Events are also subdivided into plain events (things that happen normally), and error events (abnormal occurrences). The error naming convention allows for multiple levels of granularity.
The pre-defined events are:
The predefined errors are:
Application-specific error types should follow the following format:
Catches can catch specific events (cancel) or all those sharing a prefix (error.unsupported).
Fetching of content from a URI occurs in a VoiceXML interpreter context to: (1) fetch VoiceXML documents to interpret, or (2) fetch other document types, such as audio files, objects, grammars, and scripts. All occasions for fetching content in a VoiceXML interpreter context are governed by the following three attributes:
| caching | Either safe to force a query to fetch the most recent copy of the content, or fast to use the cached copy of the content if it has not expired. If not specified, a value derived from the innermost caching property is used. |
|---|---|
| fetchtimeout | The interval to wait for the content to be returned before throwing an error.badfetch event. If not specified, a value derived from the innermost fetchtimeout property is used. |
| fetchhint | Defines when the interpreter context should retrieve content from the server. prefetch indicates a file may be downloaded when the page is loaded, whereas safe indicates a file that should only be downloaded when actually needed. In the case of a very large file (implying long download times) or a streaming audio source, stream indicates to the interpreter context to begin processing the content as it arrives and should not wait for full retrieval of the content. If not specified, a value derived from the innermost relevant *fetchhint property is used. |
When content is fetched from a URI, the caching attribute determines where it is located (in the cache or not), the fetchtimeout attribute determines how long to wait for the content (starting from the time when the resource is needed), and fetchhint determines when the content is fetched. The caching policies for a VoiceXML interpreter context are explained in more detail in the next section.
The fetchhint attribute is used to help interpreter contexts that can improve their performance by exploiting information about when content can be fetched. There is no requirement that an interpreter context must actually change when it fetches documents from other than a safe setting. However, any interpreter context that is capable of operating in a prefetch or stream setting, must also be able to operate under the safe setting.
When transitioning from one dialog to another, through either a <subdialog>, <goto>, <submit>, <link>, or <choice> element, there are additional rules that affect interpreter behavior. If the referenced URI names a document (e.g. "doc#dialog") or query data is provided (through POST or GET), then a new document is obtained (either from the local cache or from a server). When it is obtained, the document goes through its initialization phase (i.e., obtaining and initializing a new application root document if needed, initializing document variables, and executing document scripts). The requested dialog (or first dialog if none is specified) is then initialized and execution of the dialog begins. If the referenced URI names only a fragment (e.g. "#dialog") then no document is obtained, and no initialization of the document is performed. The requested dialog is processed as before.
Elements that fetch VoiceXML documents also support the following additional attribute:
| fetchaudio | The URI of the audio clip to play while the fetch is being done. If not specified, the fetchaudio property is used, and if that property is not set, no audio is played during the fetch. |
|---|
The fetchaudio attribute is useful for enhancing a user experience when there may be noticeable delays while the next document is retrieved. This can be used to play background music, or a series of announcements. When the document is retrieved, the audio file is interrupted if it is still playing.
The VoiceXML interpreter context, just like HTML visual browsers, can use caching to improve performance in fetching documents and other resources; audio recordings (which can be quite large) are as common to VoiceXML documents as images are to HTML pages. In a visual browser it is common to include end user controls to update or refresh content that is perceived to be stale. This is not the case for theVoiceXML interpreter context, since it lacks equivalent end user controls. Thus enforcement of cache refresh is at the discretion of the applications program through appropriate use of the caching policies employed by VoiceXMLinterpreter contexts.
The default caching policy for VoiceXML interpreter contexts is one commonly employed in HTML browsers:
If the document referenced by a URI is unexpired in the cache, then use the cached copy.
If the document referenced by a URI is expired or not present in the cache, then fetch it from the server using get. Note: it is an optimization to perform a “get if modified” on an expired document still present in the cache.
In VoiceXML this caching policy is known as fast. But because fast cache usage can lead to anomalous results, VoiceXML interpreter contexts also implement a safe caching policy:
Even if the document referenced by a URI is in the cache and is unexpired, still do a “get if modified” operation. This will force a more recent version of the document to replace the cached version, if a more recent version exists. If no more recent version exists, the server does not go to the expense of transferring the document.
If the document referenced by a URI is expired or not present in the cache, then fetch it from the server using get. Note: it is an optimization to perform a “get if modified” on an expired document still present in the cache.
The safe caching policy ensures that the VoiceXML interpreter context always has the most up to date version of a document, at the expense of performance (due to the extra access to the document server). The safe policy is similar to the effect of always reloading or refreshing a web page in an HTML visual browser.
VoiceXML allows the author to select which caching policy to use. The caching attribute of certain elements may be set to safe or fast to determine what default policy to use for that element. If the attribute is not specified, the policy is determined a <property> element that specifies a value for the caching property (see Section 17).
For example:
<?xml version="1.0"?>
<vxml version="1.0">
<!-- Elements in this document will by default use caching="fast". -->
<property name="caching" value="fast"/>
…
<form id="test">
<block>
<!-- Welcome rarely changes, so fast caching is fine. -->
<audio src="http://www.weather4U.example/vxml/welcome.wav"/>
<!-- Ads change all the time, so safe caching is needed. -->
<audio caching="safe"
src="http://www.onlineads.example/weather4U/ad17"/>
</block>
…
</form>
…
</vxml>
One common practice will be to use safe caching during development, when documents and resources change continually, and then use fast caching with selected resources fetched “safely” as the application goes into system test and then production.
It is also possible, though perhaps less likely, to have a production application that uses safe caching by default and fetches some resources using the fast caching policy.
The prompt element controls the output of synthesized speech and prerecorded audio. Conceptually, prompts are instantaneously queued for playing, so interpretation proceeds until the user needs to provide an input. At this point, the prompts are played, and the system waits for user input. Once the input is received from the speech recognition subsystem (or the DTMFrecognizer), interpretation proceeds.
Prompts have the following attributes:
| bargein | Control whether a user can interrupt a prompt. Default is true. |
|---|---|
| cond | An expression telling if the prompt should be spoken. Default is true. |
| count | A number that allows you to emit different prompts if the user is doing something repeatedly. If omitted, it defaults to “1”. |
| timeout | The timeout that will be used for the following user input. The default noinput timeout is platform specific. |
You’ve seen prompts in the previous examples:
<prompt>Please say your city.</prompt>
You can leave out the <prompt> … </prompt> if:
There is no need to specify a prompt attribute (like bargein), and
The prompt consists entirely of PCDATA (contains no speech markups) or consists of just an <audio> element.
For instance, these are also prompts:
Please say your city. <audio src="say_your_city.wav"/>
But the <prompt> … </prompt> cannot be removed from this prompt due to the embedded speech markups:
<prompt>Please <emp>say</emp> your city.</prompt>
Prompts can have markup to indicate emphasis, breaks, and prosody:
<prompt> This is <emp>also</emp> computer-generated text. <break size="medium"/> Do you like it? </prompt>
VoiceXML supports the following speech markup elements:
Specifies a pause in the speech output. Attributes of <break> are:
| msecs | The number of milliseconds to pause. |
|---|---|
| size | A relative pause duration. Possible values are: none, small, medium or large. |
At most one of msecs and size must be specified. If neither are specified, size="medium" is assumed.
Identifies the enclosed text as a particular type. Attributes of <div> are:
| type | Possible values are sentence or paragraph. |
|---|
Specifies that the enclosed text should be spoken with emphasis. Attributes of <emp> are:
| level | Specifies the level of emphasis. Possible values are: strong, moderate (default), none or reduced. |
|---|
Specifies prosodic information for the enclosed text. For details about the format of attribute values, see the Java API Speech Markup Language specification (v0.5 - August 28, 1997)
Attributes of <pros> are:
| rate | Specifies the speaking rate. |
|---|---|
| vol | Specifies the output volume. |
| pitch | Specifies the pitch. |
| range | Specifies the pitch range. |
Specifies how a word or phrase is spoken. Attributes of <sayas> are:
| phon | The representation of the Unicode International Phonetic Alphabet (IPA) characters that are to be spoken instead of the contained text. |
|---|---|
| sub | Defines substitute text to be spoken instead of the contained text. |
| class | Possible values are phone, date, digits, literal, currency, number and time. |
Sometimes text needs to be rendered using a particular style. For example, a telephone number adhering to the North American Dialing Plan needs a break after the first three digits, and another break after the second three digits. To effect this, use the class attribute:
<prompt> You are calling <value expr="home_num" class="phone"/> </prompt> <prompt>You are calling <sayas class="phone">312-555-1212</sayas> </prompt>
While the interpreter must tolerate the full set of speech markup, if its implementation platform uses a text-to-speech engine that doesn’t have this level of speech markup functionality, the platform will have to map the VoiceXML markups as best it can. Specifically, all platforms must allow all speech markup elements, and if an element with contained text is not supported, the contained text must still be spoken.
Prompts can have audio clips intermingled with synthesized speech:
<prompt> Welcome to the Bird Seed Emporium. <audio src="http://www.birdsounds.example/thrush.wav"/> We have 250 kilogram drums of thistle seed for <sayas class="currency">$299.95</sayas> plus shipping and handling this month. <audio src="http://www.birdsounds.example/mourningdove.wav"/> </prompt>
Audio can be played in any prompt. Typically it is specified via a URI, but it can also be in an audio variable previously recorded:
<prompt> Your recorded greeting is <value expr="greeting"/> To rerecord, press 1. To keep it, press pound. To return to the main menu press star M. To exit press star, star X. </prompt>
The audio tag can have alternate text (with markups) in case the audio sample is not available:
<prompt>
<audio src="welcome.wav"><emp>Welcome</emp>
to Voice Portal.
</audio>
</prompt>
If the audio file cannot be played (e.g. unsupported format, invalid URI, etc.), the content of the audio element is played instead. The content may include text, speech markup, or another audio element. If the audio file cannot be played (e.g. unsupported format, invalid URI, etc.) and the content of the audio element is empty, an appropriate error event will be thrown.
Attributes of <audio> include:
| src | The URI of the audio prompt. See Appendix E for suggested audio file formats. |
|---|---|
| caching | See Section 12.1. |
| fetchtimeout | See Section 12.1. |
| fetchhint | See Section 12.1. |
Prompts can contain embedded variable references using the <value> element:
<prompt> You are calling <value expr="home_num"/> </prompt>
Attributes of <value> are:
| expr | The expression to render. |
|---|---|
| class | The <sayas> class of the variable, e.g. phone, date, currency. The valid formats are the same as those supported in the <sayas> speech markup. |
| mode | The type of rendering: tts (the default), or recorded. |
| recsrc | The URI of the audio files to be concatenated when mode isrecorded. |
If an implementation platform supports barge-in, the service author can specify whether a user can interrupt, or “barge-in” on, a prompt. This speeds up conversations, but is not always desired. If the user must hear all of a warning, legal notice, or advertisement, barge-in should be disabled. This is done with the bargein attribute:
<prompt bargein="false"> <audio src="legalese.wav"/> </prompt>
Users can interrupt a prompt whose bargein attribute is true, but must wait for completion of a prompt whose bargein attribute is false. In the case where several prompts are queued, the bargein attribute of each prompt is honored during the period of time in which that prompt is playing. If bargein occurs during any prompt in a sequence, all subsequent prompts are not played. If bargein is not specified, then the value of the bargein property is used.
Tapered prompts are those that may change with each attempt. Information-requesting prompts may become more terse under the assumption that the user is becoming more familiar with the task. Help messages become more detailed perhaps, under the assumption that the user needs more help. Or, prompts can change just to make the interaction more interesting.
Each form item and each menu has an internal prompt counter that is reset to one each time the form or menu is entered. Whenever the system uses a prompt, its associated prompt counter is incremented. This is the mechanism supporting tapered prompts.
For instance, here is a form with a form level prompt and field level prompts:
<form id="tapered">
<block>
<prompt bargein="false">
Welcome to the ice cream survey.
</prompt>
</block>
<field name="flavor">
<grammar>vanilla|chocolate|strawberry</grammar>
<prompt count="1">What is your favorite flavor?</prompt>
<prompt count="3">Say chocolate, vanilla, or strawberry.</prompt>
<help>Sorry, no help is available.</help>
</field>
</form>
A conversation using this form follows:
C: Welcome to the ice cream survey.
C: What is your favorite flavor? (the “flavor” field’s prompt counter is 1)
H: Pecan praline.
C: I do not understand.
C: What is your favorite flavor? (the prompt counter is now 2)
H: Pecan praline.
C: I do not understand.
C: Say chocolate, vanilla, or strawberry. (prompt counter is 3)
H: What if I hate those?
C: I do not understand.
C: Say chocolate, vanilla, or strawberry. (prompt counter is 4)
H: …
When it is time to select a prompt, the prompt counter is examined. The child prompt with the highest count attribute less than or equal to the prompt counter is used. If a prompt has no count attribute, a count of “1” is assumed.
A conditional prompt is one that is spoken only if its condition is satisfied. In this example, a prompt is varied on each visit to the enclosing form.
<form id="another_joke">
<var name="r" expr="Math.random()"/>
<field name="another" type="boolean">
<prompt cond="r < .50">
Would you like to hear another elephant joke?
</prompt>
<prompt cond="r >= .50">
For another joke say yes. To exit say no.
</prompt>
<filled>
<if cond="another">
<goto next="#pick_joke"/>
</if>
</filled>
</field>
</form>
When a prompt must be chosen, a set of prompts to be queued is chosen according to the following algorithm:
All elements that remain on the list will be queued for play.
The timeout attribute specifies the interval of silence allowed while waiting for user input after the end of the last prompt. If this interval is exceeded, the platform will throw a noinput event. This attribute defaults to the value specified by the timeout property (see Section 17).
The reason for allowing timeouts to be specified as prompt attributes is to support tapered timeouts. For example, the user may be given five seconds for the first input attempt, and ten seconds on the next.
The prompt timeout attribute determines the noinput timeout for the following input:
<prompt count="1"> Pick a color for your new Model T. </prompt> <prompt count="2" timeout="120s"> Please choose color of your new nineteen twenty four Ford Model T. Possible colors are black, black, or black. Please take your time. </prompt>
If several prompts are queued before a field input, the timeout of the last prompt is used.
A form item is an element of a <form> that can be visited during form interpretation. They include <field>, <block>, <initial>, <subdialog>, <object>, <record>, and <transfer>.
All for