-
Notifications
You must be signed in to change notification settings - Fork 298
Description
Hello. Asterisk-Java is such and amazing piece of code!! Thank you for the hard work. I'm building a voice bot. A batch/API initiated process starts a call to a user's mobile phone, for example, to confirm an schedule or an order reception. As soon as the user answers the phone, the bot starts talking and they get into a normal conversation.
I'm using asteriskPBX.dial(...) to start the call (in an independent app called "dialer") and when the user answers the call, the call is attended by another independent app ("controller") which exposes a class extending Asterisk-Java's BaseAgiScript. So far, so good: the call gets done, the BaseAgiScript class receives the call control and I can send Agi actions/commands to the call via Asterisk.
However, when I used asteriskPBX.dial(...), after some seconds the call is hang up by the asterisk-java lib in dialer app with this log, so I can not continue sending commands in the controller app:
2019-05-22T16:10:23,723 DEBUG [http-nio-8080-exec-3] c.s.b.c.CallerService$CallEventCallback: ===> activity.cancelledByOperator: false
2019-05-22T16:10:23,725 DEBUG [http-nio-8080-exec-3] c.s.b.c.CallerService$CallEventCallback: ===> activity.isSuccess: false
2019-05-22T16:10:23,726 DEBUG [http-nio-8080-exec-3] c.s.b.c.CallerService$CallEventCallback: ===> activity.getLastException: {}
2019-05-22T16:10:23,727 DEBUG [http-nio-8080-exec-3] c.s.b.c.CallerService$CallEventCallback: ===> activity.getOriginatingChannel: null
2019-05-22T16:10:23,727 DEBUG [http-nio-8080-exec-3] c.s.b.c.CallerService$CallEventCallback: ===> activity.getAcceptingChannel: null
2019-05-22T16:10:23,728 DEBUG [http-nio-8080-exec-3] c.s.b.c.CallerService$CallEventCallback: ===> activity.getOriginatingEndPoint: PJSIP/101
2019-05-22T16:10:23,730 DEBUG [http-nio-8080-exec-3] c.s.b.c.CallerService$CallEventCallback: ===> activity.getAcceptingEndpoint: LOCAL/102
2019-05-22T16:10:23,733 INFO [Dial] o.a.p.i.a.DialActivityImpl: *********** begin dial out **************** [{}]
2019-05-22T16:10:23,734 INFO [Dial] o.a.p.i.a.DialActivityImpl: *********** LOCAL/102 **************** [{}]
2019-05-22T16:10:23,743 INFO [pool-3-thread-1] o.a.p.i.m.OriginateBaseClass: new channel name (proxy=2) PJSIP/101-00000011:1558559423.AJ2 [{}]
2019-05-22T16:10:23,743 DEBUG [pool-3-thread-1] c.s.b.c.CallerService$CallEventCallback: status=PROGRESS, message=Channel for PJSIP/101 is now up. [{}]
2019-05-22T16:10:23,743 DEBUG [pool-3-thread-1] c.s.b.c.CallerService$CallEventCallback: ===> activity.cancelledByOperator: false [{}]
2019-05-22T16:10:23,743 DEBUG [pool-3-thread-1] c.s.b.c.CallerService$CallEventCallback: ===> activity.isSuccess: false [{}]
2019-05-22T16:10:23,744 DEBUG [pool-3-thread-1] c.s.b.c.CallerService$CallEventCallback: ===> activity.getLastException: {} [{}]
2019-05-22T16:10:23,744 DEBUG [pool-3-thread-1] c.s.b.c.CallerService$CallEventCallback: ===> activity.getOriginatingChannel: (proxy=2) PJSIP/101-00000011:1558559423.AJ2 [{}]
2019-05-22T16:10:23,744 DEBUG [pool-3-thread-1] c.s.b.c.CallerService$CallEventCallback: ===> activity.getAcceptingChannel: null [{}]
2019-05-22T16:10:23,744 DEBUG [pool-3-thread-1] c.s.b.c.CallerService$CallEventCallback: ===> activity.getOriginatingEndPoint: PJSIP/101 [{}]
2019-05-22T16:10:23,744 DEBUG [pool-3-thread-1] c.s.b.c.CallerService$CallEventCallback: ===> activity.getAcceptingEndpoint: LOCAL/102 [{}]
2019-05-22T16:10:31,709 INFO [pool-3-thread-1] o.a.p.i.m.OriginateBaseClass: notify originate response event true [{}]
2019-05-22T16:11:01,710 ERROR [Dial] o.a.p.i.a.DialActivityImpl: dialout to LOCAL/102 failed. [{}]
2019-05-22T16:11:01,710 WARN [Dial] o.a.p.i.a.DialActivityImpl: Hanging up [{}]
2019-05-22T16:11:01,710 INFO [Dial] o.a.p.i.c.AsteriskPBX: Sending hangup action for channel: (proxy=2) PJSIP/101-00000011:1558559423.AJ2 [{}]
2019-05-22T16:11:01,715 DEBUG [Dial] c.s.b.c.CallerService$CallEventCallback: status=FAILURE, message=Failure [{}]
2019-05-22T16:11:01,715 DEBUG [Dial] c.s.b.c.CallerService$CallEventCallback: ===> activity.cancelledByOperator: false [{}]
2019-05-22T16:11:01,715 DEBUG [Dial] c.s.b.c.CallerService$CallEventCallback: ===> activity.isSuccess: false [{}]
2019-05-22T16:11:01,715 DEBUG [Dial] c.s.b.c.CallerService$CallEventCallback: ===> activity.getLastException: {} [{}]
org.asteriskjava.pbx.PBXException: OperatorEndedCall
at org.asteriskjava.pbx.internal.activity.DialActivityImpl.doActivity(DialActivityImpl.java:97)
at org.asteriskjava.pbx.internal.activity.ActivityHelper.run(ActivityHelper.java:113)
at java.lang.Thread.run(Thread.java:748)
2019-05-22T16:11:01,716 DEBUG [Dial] c.s.b.c.CallerService$CallEventCallback: ===> activity.getOriginatingChannel: (proxy=2) PJSIP/101-00000011:1558559423.AJ2 [{}]
2019-05-22T16:11:01,716 DEBUG [Dial] c.s.b.c.CallerService$CallEventCallback: ===> activity.getAcceptingChannel: null [{}]
2019-05-22T16:11:01,716 DEBUG [Dial] c.s.b.c.CallerService$CallEventCallback: ===> activity.getOriginatingEndPoint: PJSIP/101 [{}]
2019-05-22T16:11:01,716 DEBUG [Dial] c.s.b.c.CallerService$CallEventCallback: ===> activity.getAcceptingEndpoint: LOCAL/102 [{}]
I found asteriskPBX.dialToAgi and asteriskPBX.dialLocalToAgi methods, so I thought maybe I should use one of these. Using asteriskPBX.dialLocalToAgi allows me to continue the call (no hang up by the dialer app), however I'm still receiving an error log as follows:
2019-05-22T15:59:54,471 INFO [Dial SIP/((TRUNK NAME))/((HIDDEN MOBILE NUMBER)) to AGI] o.a.p.i.c.DialLocalToAgiActivity: [ ] *********** begin dial local to AGI **************** [{}]
2019-05-22T15:59:59,494 ERROR [Dial SIP/((TRUNK NAME))/((HIDDEN MOBILE NUMBER)) to AGI] o.a.p.i.c.DialLocalToAgiActivity: [ ] org.asteriskjava.manager.TimeoutException: Timeout waiting for response to Originate (actionId: 6) [{}]
org.asteriskjava.manager.TimeoutException: Timeout waiting for response to Originate (actionId: 6)
at org.asteriskjava.manager.internal.ManagerConnectionImpl.sendAction(ManagerConnectionImpl.java:862)
at org.asteriskjava.manager.DefaultManagerConnection.sendAction(DefaultManagerConnection.java:332)
at org.asteriskjava.pbx.internal.core.CoherentManagerConnection.sendAction(CoherentManagerConnection.java:340)
at org.asteriskjava.pbx.internal.core.AsteriskPBX.sendAction(AsteriskPBX.java:664)
at org.asteriskjava.pbx.internal.core.DialLocalToAgiActivity.run(DialLocalToAgiActivity.java:97)
at java.lang.Thread.run(Thread.java:748)
What's the right way to achieve my goal? (outgoing automated call attended by a bot) How should I use dialLocalToAgi or dialToAgi or dial in the right way so I don't get errors? Could you provide examples similar to this case in the Wiki? If you teach me how, I'll be glad to document that in your Wiki.
This is my extensions_custom.conf:
[bizbo-inbound]
exten => s,1,Answer()
same => n,Verbose(1,${CONTEXT}: Recibiendo llamada desde "${DID}")
same => n,Noop(Running miscapp 4: MiscApp para asterisk-java)
same => s,DumpChan()
same => n,AGI(agi://((CONTROLLER APP HOST IP))/inboundAgi)
This is how I try to use dialXXX methods:
// It's weird but the only way I can make a call with this method is inverting to and from endpoints:
asteriskPbx.dial(to, toCallerID, from, fromCallerID, new CallEventCallback(), channelVars);
// action is null because I just don't know what to use here:
asteriskPbx.dialToAgi(to, toCallerID, null, new CallEventCallback();
// Not sure o this neither:
asteriskPbx.dialLocalToAgi(to, toCallerID, new CallEventCallback(), channelVars);
Thanks a lot!!
PS:
When dialing over a trunk to and outside number (not an extension) the call could no be hang up by the dialer maybe because it is controlled by the remote trunk. Besides, I don't have any issue in the case the call is and inbound call, but that's another totally different use case.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status