P
P
Pavel Shvedov2015-02-27 18:22:13
Java
Pavel Shvedov, 2015-02-27 18:22:13

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();
}

As a result, everything rings, the settings are all correct. But ORIGINATE RESPONSE is always SUCCESS and ORIGINATE MESSAGE is always Originate successfully queued.
But the problem is that I need to know how the user reacted to the call (was available or not, picked up the phone or not, etc...). How can I change the method of sending a message (maybe I can advise to fix something in the asterisk settings, I’m not boom-boom in its config, but I have access to the admins) in order to receive some kind of feedback in this or that situation? Help mi pliz, the project is on fire)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2015-02-27
@mmmaaak

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.

V
Vladimir, 2015-02-27
@rostel

by changing the request, this cannot be achieved
; you need to listen to events and parse them

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question