public class SampleVoiceXMLDialog extends CallListenerAbstract
The code below illustrates how to intercept a call and start a VoiceXML dialog.
First, to be able to intercept a call, you must implement a class that is
annotated with TheCallListener and either implement
CallListener
or extend
CallListenerAbstract
. This class is a
"listener" that allows you to intercept a call.
Next, you must implement a "VoiceXML dialog listener" class that implements VoiceXMLDialogListener. This class allows you to be notified when important events related to a VoiceXML dialog have occurred. Specifically, when the dialog ends, then the method dialogEvent will be called with the name value pairs specified in the VoiceXML document. If an error occurred starting a VoiceXML dialog then the dialogEvent will be called with the appropriate VoiceXMLDialogCause that indicates an error event.
In the callIntercepted method shown below the following occurs:
The VoiceXML dialog used in the sample is an example of an interactive voice response call that uses Text To Speech and Automatic Speech Recognition.
public class SampleVoiceXMLDialog extends CallListenerAbstract { private final Logger logger = Logger.getLogger(SampleVoiceXMLDialog.class); public class MyVoiceXMLDialogListener implements VoiceXMLDialogListener { private final Participant participant; public MyVoiceXMLDialogListener(final Participant participant) { this.participant = participant; } @Override public void dialogEvent(final UUID requestId, final Mapnames, final VoiceXMLDialogCause dialogEvent) { logger.info("VoiceXML dialog completed for " + participant); participant.getCall().allow(); } } @Override public void callIntercepted(final Call call) { final VoiceXMLDialogItem voiceXMLDialogItem = SpeechFactory.createVoiceXMLDialogItem(); try { final URI documentUrl = new URI("http://speechserver.test.com/test.vxml"); voiceXMLDialogItem.setVoiceXMLScript(documentUrl); final MyVoiceXMLDialogListener voiceXMLDialogListener = new MyVoiceXMLDialogListener(call.getCallingParty()); final UUID requestId = SpeechFactory.createSpeechService().startVoiceXMLDialog( call.getCallingParty(), voiceXMLDialogItem, voiceXMLDialogListener); logger.info("VoiceXML dialog started with requestId " + requestId.toString()); } catch(final URISyntaxException e) { logger.error("Failed to start VoiceXML dialog", e); } }
Modifier and Type | Class and Description |
---|---|
class |
SampleVoiceXMLDialog.MyVoiceXMLDialogListener |
Constructor and Description |
---|
SampleVoiceXMLDialog() |
Modifier and Type | Method and Description |
---|---|
void |
callIntercepted(Call call)
Notification of intercepted call.
|
addParticipantFailed, callAlerting, callAnswered, callOriginated, callTerminated, mediaDetected
public void callIntercepted(Call call)
CallListener
call
- the intercepted callCopyright © 2014 Avaya. All Rights Reserved.