2
votes

I'm developing a java application that should be able to call another party using Java-Asterisk and get a DTMF value from user. I am using originate command of AMI and I'm stuck. I can call the other party but the call is ended immediately after answering and returns success.
How can I originate a call and read a DTMF value?

1
This question is exactly same as you asked 2 day ago. stackoverflow.com/questions/23472983/… . I am sorry, you have read some books to understand answers.arheops
i believe that i can use AMI's originate function to connect a user to an application but can not figure how. the documentation is very weak. for know i am using call files but i dont like it!hkazemi
i have read this book: "Asterisk Cookbook - O´Reilly - Chapter 2 - Call Control ". I have to be able to use originate functionhkazemi
I am sorry, you have read FULL book to understand dialplan.arheops

1 Answers

1
votes
OriginateAction originateAction = new OriginateAction();
   originateAction.setChannel("SIP/1001");
   originateAction.setContext("from-internal");
   originateAction.setExten("1002");
   originateAction.setCallerId("Server");
   originateAction.setPriority(1);
   originateAction.setTimeout(30000);

   // connect to Asterisk and log in
   managerConnection.login();
   //send the originate action and wait for a maximum of 30 seconds for Asterisk
   // to send a reply
   ManagerResponse response= managerConnection.sendAction(originateAction, 30000);

The Originate action in the AMI allows you to send a request over a TCP connection for Asterisk to make a call. This is the most popular method for originating calls from custom applications. The example provided in the solution starts by having Asterisk make a new call to SIP/1001. If the phone does not answer within 30 seconds, the call will be aborted. If the call is answered, it is connected to extension 1002 in the from-internal context in the dialplan. After calling 1002 extension all i need to read DTMF is this:

public class HelloAgiScript extends BaseAgiScript {
public void service(AgiRequest request, AgiChannel channel) throws AgiException
{

    // Answer the channel...
    answer();

    // ...say hello and get DTMF data...
    String data = getData("welcome");

    // ...and hangup.
    hangup();
}

}

click here to see the original HelloAgiScript.