3

I'm having a really hard time figuring out if there is a trigger or a way to continue from the Dial action that allows you to detect if the call is answered. It seems like Dial doesn't respond until hangup, busy, or congested. What action or event am I missing that would tell me when the other end of the line actually answers the call? Hoping there is something like this available that I'm just missing:

exten => s,7,Dial(${ARG1},20,rt)       ; Ring the interface, 20 seconds maximum
exten => s,8,Goto(s-${DIALSTATUS},1)                    
; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
exten => s-ANSWER(do something)
Jb1128
  • 87
  • 2
  • 10

2 Answers2

3

Finally figured it out. It involves calling the M flag in the Dial action call. By calling the M flag, you can call a custom macro that will execute immediately after the call is connected/answered.

Ex: Dial(SIP/200,60,M(myCustomMacro))

Hope this helps for any that were also curious.

Jb1128
  • 87
  • 2
  • 10
  • I'm aiming to run a shell script when a certain extension is called, and another script when the same extension finishes a call - would this be one way to go about it? – daneee Nov 20 '19 at 14:54
  • @Jb1128 Can you post your code inside extensions.conf. I faced the same problem. In addition what is ```myCustomMacro```? – Abdusoli Dec 05 '20 at 10:09
1

You can also do a Gosub when call is answered:

asterisk*cli> core show application Dial
...
    U(x[^arg[^...]]):
        x - Name of the subroutine to execute via Gosub
        arg - Arguments for the Gosub routine
Execute via Gosub the routine <x> for the *called* channel before connecting to
the calling channel. Arguments can be specified to the Gosub using '^' as a
delimiter. The Gosub routine can set the variable ${GOSUB_RESULT} to specify
the following actions after the Gosub returns
viktike
  • 717
  • 4
  • 7