AsyncAGI from AMI with AsterNET

Oct 22, 2014 at 3:52 PM
Edited Oct 22, 2014 at 5:31 PM
Hi all,

I want to thank the community and specially skrusty for his work.

I need advice. I try to make an validation system for a web site using a phone call. The client have to input on a web form the 5 random number he got from the call.

I have read asterisk documentation for AMI and AGI !

Now I would like to do the following proof of concept :
  • On connect button click -> authenticate to AMI ( WORKS! )
  • On call button click -> AMI Originate action with only channel and application like this :
            OriginateAction oc = new OriginateAction();
            oc.Channel = "SIP/myTrunk/ACustomerPhoneNumber";
            oc.Application = "AGI";
            oc.Data = "agi:async";
            oc.CallerId = "AGI SCRIPT";
            oc.Timeout = 40000;
** This is actually placing the call.... my phone rings if I send this action thru AMI. ( WORKS ! )
  • ISSUES STARTS HERE : as per documentation ( see here ), after my previous call to AGI(agi:async) I should start listening for an AsyncAgi Event, then find a way to match my first AMI call to this Event so I can get the current open channel.
From asterisk cli with verbose of 5 I can see the following happened :
       > Channel SIP/mytrunk-00000005 was answered.
       > Launching AGI(agi:async) on SIP/mytrunk-00000005
Where can I get this channel value from in AsterNET ???

I if am not mistaken AsterNet does not implement this event and event handler yet ?
  • At this point if I know the channel holding the call I have originated, I should be able to send AMI action containing AGI instructions that will be added to the call queue in order to play a message and read the 5 code audio file I have uploaded to asterisk as per my random generated pin number.
Right now I am stuck a step 3. Is the only solution to implement the AsyncAGI event and handler my self in the framework ?

Please help me, I want to open the code after so anybody can do the same.
Oct 22, 2014 at 4:26 PM
Why isn't the last version binaries source code available ?
Oct 22, 2014 at 6:26 PM
Hi, thanks for the feedback.
  1. The source for the latest version is available via the source code tab at the top of the page, each released is matched to a specific commit, so it's easy to see there have been no commits to the main branch since the release of asternet 1.0.0.
  2. Regarding the channel id, the honest answer is off hand i can't remember. Have you seen if the new channel event is linked via your own custom actionid?
Oct 22, 2014 at 6:55 PM
Hi skrusty,

Thank you for the quick answer :)

The new channel event does not have an ActionId property... any other suggestion ?
Oct 22, 2014 at 7:29 PM
I am sure there must be a nicer way to do it, but a quick hack might be to create a variable on the Originate that you can then pickup when it gets set by Asterisk on the child channel. Not pretty, bit it should work! If you make sure it's an inherited variable, any other channels involved in the call should also get picked up using this method.

Hope that gives you an intermediate solution!
Nov 25, 2014 at 7:50 AM
webzfactory wrote:
Hi skrusty,

Thank you for the quick answer :)

The new channel event does not have an ActionId property... any other suggestion ?
Hey Webzfactory,

Did you find a solution for this?
Nov 25, 2014 at 1:38 PM
As a work around you can use the account field which you set with your originate action and is then bound to all the sub actions. Or you can use polymorphism on events and use them as generic ManagerEvent and work from there.
Nov 28, 2014 at 8:32 AM
or perhaps actionId?