Execute Web Request on operator answer


Newbie here.
I need asterisk to execute a web request when a operator picks up a call in a queue.
I can get asterisk to send that request as soon as there is an incoming call to an extension but I need the extension of the actual operator picking up the call too.

exten => _123123,1,ExecIf($["${DIALSTATUS}"="ANSWER"]?Set(HOOK=${CURL(http://someurl.com/hooks/${CALLERID(num)}+${UNIQUEID}+${EXTEN})

I tried ExecIf but that does not seem to operate in he way I understand it: Execute api call if status of call changes to “answer”.

Any pointers? I feel like I have exhausted all options.


Queues don’t set DIALSTATUS and both Queue and Dial supervise the call, not just set it up, so any following dialplan is not run until the call ends.

ExecIf is not an event handler. It is a test of the value of the expression at point in time when it is run.

Both Queue and Dial have subroutines that can be run, on the answering channel, at the point the call is answered. That is one way of getting Curl called on answer. The curl needs to run very quickly a the call will not be fully connected until it completes.

Note that variables set in such a subroutine will require special consideration to access from the main channel, as they will only be set on the answering channel. The user of IMPORT, SHARED, of GLOBAL may be necessary.

You can send the call to a gosub and do a DumpChan() to view the channel variables and information.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.