[asterisk-users] Triggering an AGI script when a queued call is answered

A J Stiles asterisk_list at earthshod.co.uk
Thu Nov 24 11:20:54 CST 2016

Many years ago, I used to have an AGI script that fired on an incoming call, 
did some database lookups and ended up raising a notification on the screen of 
the person whose phone was ringing, with the details looked up from the 
incoming caller ID.

All that fell by the wayside when Debian Squeeze introduced KDE4 and the 
notification system I had created stopped working.  And some time after that, 
we introduced queues instead of everyone having their own direct inbound 
number .....

Now, some tie-wearer is dribbling on me to bring back the old system.

I am confident that I could write something that will work with the new cross-
desktop notification model  (and in any case, that is a matter for Elsewhere On 
The Internet).  However, I am going to need to hook it into Asterisk somehow.

What I think I need is for an event to fire when someone answers a queued call; 
then I can run an AGI script, or execute a script using the System() command.  
Within my script, I need the variable ${CALLERID(num)} to look up the caller's 
details from their number, and the answering extension to decide where to send 
the notification.

Is there a way of specifying in the dialplan or queue configuration that I want 
to execute a script when an agent answers?

So far, all I can think of is joining local channels into the queue instead of 
the actual phones, so I get to run a bit of dialplan where I can kick off the 
AGI script and then Dial() the actual extension; but that could get terribly 
unwieldy if not done extremely carefully.

(Of course, the manager in question also insists for me to implement all this 
without a moment's downtime.  Kids, this is what happens when your brain is 
deprived of oxygen .....)


Note:  Originating address only accepts e-mail from list!  If replying off-
list, change address to asterisk1list at earthshod dot co dot uk .

More information about the asterisk-users mailing list