Weird one this week for #FridayFun
We had a recent request where I needed to set up a series of calls in the future from some action initiated by the phone user. I settled on creating .call files directly using dialplan applications, which sounds kind of dumb, but it turns out to be pretty simple way of setting up a scheduled future call. This this the subroutine:
[lgaetz-callfile]
exten => s,1,NoOp(Entering user defined context lgaetz-callfile in extensions_custom.conf)
; todo - add a check to confirm 3 args are set
exten => s,n,Set(call_filename=${ASTSPOOLDIR}/tmp/${UNIQUEID}.scheduled.call.${ARG3})
exten => s,n,System(rm -rf ${call_filename}) ; purge any existing call file with identical name - prob won't happen
exten => s,n,System(echo "Channel: Local/${ARG1}@originate-skipvm" >> ${call_filename})
exten => s,n,System(echo 'Callerid: <${ARG1}> "Scheduled Call"' >> ${call_filename})
exten => s,n,System(echo 'WaitTime: 30' >> ${call_filename})
exten => s,n,System(echo 'MaxRetries: 0' >> ${call_filename})
exten => s,n,System(echo 'Context: originate-skipvm' >> ${call_filename})
exten => s,n,System(echo 'Extension: ${ARG2}' >> ${call_filename})
exten => s,n,System(echo 'Priority: 1' >> ${call_filename})
exten => s,n,System(echo 'Archive: yes' >> ${call_filename})
; add as many variables as you need, they can be referenced directly as channel vars when
; the scheduled call occurs
exten => s,n,System(echo "Setvar: schedule_uniqueid=${UNIQUEID}" >> ${call_filename})
exten => s,n,System(echo "Setvar: call_delay=${ARG3}" >> ${call_filename})
exten => s,n,System(touch -d "+${ARG3} minutes" ${call_filename})
exten => s,n,System(mv ${call_filename} ${ASTSPOOLDIR}/outgoing)
exten => s,n,Return
Maintained here: Gentleman Caller · GitHub
Reference the sub from your dialplan with three args. To schedule a call 20 min in the future where extension 4003 rings and once answered gets bridged to the echo test feature code
GoSub(lgaetz-callfile,s,1(4003,*43,20));
.call file is created, and 20 min later the phone rings with a call to the echo test.