Hello people,
I have a telephone line with n operators. In case of incoming call all n operators have their phonesets ringing. When a certain operator picks up the phone, I need AGI to catch his/her internal number + calling party’s number and send both params to some external system over http with curl.
The problem is that I cannot do this:
exten => 6,n,Dial(SIP/2001&SIP/2002&SIP/2003,20)
exten => 6,n,AGI(/var/lib/asterisk/agi-bin/script.sh)
Because AGI() will be called after the operator’s hang up.
And I cannot do like this:
exten => 6,n,AGI(/var/lib/asterisk/agi-bin/script.sh)
exten => 6,n,Dial(SIP/2001&SIP/2002&SIP/2003,20)
Because we don’t know operator’s number yet.
One of the solution that I found is to call Dial() with U() sub-function like this:
[main-context]
...
exten => 6,n,Dial(SIP/2001&SIP/2002&SIP/2003,20,U(agi-context))
[agi-context]
exten => s,1,AGI(/var/lib/asterisk/agi-bin/script.sh)
exten => s,n,Return()
Using U() I am unable to catch CALLERID(num) within [agi-context]. Setting variables in the [main-context] also does not work. I know that setting a variable with SET() in one context should be visible/accessible in another, but in fact U() breaks this logic. The only way is to set the GLOBAL variable in [main-context] and catch it in [agi-context]. But I think this is absolutely incorrect in case of having several parallel calls.
Could you advise me another way to accomplish this task?
Thank you in advance.