Playing a prerecorded message on outbound calls that get to a voicemail

We have FreePBX 14 running Asterisk 16. What we are trying to do is for outbound callers that reach a customer’s voicemail. We want the caller/agent to be able to play a prerecorded message once the voicemail message has completed. We have used the following code for a while and it generally works pretty well. However, some times it will cut off the message and the reason for this post, it will often wind up back in the agent’s voicemail.

IOW, I call a number, I hear the voicemail message start, I then do a blind transfer to a custom extension that then waits for a period of silence, plays a message and then hangs up.

exten => 22,1,answer()
exten => 22,2,Set(NOW=${EPOCH})
exten => 22,3,Set(DAY=${STRFTIME(${NOW},,%d)})
exten => 22,4,Set(MONTH=${STRFTIME(${NOW},,%m)})
exten => 22,5,Set(YEAR=${STRFTIME(${NOW},,%Y)})
exten => 22,6,Set(TIMESTR=${YEAR}${MONTH}${DAY}-${STRFTIME(${NOW},,%H%M%S)})
exten => 22,7,Set(MON_FMT=${IF($["${MIXMON_FORMAT}"="wav49"]?WAV:${MIXMON_FORMAT})})
exten => 22,8,Set(CALLTYPE=external)
exten => 22,10,Monitor(${MON_FMT},${MIXMON_DIR}${YEAR}/${MONTH}/${DAY}/${CALLFILENAME},m)
exten => 22,11,Set(CDR(recordingfile)=${CALLFILENAME}.${MON_FMT})
exten => 22,12,Playback(silence/1)
exten => 22,13,WaitForSilence(1000,1)
exten => 22,14,Playback(custom/amd_message)
exten => 22,15, Hangup()

Is this a reasonable way to do this? Is there anything amiss in my dialplan? Is there a better way to do this?

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