Event handling

Types of events

An event is thrown by the VoiceXML platform for any number of reasons, such as a user not responding to an input, not responding correctly, requesting help, etc. An event is also thrown if there is a semantic error in the VoiceXML document, or when the <throw> element is encountered. The <throw> element generates an event (user-defined or system) and the <catch> element catches the event thrown by the VoiceXML document, dialog, or form item.

Throw element

The <throw> element generates predefined or user-defined events. An example of the use of the <throw> element is:

 <throw event="nomatch"/>

In this case, an event is generated when an input by the user is not recognized as part of the active grammar. The attribute for the <throw> element is event, which defines the event to be thrown.

Catch element

The <catch> element catches the event thrown by the VoiceXML document, dialog, or form item. An example of the use of the <catch> element is:

 <catch event="nomatch"/>
  <throw event="event.password.invalid"/>
 </catch>

The following is a set of catch elements available: