I am writing a java application to dial a number and get user's pin by DTMF. I am using asterisk-java connect to an asterisk VOIP server and dial the number but I don't know how to stream a file and read user's input as DTMF. Here's my code:

OriginateAction originateAction = new OriginateAction();
originateAction.setChannel("SIP/1001");
originateAction.setContext("default");
originateAction.setCallerId("Server");
originateAction.setPriority(1);

// 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 originateResponse = managerConnection.sendAction(originateAction, 30000);

// print out whether the originate succeeded or not
System.out.println(originateResponse.getResponse());

// and finally log off and disconnect
managerConnection.logoff();
有帮助吗?

解决方案

You are using AMI.

There are no way get dtmf in AMI without dialplan support. You can get event via ami using something like this in dialplan

exten => s,1,Read(variable,filetoplay)
exten => s,2,UserEvent(variable: variable)

Or you can use fastagi to control call execution and collect dtmf

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top