I’ve written a few dialplans for outbound calls. I’m unfamiliar with the ‘flow’ of a dialplan because of things like pattern matching and ‘extensions’ which don’t lend themselves to the traditional imperative style of programming that I’m used to.
Here is a dialplan that currently has a problem:
[foobar_playback]
exten => _X.,1,AGI(foobarCallback.php|UpdateCallStatus|${CALLID}|7)
exten => _X.,n,AGI(foobarCallback.php|EnsureFile|${PRODUCTID}|${PRODUCTIDN})
exten => _X.,n,Answer
exten => _X.,n,GotoIf(${RECORD}="1"?rec:start)
exten => _X.,n(rec),Monitor(wav|/var/www/html/uber_sys/${CALLIDN}|m)
exten => _X.,n(start),Wait(1)
exten => _X.,n,AGI(foobarCallback.php|UpdateCallStatus|${CALLID}|11)
exten => _X.,n,Playback(custom/${PRODUCTIDN})
exten => _X.,n,Hangup
exten => h,1,GotoIf(${RECORD}="1"?rec2:end)
exten => h,n(rec2),DeadAGI(foobarCallback.php|UploadCallRecording|${CALLID}|${CALLIDN})
exten => h,n(end),DeadAGI(foobarCallback.php|UpdateCallStatus|${CALLID}|29)
exten => h,n,DeadAGI(fixdollarsign.agi)
exten => h,n,System(/var/lib/asterisk/agi-bin/UploadCallRecording.sh "${CALLID}" "${CALLIDN}" &)
exten => h,n(callstatus),System(/var/lib/asterisk/agi-bin/UpdateCallStatus.sh "${CALLID}" "${DIALSTATUS}" &)
exten => h,n(done),NoOp("Exiting here!")
It currently ‘works’ but has a problem where if the call is unsuccessful (i.e. a call is made to a wrong number) then none of the dialplan is executed, at least as far as I can tell, because our initial call to foobarCallback.php|UpdateCallStatus is never executed.
I did some reading and read about the ‘s’ extension which is used when starting a call, so is this the change I need to make (to the first line)?
exten => s,1,AGI(foobarCallback.php|UpdateCallStatus|${CALLID}|7)
To be honest, I wrote the dialplan by copying and pasting from others already-present on the server and I wasn’t sure of what I was doing, so I’m sure there’s plenty of cargo-cult code in there, such as the ‘_X., n’ stuff, and I’m not sure if I’m using ‘h,n’ correctly either.
Can someone take a look at the dialplan and let me know if my fix is appropriate, and also if it’s sensible to replace the strange ‘_X.,n’ stuff with something more understandable?
Thank you