I have a queue that dials two extensions, and it’s needed that the answering extension calls to an external app through curl. The curl call is executed by the “e” option from dial.
[test]
exten => _X.,1,Dial(SIP/${EXTEN},150,U(curl,${EXTEN},${CALLERID(number)}))
same => n,Hangup
[curl]
exten => s,1,Set(CURLOPT(conntimeout)=1)
same => n,Set(CURLOPT(httptimeout)=1)
same => n,Set(foo=${CURL(http:/urlWithParams)})
same => n,Return()
It works, but when both extensions are answered simultaneously, curl call is executed in both, and this is wrong. I tried to get ${DIALSTATUS} in my curl context to check if it is the real answering extension, but it’s empty.
Queues would have the same problem. The issue is that originating side of the local channel isn’t being answered until the curl has been issued. I’m not sure if this is just because of the general propagation delays for the answer event, or whether U is run before the the answer is propagated, but basically you need to run the curl on the Dial with the &.
I tried to skip the second curl with a db flag, but It’s wrong because second extension has the call.
After first extension pick up the call, the second extension “steals” the call, then the problem is that the first one has sent the curl call but it hasn’t the call.
I was using dial from context because I didn’t know how to get the member who answers to send to CRM (s extension in subroutine) . Finally, I’ve found that CALLNUMBER(num) (or CHANNEL) inside the routine context gives the extension, I don’t know why it’s not the original caller number, and I suppose that there is another variable to get the extension who answered (EXTEN returns s), but it works.
I think that the problem launching the curl call from the dial function is that untill it finish the queue doesn’t that the call is answered, because changing curl call for NoOp I can’t reproduce the issue of answering two extensions simultaneously.