Hello everyone,
because 3cx lost a feature (on answered call redirect to open agent) we want to let asterisk only take over this part. We have set up asterisk to receive http requests with ARI. The number to call, the callerid and agent number to redirect to are in the json body of the request. These variables are already readable in the dialplan.
We’re having trouble redirecting correctly.
I’ve already tried splitting the logic into different exten but this doesn’t seem to change much.
The problem right now is this:
Basically if the number_to_call is answered it calls REDIRECTTO and if this gets answered the first number is getting called AGAIN for some reason (It shows HTTP Call Trigger in the log)? And if this call is not answered it hangs up the call between the 2 already talking numbers. What concept of asterisk am I missing?
[globals]
REDIRECTTO=
[outbound]
exten => outboundStart,1,NoOp(HTTP Call Trigger)
same => n,NoOp(${callerid})
same => n,NoOp(${number_to_call})
same => n,NoOp(${redirect_to})
same => n,Set(REDIRECTTO=${redirect_to})
same => n,Set(CALLERID(num)=${callerid})
same => n,Set(TRANSCODED_CODEC=g722)
same => n,Dial(PJSIP/${number_to_call}@easybell,10,G(outbound-redirect,redirStart,1))
[outbound-redirect]
exten => redirStart,1,NoOp(Call Answered, redirecting to ${REDIRECTTO})
same => n,Dial(PJSIP/${REDIRECTTO}@easybell,10)
Here is a simpler test of this behaviour. Is there some way to prevent this kind of loopback?
Global vars also get reset after the the 2nd start.
This is with Asterisk 20.12.0 btw.
[outbound]
exten => http,1,NoOp(-------------------------------HTTP Call Trigger)
same => n,Answer()
same => n,HangUp()
-- Called http@outbound
-- Executing [http@outbound:1] NoOp("Local/http@outbound-00000015;2", "-------------------------------HTTP Call Trigger") in new stack
-- Executing [http@outbound:2] Answer("Local/http@outbound-00000015;2", "") in new stack
-- Local/http@outbound-00000015;1 answered
-- Executing [http@outbound:1] NoOp("Local/http@outbound-00000015;1", "-------------------------------HTTP Call Trigger") in new stack
-- Executing [http@outbound:2] Answer("Local/http@outbound-00000015;1", "") in new stack
-- Executing [http@outbound:3] Hangup("Local/http@outbound-00000015;1", "") in new stack
== Spawn extension (outbound, http, 3) exited non-zero on ‘Local/http@outbound-00000015;1’
== Spawn extension (outbound, http, 2) exited non-zero on ‘Local/http@outbound-00000015;2’
You’ve instructed it to do that, so you need to tell it to do something else. The request means this as you’re doing it:
Dial extension “outboundStart” in context “outbound”. Upon answer send the call to “outboundStart” in context “outbound”. You’ve instructed Asterisk to send the call to the same place upon answer. If you want it to go somewhere else, you need to specify somewhere else.
Ah gotcha. I thought I needed to put the if answered go there logic in the dialplan but the http request specifies that already. Here is my new dialplan:
[outbound]
exten => http,1,NoOp(----------------HTTP Call Trigger)
same => n,Set(CALLERID(num)=${callerid})
same => n,Set(TRANSCODED_CODEC=g722)
same => n,Dial(PJSIP/${number_to_call}@easybell,10)
[redirect]
exten => redirectStart,1,NoOp(----------------- REDIRECT START)
same => n,Set(CALLERID(num)=${callerid})
same => n,Set(TRANSCODED_CODEC=g722)
same => n,Dial(PJSIP/${redirect_to}@easybell,10)