Answer the question
In order to leave comments, you need to log in
How to find out the result of Originate Action by AMI?
Gentlemen, next question. I am writing a utility that will send an Originate request to Asterisk via AMI, so that he calls to a mobile phone. They gave me the data for connecting to Asterisk via AMI. I have found the Asterisk-Java library on the Internet. I make a request like this:
final ManagerConnection managerConnection;
LogManager.getLogManager().reset();
Logger globalLogger = Logger.getLogger(java.util.logging.Logger.GLOBAL_LOGGER_NAME);
globalLogger.setLevel(java.util.logging.Level.OFF);
ManagerConnectionFactory managerConnectionFactory = new ManagerConnectionFactory("XXXXX", XXXXX, "XXXXX", "XXXXX");
managerConnection = managerConnectionFactory.createManagerConnection();
OriginateAction originateAction;
ManagerResponse originateResponse;
originateAction = new OriginateAction();
originateAction.setChannel("XXXXX");
originateAction.setContext("XXXXX");
originateAction.setExten("XXXXX");
originateAction.setPriority(1);
originateAction.setAsync(false);
originateAction.setVariable("customernum", "XXXXX");
originateAction.setTimeout(new Long(30000));
try {
managerConnection.login();
originateResponse = managerConnection.sendAction(originateAction);
System.out.println("ORIGINATE RESPONSE: " + originateResponse.getResponse());
System.out.println("ORIGINATE MESSAGE: " + originateResponse.getMessage());
System.out.println("ACTION ID: " + originateAction.getActionId());
} catch (IOException e) {
e.printStackTrace();
} catch (AuthenticationFailedException e) {
e.printStackTrace();
} catch (TimeoutException e) {
e.printStackTrace();
} finally {
managerConnection.logoff();
}
Answer the question
In order to leave comments, you need to log in
You need to send a request asynchronously (async=true) and catch the OriginateResponse, in which the Reason variable contains the call result code. You can look at the code values here: www.voip-info.org/wiki/view/Asterisk+Manager+API+A... If you plan to send requests in parallel, then you need to add the actionid variable to the request and catch originateresponse with the desired actionid.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question