Author Message
ajh216
Joined: Nov 12, 2015
Messages: 1
Offline
All,

Having some troubles trying to get my snap-in to execute a call and play the desired VXML script. I have verified my VXML script is correct and is being hosted correctly. Here's the code:

//starts the call
private void doCall(String pnum){
try{
logger.info("in doCall");
Participant participant = ParticipantFactory.create("7324950228", "collaboratory.avaya.com");
Call call = CallFactory.create(participant, "pnum");
// create callListener
final MyCallListener callListener = new MyCallListener();

/ /save call ID
call.setAttribute(CallData.CALL_ID, call.getUCID());
/ /we can add attributes here too

call.initiate();

}
catch(Exception e){
logger.info("doCall: "+e.getMessage());
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
sw.toString(); // stack trace as a string
logger.info("doCall: "+sw);
}

}

public class MyCallListener extends CallListenerAbstract{
private static Logger logger = Logger.getLogger(MyCallListener.class);

public class MyVoiceXMLDialogListener implements VoiceXMLDialogListener {

//private final Participant participant;
private final Call call;

public MyVoiceXMLDialogListener(Call call)
{
this.call = call;

}

@Override
public void dialogEvent(final UUID requestId, final Map names,
final VoiceXMLDialogCause dialogEvent)
{

logger.info("Dialog Event: "+dialogEvent.toString());
if(dialogEvent == VoiceXMLDialogCause.EXITED){
logger.info("Parsing 'names' map...");

if(names != null){
//we can take action based on the attributes returned via this map
String[] namesKeys = (String[]) names.keySet().toArray();
for(int i = 0; i < names.keySet().size(); i++){
logger.info(namesKeys[i]+"\n");
}
logger.info("Value of YesorNo = "+names.get("YesorNo"));
//this is probably where we'd want to add a location as a participant...?

}
else{
logger.info("No values returned from VXML script: "+call.getAttribute(CallData.VXML_URI));
}

logger.info("'names' map parsed");
}
//call.drop();
}
}


public MyCallListener()
{

}

@Override
public final void callAnswered(Call call){

logger.info("callAnswered: call entered");
try{
//set this attribute so we know the driver picked up... this is used for repeat calling
call.setAttribute("CALL_STATUS", "OK");


final Participant participant = call.getAnsweringParty();
//add ID attribute to get uniqueness
String id = (String) participant.getCall().getAttribute(CallData.CALL_ID);

// it's the call it's supposed to be
logger.info("Call UCID - "+call.getUCID()+"; participant's call UCID - "+id);
if(call.getUCID().equalsIgnoreCase(id)){
//let's add our dialog item
VoiceXMLDialogItem vxmlItem = SpeechFactory.createVoiceXMLDialogItem();

URI u;
try {
u = new URI((String)call.getAttribute("VXML_URI"));
vxmlItem.setVoiceXMLScript(u);
logger.info("Added VXML Item: "+u.getPath());
} catch (Exception e) {
logger.info("Error setting VXML Script: "+e.getMessage());
logger.info("*"+e.getMessage());
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
sw.toString(); // stack trace as a string
logger.info("\n*Stack Trace: "+sw);
}

logger.info("vxmlItem toString() - "+vxmlItem.toString());
final UUID requestID = SpeechFactory.createSpeechService().startVoiceXMLDialog(participant, vxmlItem, this.new MyVoiceXMLDialogListener(call));
logger.info("invokeVoiceXmlDialog: Request ID is " + requestID);
}

}catch(Exception e){
logger.info("Error in callAnswered: "+e.getMessage());
logger.info("*"+e.getMessage());
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
sw.toString(); // stack trace as a string
logger.info("\n*Stack Trace: "+sw);
}

}




@Override
public final void callIntercepted(final Call call)
{
logger.info("Call Intercepted!");
try{
call.allow();
}
catch(Exception e){
logger.info(e.getMessage());
}


}


}


In my logger, I can see the call is getting to "doCall," but it is never intercepted by my listener (and obviously doesn't go through the recipient!). Can anyone point out what I might be doing wrong here?
Go to:   
Mobile view