Creating dialplan for recording outbound calls

Hi, I’ve inherited a dialplan and have been tasked with figuring out how to record all outbound calls. It appears that it used to work in some way, but now it doesn’t, and I don’t understand enough about how to fix it.

I’ve included the dialplan from extensions.conf here. Can someone guide me in the right direction?

exten           => s,1,Dial(${ARG1},20,tr)
exten           => s,2,Goto(s-${DIALSTATUS},1)
exten           => s-NOANSWER,1,Voicemail(${ARG2}@local,u)      ; No answer.
exten           => s-NOANSWER,2,Hangup
exten           => s-BUSY,1,Voicemail(${ARG2}@local,b)          ; Phone busy.
exten           => s-BUSY,2,Hangup
exten           => _s-.,1,Playback(invalid)             ; Channel unavailable.
exten           => _s-.,2,Goto(incoming,_1NXXNXXXXXX,4)
[local]
exten           => _7XXX,1,Macro(stdexten,SIP/${EXTEN},${EXTEN})
exten           =>  8000,1,Goto(incoming,s,1)
exten           => _8XXX,1,Playback(invalid)
exten           => _8XXX,2,Goto(incoming,s,1)
exten           => _9XXX,1,Playback(invalid)
exten           => _9XXX,2,Goto(incoming,s,1)
exten           => *86,1,Answer 
exten           => *86,2,Wait(.5)
exten           => *86,3,VoicemailMain(@local)
exten           => *86,4,Hangup
exten           => *87,1,Answer 
exten           => *87,2,Wait(.5)
exten           => *87,3,VoicemailMain(${CALLERID(num)}@local)
exten           => *87,4,Hangup
exten           => 9,1,Set(CALLERID(all)=9 - ${CALLERID(name)} <${CALLERID(num)}>)
exten           => 9,2,Directory(local)
exten           => 9,3,Hangup
exten           => h,1,Hangup
exten           => i,1,Hangup
exten           => t,1,Hangup
[incoming]
exten => s,1,NoOp(CALLERID = ${CALLERID(name)} - ${CALLERID(num)})
 same => n,Set(LoopCount=1) ; Set up your counter
 same => n,Set(TIMEOUT(response=6)
 same => n,Set(TIMEOUT(digit)=2)
 same => n,GotoIfTime(09:00-20:00,mon-fri,*,*?mainmenu-day,s,1)
 same => n,Goto(mainmenu-night,s,1)
[mainmenu-day]
exten => s,1,NoOP()
 same => n,Ringing()
 same => n,Wait(1)      ; ring before IVR starts
 same => n(MENU),Background(local-mainmenu-day)
 same => n,WaitExten(6) ; (3)                  ; Wait for an extension to be dialed.
exten => fax,1,Hangup()
exten => 2,1,Set(CALLERID(all)=2 - ${CALLERID(name)} <${CALLERID(num)}>)
 same => n,Queue(sales,t,,,20)
 same => n,Voicemail(7003@local,b)
 same => n,Hangup()
exten => 3,1,Set(CALLERID(all)=3 - ${CALLERID(name)} <${CALLERID(num)}>)
 same => n,Queue(custservice,t,,,20)
 same => n,Voicemail(7003@local,b)
 same => n,Hangup()
exten => 4,1,Set(CALLERID(all)=4 - ${CALLERID(name)} <${CALLERID(num)}>)
 same => n,Queue(support,t,,,20)
 same => n,Voicemail(7003@local,b)
 same => n,Hangup()
exten => 5,1,Set(CALLERID(all)=5 - ${CALLERID(name)} <${CALLERID(num)}>)
 same => n,Queue(noc,t,,,20)
 same => n,Voicemail(7003@local,b)
 same => n,Hangup()
exten => 6,1,Goto(incoming,s,1)
exten           => _7XXX,1,Macro(stdexten,SIP/${EXTEN},${EXTEN})
exten => *86,1,Goto(local,*86,1)
exten => 9,1,Set(CALLERID(all)=9 - ${CALLERID(name)} <${CALLERID(num)}>)
 same => n,Directory(local)
 same => n,Hangup()
exten => i,1,Playback(invalid)
 same => n,Goto(s,MENU)
exten => t,1,Set(LoopCount=${INC(LoopCount)}) ; Increment the counter
 same => n,GotoIf($[${LoopCount} < 3]?s,MENU) ; If we have looped fewer than 2 times jump back to the Menu
 same => n,Playback(goodbye) ; If we have looped 4 times then play Goodbye
 same => n,Hangup() ; Terminate the call
[mainmenu-night]
exten => s,1,NoOP()
 same => n,Ringing()
 same => n,Wait(5)
 same => n,Answer()
 same => n(MENU),Background(local-mainmenu-night)
 same => n,WaitExten(6) ; Remove the below 5 lines to get rid of voicemail at night
 ;same => n,Ringing()
 ;same => n,Wait(2)
 ;same => n,Voicemail(7000@local,u)
 ;same => n,Hangup()
exten => fax,1,Hangup()
exten => 1,1,Goto(enterprise-support-auth,s,1)
exten => 2,1,Set(CALLERID(all)=2 - ${CALLERID(name)} <${CALLERID(num)}>)
 same => n,Queue(sales,t,,,20)
 same => n,Voicemail(7000@local,b)
 same => n,Hangup()
exten => 9,1,Set(CALLERID(all)=9 - ${CALLERID(name)} <${CALLERID(num)}>)
 same => n,Directory(local)
 same => n,Hangup
exten => *86,1,Goto(local,*86,1)
exten => i,1,Playback(invalid)
 same => n,Goto(s,MENU)
exten => t,1,Set(LoopCount=${INC(LoopCount)}) ; Increment the counter
 same => n,GotoIf($[${LoopCount} < 3]?s,MENU) ; If we have looped fewer than 3 times jump back to the Menu
 same => n,Playback(goodbye) ; If we have looped 4 times then play Goodbye
 same => n,Hangup() ; Terminate the call
[enterprise-support-auth]
exten           => s,1,Authenticate(/etc/asterisk/enterprise-customers.txt,a)
exten           => s,2,Goto(enterprise-support,s,1)
exten           => s,3,Hangup
exten           => i,1,Hangup
exten           => h,1,Hangup
exten           => t,1,Hangup
[enterprise-support]
exten           => s,1,Voicemail(7999@local,)
exten           => s,2,Hangup
exten           => i,1,Hangup
exten           => h,1,AGI(enterprise-support.agi,1)
exten           => t,1,Hangup
[enterprise-support-callback]
exten           => s,1,Background(local-enterprise-support-callback-dial-7999)
exten           => s,2,Wait(1)
exten           => s,3,Goto(enterprise-support-callback,s,1)
exten           => s,4,Hangup
exten           => i,1,Goto(enterprise-support-callback,s,1)
exten           => *,1,Goto(local,*86,1)
[incoming-sales]
exten           => s,1,NoOp(CALLERID = ${CALLERID(name)} - ${CALLERID(num)})
exten           => s,2,Macro(stdexten,SIP/7004,7004)
exten           => s,2,Goto(incoming,_1NXXNXXXXXX,1)
exten           => s,3,Goto(incoming,_1NXXNXXXXXX,1)
exten           => s,4,Hangup
[invalid]
exten           => s,1,Hangup
exten           => h,1,Hangup
exten           => i,1,Hangup
exten           => t,1,Hangup
[network-outage] 
exten           => s,1,AGI(network-outage.agi,1)
exten           => s,2,Answer
exten           => s,3,Hangup
exten           => i,1,Hangup
exten           => h,1,Hangup
exten           => t,1,Hangup
[network-outage-callback]
exten           => s,1,Background(local-network-outage);
exten           => s,2,Wait(1)
exten           => s,3,Goto(network-outage-callback,s,1)
exten           => s,4,Hangup
[default]
exten           => s,1,Goto(incoming,_1NXXNXXXXXX,1)
exten           => h,1,Hangup
exten           => i,1,Hangup
exten           => t,1,Hangup
[trusted]
include         => local
include         => outgoing
include         => testing
exten           => _*7XXX,1,Answer
exten           => _*7XXX,2,Ringing
exten           => _*7XXX,3,Wait(30)
exten           => _*7XXX,4,Voicemail(${EXTEN:1}@local,u)
exten           => _*7XXX,5,Hangup
exten           => 8000,1,Set(TIMEOUT(absolute)=21)
exten           => 8000,2,AGI(intercom.agi,${CALLERID(num)})
exten           => 8000,3,Page(${CANDIDATES}) 
exten           => h,1,NoOp([trusted] CALL ENDING -- ${STRFTIME(${EPOCH},,%m/%d/%Y - %H:%M:%S)})
[testing]
exten           => 200,1,Goto(mainmenu-day,_1NXXNXXXXXX,1)
exten           => 201,1,Goto(mainmenu-night,_1NXXNXXXXXX,1)
exten           => 202,1,Goto(incoming,_1NXXNXXXXXX,1)
exten           => 203,1,MusicOnHold()
exten           => 300,1,Answer
exten           => 300,2,Ringing
exten           => 300,3,Wait(1)
exten           => 300,4,Echo
exten           => 300,5,Hangup
exten           => 1102,1,Answer
exten           => 1102,2,Ringing
exten           => 1102,3,Wait(3)
exten           => 1102,4,Milliwatt()
exten           => 1102,5,Hangup
exten           => 31337,1,ChanSpy(SIP,q)
exten           => 31337,2,Hangup
[outgoing]
exten           => h,1,Hangup
exten           => i,1,Hangup
exten           => t,1,Hangup
exten   => _91NXXNXXXXXX,1,AGI(make-outgoing.agi,${CALLERID(num)},${EXTEN})
exten   => _91NXXNXXXXXX,2,Set(CALLERID(all)=)
exten   => _91NXXNXXXXXX,3,Goto(outgoing,_1NXXNXXXXXX,3);
exten   => _1NXXNXXXXXX,1,AGI(make-outgoing.agi,${CALLERID(num)},${EXTEN})
exten   => _1NXXNXXXXXX,1,Set(CALLFILENAME=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${EXTEN}-${CALLERIDNUM}-${EXTEN:1})
exten   => _1NXXNXXXXXX,2,Set(CALLERID(all)=12015557300)
exten   => _1NXXNXXXXXX,2,Monitor(wav,${CALLFILENAME},m)
exten   => _1NXXNXXXXXX,3,NoOp([outgoing] STARTING -- ${STRFTIME(${EPOCH},,%m/%d/%Y - %H:%M:%S)})
exten   => _1NXXNXXXXXX,1,Set(CALLFILENAME=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${EXTEN}-${CALLERIDNUM}-${EXTEN:1})
exten   => _1NXXNXXXXXX,2,Monitor(wav,${CALLFILENAME},m)
exten   => _1NXXNXXXXXX,3,Goto(outgoing,${EXTEN:1},1);
exten   => _1NXXNXXXXXX,4,Dial(DAHDI/${CHANNEL_OV}/${DIAL_OV})
exten   => _011.,1,Set(CALLERID(all)=12015557300)
exten   => _011.,4,Congestion```

Look at your dialplan definitions for your outgoing context.

I see multiple extensions with the same priority.