Hi I am trying to make an outbound call to a phone and listen for dtmf to initiate a bridge to another line and I can’t seem to get it to work. This is what I have right now but I have tried several other ways to do it. The issue is that once the 1st phone (ARG2) is answered, it immediately calls the 2nd (ARG3) without waiting for any kind of input. Also If the 1st phone is not answered it will still call the 2nd when I am trying to end the call if that happens.
[test]
exten => start,1,NoOp(Starting the call)
same => n,Dial(PJSIP/${ARG2}@call,,Tt)
same => n,GotoIf($["${DIALSTATUS}" = "ANSWER"]?connected:failed)
[connected]
exten => s,1,NoOp(ARG2 answered the call)
same => n,Playback(pgp)
same => n,WaitExten(10) ; Wait for DTMF input for 10 seconds
; Check if DTMF input was received
same => n,GotoIf($["${LEN(${EXTEN})}" = "1"]?process_input:end)
[process_input]
; Check the received DTMF digit and proceed accordingly
same => n,GotoIf($["${EXTEN}" = "1"]?initiate_call_ARG3:end)
[initiate_call_ARG3]
same => n,Dial(PJSIP/${ARG3}@call,,Tt)
same => n,Hangup()
[end]
exten => s,1,NoOp(ARG2 did not answer or the call failed)
same => n,Hangup()
I believe one issue is that the WaitExten is listening for DTMF from the caller, not the callee. Unfortunately, I don’t know an easy fix; perhaps another member will chime in.
However, I’m curious if this application could be implemented in the GUI, perhaps using call files, Callback and/or DISA. What is the purpose of this application? Please describe the desired business logic.
What initiates the process (a human, an event on the PBX, a robot running on the PBX machine, a robot running elsewhere, etc.)?
What is the 1st phone (a physical phone answered by a human, a remote robot, etc.)?
What options are available to whatever answers the 1st phone?
What is the 2nd phone, and what happens after the phones are connected?
I actually figured it out. I was Originating a call directly to an Extension then Dialing out and it was giving me issues. Now I am dialing out straight from the origination linking it to the Extension I want and going from there and using Background and WaitExten to wait for the DTMF input. Thanks for helping!
Custom script running calls through freepbx/asterisk. It basically just sends you to whatever extension I have set for a specific key, be it Local or not.