Autodial and play prerecorded message when callee answer

autodialer]
; Entry point for outbound calls
exten => s,1,Wait(0.5) ; Small pause before proceeding
exten => s,n,Progress() ; Send progress tone while ringing
exten => s,n,NoOp(Waiting for answer)
exten => s,n,Wait(1) ; Wait for answer
exten => s,n,Answer() ; Answer once the remote party picks up
exten => s,n,Set(RETRIES=0)
exten => s,n,Goto(play-ivr,1)

; IVR playback and retry logic
exten => play-ivr,1,NoOp(Playing IVR, attempt ${RETRIES})
exten => play-ivr,n,Playback(/var/lib/asterisk/sounds/autodialer/custom-ivr)
exten => play-ivr,n,WaitExten(5)
exten => play-ivr,n,Set(RETRIES=${MATH(${RETRIES} + 1)})
exten => play-ivr,n,GotoIf($[${RETRIES} < 3]?play-ivr,1:h,1)

; When caller presses any key
exten => 1,1,Goto(forward-call,1)
exten => 2,1,Goto(forward-call,1)
exten => 3,1,Goto(forward-call,1)
exten => 4,1,Goto(forward-call,1)
exten => 5,1,Goto(forward-call,1)
exten => 6,1,Goto(forward-call,1)
exten => 7,1,Goto(forward-call,1)
exten => 8,1,Goto(forward-call,1)
exten => 9,1,Goto(forward-call,1)
exten => 0,1,Goto(forward-call,1)

; Forward call to VitalPBX
exten => forward-call,1,NoOp(Forwarding call to VitalPBX)
exten => forward-call,n,Set(KEY_PRESSED=${EXTEN})
exten => forward-call,n,System(php /var/www/html/autodialer/track_press.php ${PHONE_ID} ${KEY_PRESSED})
exten => forward-call,n,Set(VITAL_TRUNK=${SHELL(php -q /var/www/html/autodialer/get_vital_trunk.php)})
exten => forward-call,n,Dial(SIP/${VITAL_TRUNK}/${DID_NUMBER})
exten => forward-call,n,Hangup()

; Handle hangup event
exten => h,1,NoOp(Call ended - ${DIALSTATUS})
exten => h,n,System(php /var/www/html/autodialer/update_status.php ${PHONE_ID} ${DIALSTATUS})

can you help fix this dial plan? call rings sometimes, the prerecorded sound always starts playing before it rings the callee and sometimes it comes as missed call.

this is what i want to achieve i want to dial the number then when it ring after callee answers the call they would listen to ivr when callee press 1 or any key it send to vitalpbx

You should show what actually happens when it doesn’t work. Asterisk could very well be working fine, but the upstream provider is the problem.

You haven’t done anything that would cause a tone to be generated!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.