The VoiceXML interpreter can throw a number of predefined events based on errors, telephone disconnects or user requests. You can also throw events you define that are specific to your application. When an event is thrown, the associated event handler, if it exists, is invoked. Then execution resumes in the element that was being executed when the event was thrown.
| | Predefined Events |
| | Default Event Handlers |
| | Application-Defined Event Handlers |
| | Events in Subdialogs |
| | Throwing Events |
| | Application-Defined Events |
The following standard events are predefined:
| Event | Description |
|
|
|
|
|
|
|
|
|
|
|
|
|
The following additional events are defined as BeVocal VoiceXML extensions:
| Event | Description |
|
User wants to retract the last response and go back to an earlier part of the interaction. See Chapter 7, Go-Back Facility. |
|
|
|
An outbound telephone was disconnected because the called third party hung up. Outbound telephone calls are described in Chapter 6, Controlling Outbound Calls. |
|
An outbound telephone exceeded its maximum allowed duration. |
|
An outbound telephone call was not answered within the time allowed for making the connection. |
The following standard errors are predefined:
The following additional errors are defined as BeVocal VoiceXML extensions:
Note: In a VoiceXML 2.0 document (when the value of the version attribute of the vxml tag is 2.0), the telephone.disconnect.* and error.telephone.* events have been changed to connection.disconnect.* and error.connection.*. See above.
The following predefined events are still supported in VoiceXML 1.0:
| Event | Description |
|
|
|
The following predefined errors are still supported in VoiceXML 1.0:
The BeVocal interpreter provides the following default event handlers for the predefined events and errors:
The following predefined events handler is still supported for VoiceXML 1.0.
| Event Handler | Description |
|
Although the system provides default handlers for the predefined events, you can override these handlers by providing your own event handlers in any element that can throw an event. The <catch>, <error>, <help>, <noinput>, and <nomatch> elements are event handlers.
An element in which an event may be thrown also inherits event handlers defined in its ancestor elements. For example, an event thrown within a field element may be caught by a handler in that element, or in its form, or in its document, or in its application. This inheritance of event handlers allows you to provide consistency in event handling by defining handlers at a higher level.
The method by which event handlers are inherited from ancestor elements is called as if by copy semantics in the VoiceXML 2.0 specification. It helps to think of the appropriate event-handler literally being copied into the scope of where the event was thrown. Variable references are resolved relative to the scope of the element where the event was thrown. And URL references are resolved relative to the document from which the event was thrown. For example, if you have a <catch> handler in an application root document, which is in a different directory from the main document which threw the event, URLs in the handler will be resolved to the directory of the main document. The change to URL resolution to the originating document is considered 2.0 behavior and applies only when the <vxml> tag's version attribute is set to "2.0" or greater.
Form items contain event counters that let you respond differently if the same event is thrown multiple times. For example, you may want to provide more details each time the user asks for help. The event counters are reset on each form invocation.
When an event occurs, its counter is used to select applicable event handlers:
You can set up event handlers that catch all events with a given prefix (for example, error.unsupported). Note, however, that the interpreter selects a handler based on count, scope, and document order only. A more specific handler does not take precedence. For example, if an error.unsupported.format event is thrown and the first applicable handler is for all events beginning with the prefix error.unsupported, that handler will be invoked even if the next applicable handler is for the specific event error.unsupported.format.
Within an event handler, the _event variable contains the name of the event currently being handled; the _message variable contains the message string that provides additional information about the event. If no message was supplied when the event was thrown, the _message variable is undefined.
|
||||
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml"> <help> I'm sorry. There's no help available here. <reprompt/> </help> <noinput> I'm sorry. I didn't hear anything. <reprompt/> </noinput> <nomatch> I didn't get that. <reprompt/> </nomatch> ...
|
A subdialog must catch any event that is thrown while the subdialog is being executed. If no handler for the event is found in the subdialog's execution context, a fatal error occurs, causing the interpreter to exit.
(VoiceXML 1.0 only) In VoiceXML 1.0, when a subdialog throws an event, the result depends on whether the subdialog is modal. Subdialogs are modal by default; a subdialog can be made non-modal by setting the modal attribute to false.
Note: In VoiceXML 2.0, all subdialogs are modal.
An application can throw events as follows:
| | A <throw> element throws an event; it can occur within executable content, that is, in a block or <filled> element, or an event handler. |
| | A <link> element can specify an event to be thrown when the link's grammar is matched. |
| | A <choice> element in a menu can specify an event to be thrown when the choice's grammar is matched. |
| | A <return> element in a subdialog can specify an event to be thrown after control returns to the calling dialog. |
An application can define additional events implicitly. If a tag that throws an event specifies an event other than one of the predefined events, it implicitly defines the specified event. For example, the following tag implicitly defines an event named myEvent and throws that event.
<throw event="myEvent"/>
An application can use a <catch> element to catch and handle an application-defined-event. For example:
<catch event="myEvent"> ... </catch>
| Café Home |
Developer Agreement |
Privacy Policy |
Site Map |
Terms & Conditions Part No. 520-0001-02 | © 1999-2007, BeVocal, Inc. All rights reserved | 1.877.33.VOCAL |