Last reviewed: 3/23/2024 11:39:21 AM

Event Handling

To receive VoiceXML validation and runtime messages, applications receive event notifications.

EventEvent ArgumentsDescription
ApiErrorChantAPIErrorEventArgsNotifies the application of an API error
CompileDoneVxmlCompileDoneEventArgsNotifies the application that the compile process is done
CompileErrorVxmlCompileErrorEventArgsNotifies the application that the compiler detected a grammar error
DlgAddChoiceVxmlDlgTextEventArgsNotifies the application of an add choice event
DlgClearChoicesVxmlDlgEventArgsNotifies the application of a clear choices event
DlgClearTextVxmlDlgEventArgsNotifies the application of a clear text event
DlgCreateDialogVxmlDlgEventArgsNotifies the application of a create event
DlgHideChoicesVxmlDlgEventArgsNotifies the application of a hide choices event
DlgHideTextVxmlDlgEventArgsNotifies the application of a hide text event
DlgSelectChoiceVxmlDlgTextEventArgsNotifies the application of a select choice event
DlgSetPromptVxmlDlgTextEventArgsNotifies the application of a set prompt event
DlgSetTextVxmlDlgTextEventArgsNotifies the application of a set text event
DlgShowChoicesVxmlDlgEventArgsNotifies the application of a show choices event
DlgShowDialogVxmlDlgEventArgsNotifies the application of a show event
DlgShowTextVxmlDlgEventArgsNotifies the application of a show text event
DoneVxmlDoneEventArgsNotifies the application of a done event
LogVxmlLogEventArgsNotifies the application of a log event

Some events provide data values that are returned in argument objects. Argument data availability varies among Speech APIs.

  • ChantAPIErrorEventArgs
    • Function - API funtion name
    • Message - API error message
    • RC - API error return code
  • VxmlCompileDoneEventArgs
    • File - File name
  • VxmlCompileErrorEventArgs
    • LineNumber - Line number
    • LinePosition - Line position
    • Error - Compile error
    • Description - Compile error description
  • VxmlDlgEventArgs
    • SessionID - Session identifier
  • VxmlDlgTextEventArgs
    • SessionID - Session identifier
    • Text - Text
  • VxmlDoneEventArgs
    • LeafDocument - Leaf document name
    • Node - Node name
    • RootDocument - Root document name
    • SessionID - Session identifier
    • Variables - Collection of Event/Value pair variables
  • VxmlLogEventArgs
    • SessionID - Session identifier
    • Text - Text

Event notifications are recieved in callback routines as follows:


_VoiceXML = _VoiceXMLKit.CreateSAPI5VoiceXML();
// Register for the events
if (_VoiceXML != null)
{
    _VoiceXML.Done += VoiceXML_Done;
    ...
}

_VoiceXML = _VoiceXMLKit->CreateSAPI5VoiceXML();
if (_VoiceXML != NULL)
{
    _VoiceXML->SetDone(VoiceXMLDone);
    ...
}
    

_VoiceXML = _VoiceXMLKit->CreateSAPI5VoiceXML();
if (_VoiceXML != NULL)
{
    _VoiceXML->SetDone(VoiceXMLDone);
    ...
}
    

_VoiceXML := _VoiceXMLKit.CreateSAPI5VoiceXML();
if (_VoiceXML <> nil) then
begin
    _VoiceXML.Done := VoiceXMLDone;
    ...
end;
    

_VoiceXMLKit = new JVoiceXMLKit();
if (_VoiceXMLKit != null)
{
    // Set the callback
    _VoiceXML.setChantVoiceXMLKitEvents(this);
    // Register Callbacks
    _VoiceXML.registerCallback(ChantVoiceXMLKitCallback.CCXMDone);
    ...
}
    

_VoiceXML = _VoiceXMLKit.CreateSAPI5VoiceXML()
// Declaring the event handlers routines with Handles clause in VB automatically registers for the event notifications
Public Sub VoiceXML_Done(ByVal sender As System.Object, ByVal e As VxmlDoneEventArgs) Handles _VoiceXML.Done
    

The Voice XML object sends all notifications to the event handlers. All event data is contained in a arguments object.


private void VoiceXML_Done(object sender, VxmlDoneEventArgs e)
{
    if ((e != null) && (e.Variables != null))
    {
        ...
    }
}
    

void CALLBACK VoiceXMLDone(void* Sender, CVxmlDoneEventArgs* Args)
{
    if ((Args != NULL) && (Args->GetVariables()->GetCount() > 0))
    {
        ...
    }
}
    

void CALLBACK VoiceXMLDone(void* Sender, CVxmlDoneEventArgs* Args)
{
    if ((Args != NULL) && (Args->GetVariables()->Count > 0))
    {
        ...
    }
}
    

procedure TForm1.VoiceXMLDone(Sender: TObject; Args: TVxmlDoneEventArgs);
begin
    if ((Args <> nil) and (Args.Variables <> nil)) then
    begin
        ...
    end;
end;
    

public void done(Object sender, VxmlDoneEventArgs args)
{
    if ((args != null) && (args.getVariables() != null))
    {
        ...
    }
}
    

Public Sub VoiceXML_Done(ByVal sender As System.Object, ByVal e As VxmlDoneEventArgs) Handles _VoiceXML.Done
    If ((e IsNot Nothing) And (e.Variables IsNot Nothing)) Then
        ...
    End If
End Sub