This is my extensions.conf code.
[general]
static=yes
writeprotect=no
autofallthrough=yes
dtmfmode=rfc2833
[default]
exten => 0112019510,1,Answer() ; Replace 'SIP/chandima' with the appropriate endpoint or device
same => n,Playback(welcomedmse)
[software_agent]
exten => 0773451602,1,NoOp(call to SOFTWARE AGENT MOBILE NUMBER)
same => n,Dial(PJSIP/0773451602@my_sip_trunk,20)
same => n,Hangup()
exten => 0770840517,1,NoOp(call to SOFTWARE AGENT MOBILE NUMBER)
same => n,Dial(PJSIP/0770840517@my_sip_trunk,20)
same => n,Hangup()
exten => 0787733966,1,NoOp(call to SOFTWARE AGENT MOBILE NUMBER)
same => n,Dial(PJSIP/0787733966@my_sip_trunk,20)
same => n,Hangup()
[outbound-calls]
; Context for handling specific outbound call scenarios
exten => _X.,1,NoOp(Making outbound call to ${EXTEN})
; Dial the number and set the call to jump to priority 2 if the call is answered
same => n, Dial(PJSIP/${EXTEN}@my_sip_trunk,30,g)
; Priority 2, execute if the call is answered
same => n, Background(welcome_en)
same => n, Hangup()
[call_barging]
exten => 7005,1,Answer()
same => n,Wait(1)
same => n,ChanSpy(PJSIP/6002,qb)
same => n,Hangup()
[from_external]
include => call_barging
exten => 6001,1,Dial(PJSIP/6001)
exten => 6002,1,Dial(PJSIP/6002)
exten => 6005,1,Dial(PJSIP/6005)
exten => 601,1,NoOp(call to Sachith(6001))
same => n,Dial(PJSIP/6001)
same => n,Hangup()
exten => 602,1,NoOp(call to Chandima(6002))
same => n,Dial(PJSIP/6002)
same => n,Hangup()
; OUTBOUND Configuration
exten => _X.,1,NoOp(Outbound call from ${CALLERID(all)})
same => n,Set(UNIQUEID=${UNIQUEID})
same => n,MixMonitor(/var/spool/asterisk/monitor/${UNIQUEID}.wav)
same => n,Dial(PJSIP/${EXTEN}@my_sip_trunk)
same => n,Hangup()
; INBOUND CONFIGURATION
exten => _0112019510,1,NoOp(Incoming call from ${EXTEN})
same => n,Set(DIALED_NUMBER=${EXTEN})
same => n,Goto(dmse_IVR,s,1)
exten => _0112019511,1,NoOp(Incoming call from ${EXTEN})
same => n,Set(DIALED_NUMBER=${EXTEN})
same => n,Goto(dmse_IVR,s,1)
exten => _0112019512,1,NoOp(Incoming call from ${EXTEN})
same => n,Set(DIALED_NUMBER=${EXTEN})
same => n,Goto(dmse_IVR,s,1)
exten => _0112019513,1,NoOp(Incoming call from ${EXTEN})
same => n,Set(DIALED_NUMBER=${EXTEN})
same => n,Goto(dmse_IVR,s,1)
exten => _0112019514,1,NoOp(Incoming call from ${EXTEN})
same => n,Set(DIALED_NUMBER=${EXTEN})
same => n,Goto(dmse_IVR,s,1)
exten => _0112019516,1,NoOp(Incoming call from ${EXTEN})
same => n,Set(DIALED_NUMBER=${EXTEN})
same => n,Goto(dmse_IVR,s,1)
exten => _0112019517,1,NoOp(Incoming call from ${EXTEN})
same => n,Set(DIALED_NUMBER=${EXTEN})
same => n,Goto(dmse_IVR,s,1)
exten => _0112019518,1,NoOp(Incoming call from ${EXTEN})
same => n,Set(DIALED_NUMBER=${EXTEN})
same => n,Goto(dmse_IVR,s,1)
exten => _0112019519,1,NoOp(Incoming call from ${EXTEN})
same => n,Set(DIALED_NUMBER=${EXTEN})
same => n,Goto(dmse_IVR,s,1)
; testing to 515 call routing
exten => _0112019515,1,NoOp(Incoming call from ${EXTEN})
same => n,Set(DIALED_NUMBER=${EXTEN})
same => n,Goto(ip_phone,s,1)
[ip_phone]
exten => s,1,NoOp(Transferring call directly to IP 172.20.10.101)
same => n,Dial(PJSIP/105)
same => n,Hangup()
[dmse_IVR]
exten => s,1,Answer()
same => n,Set(FILENAME=/var/log/asterisk/call_log.txt)
same => n,Set(CALL_DETAILS=${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)} - Caller ID: ${CALLERID(num)}, Button Pressed: 2, Unique ID:${CONFID})
same => n,System(echo "${CALL_DETAILS}" >> ${FILENAME})
same => n,Set(TEST_MESSAGE=Testing logging)
same => n,System(echo "${TEST_MESSAGE}" >> ${FILENAME})
; Use DIALED_NUMBER directly to set DESTINATION_NUMBER
same => n,Set(DESTINATION_NUMBER=${DIALED_NUMBER})
same => n,Set(CDR(userfield)=${DIALED_NUMBER}) ; Optional: Set custom CDR userfield
same => n,Set(CDR(destination_number)=${STRFTIME(${EPOCH},,%Y%m%d%H%M%S)}${CALLERID(num)})
same => n,Set(tries=0)
same => n,Goto(time_selection,s,1)
[time_selection]
exten => s,1,NoOp(Entering into the system at ${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)})
same => n,GotoIfTime(00:01-23:59,,,*?day_ivr,s,1)
same => n,Goto(night_ivr,s,1)
[day_ivr]
exten => s,1,NoOp(Daytime IVR)
same => n,Goto(annoucement_1,s,1)
[night_ivr]
exten => s,1,NoOp(Nighttime IVR)
same => n,Dial(PJSIP/6001)
same => n,Answer()
same => n,Playback(nighttime-greeting)
same => n,Wait(1)
same => n,Hangup()
[annoucement_1]
exten => s,1,NoOp(Incoming Call In Daytime)
same => n,Set(TIMEOUT(digit)=1)
same => n,WaitExten(1)
same => n,Set(UNIQUEID=${UNIQUEID})
same => n,MixMonitor(/var/spool/asterisk/monitor/${UNIQUEID}.wav)
same => n,Background(Welcome-to-DMS-Electronic-1)
same => n, WaitExten(1)
same => n,Goto(annoucement_2,s,1)
; MAIN MENU
[annoucement_2]
exten => s,1,NoOp(Incoming call from Annoucement_1)
same => n,Set(TIMEOUT(digit)=1)
same => n,Background(Contact-the-sales-1)
same => n,Background(press-one-1)
same => n,Background(Contact-the-Service-1)
same => n,Background(press-two-1)
same => n,Background(Contact-the-Transaction-P-1)
same => n,Background(press-three-1)
same => n,Background(Contact-the-Service-Cente-1)
same => n,Background(press-four-1)
same => n,Background(Contact-the-Operator-Assi)
same => n,Background(press-five-1)
same => n,Background(Listen-again-the-menu-1)
same => n,Background(press-star-key-1)
same => n,Background(end-the-call-1)
same => n,Background(press-zero-1)
same => n,WaitExten(10)
same => n,Set(tries=$[${tries} +1])
same => n,GotoIf($[${tries}>=3]?Hangup,s,1)
same => n,Playback(We-have-not-received-vali-1)
same => n,WaitExten(1)
same => n,Goto(annoucement_2,s,1)
;If user press 1, go to sales
exten => 1,1,NoOp(User Pressed 1, Goto Annoucement_3 Sales Menu)
same => n,Verbose(1, User pressed 1)
same => n,Set(MENU_NAME="sales")
same => n,Goto(annoucement_3,s,1)
;If user press 2, go to Service
exten => 2,1,NoOp(User Pressed 2, Goto Service Menu)
same => n,Verbose(1, User pressed 2)
same => n,Set(MENU_NAME="service")
same => n,Goto(annoucement_7,s,1)
;If user press 3, go to Transaction Processing System
exten => 3,1,NoOp(User Pressed 3, Goto Transaction Processing System)
same => n,Verbose(1, User pressed 3)
same => n,Set(MENU_NAME="transactionProcesSystem")
same => n,Goto(annoucement_14,s,1)
;If user press 4, go to Service Center
exten => 4,1,NoOp(User Pressed 4, Goto Service Center)
same => n,Verbose(1, User pressed 4)
same => n,Set(MENU_NAME="serviceCenter")
same => n,Goto(annoucement_8,s,1)
;If user press 5, go to Operator Assistance
exten => 5,1,NoOp(User Pressed 5, Operator Assistance)
same => n,Verbose(1, User pressed 5)
same => n,Set(MENU_NAME="operatorAssistance")
same => n,Goto(annoucement_15,s,1)
exten => 6,1,NoOp(User Pressed 6, Wrong Input)
same => n,Verbose(1, User pressed 6)
same => n,Set(tries=$[${tries} +1])
same => n,Goto(testVoicemail,s,1)
;same => n,GotoIf($[${tries}>=3]?Hangup)
same => n,Playback(Wrong-Input-1)
same => n,WaitExten(1)
same => n,Goto(annoucement_2,s,1)
;exten => 7,1,NoOp(User Pressed 7, Wrong Input)
;same => n,Verbose(1, User pressed 7)
;same => n,Set(tries=$[${tries} +1])
;same => n,GotoIf($[${tries}>=3]?Hangup)
;same => n,Playback(Wrong-Input-1)
;same => n,WaitExten(1)
;same => n,Goto(annoucement_2,s,1)
exten => 7,1,NoOp(User Pressed 7, Wrong Input)
same => n,Verbose(1, User pressed 7)
same => n,Dial(PJSIP/6001)
;same => n,Set(tries=$[${tries} +1])
;same => n,GotoIf($[${tries}>=3]?Hangup)
;same => n,Playback(Wrong-Input-1)
;same => n,WaitExten(1)
;same => n,Goto(annoucement_2,s,1)
;exten => 8,1,NoOp(User Pressed 8, Wrong Input)
;same => n,Verbose(1, User pressed 8)
;same => n,Set(tries=$[${tries} +1])
;same => n,GotoIf($[${tries}>=3]?Hangup)
;same => n,Playback(Wrong-Input-1)
;same => n,WaitExten(1)
;same => n,Goto(annoucement_2,s,1)
exten => 8,1,NoOp(User Pressed 8, Wrong Input)
same => n,Verbose(1, User pressed 7)
same => n,Dial(PJSIP/6002)
;same => n,Set(tries=$[${tries} +1])
;same => n,GotoIf($[${tries}>=3]?Hangup)
;same => n,Playback(Wrong-Input-1)
;same => n,WaitExten(1)
;same => n,Goto(annoucement_2,s,1)
exten => 9,1,NoOp(User Pressed 9, Wrong Input)
same => n,Verbose(1, User pressed 9)
same => n,Set(tries=$[${tries} +1])
same => n,GotoIf($[${tries}>=3]?Hangup)
same => n,Playback(Wrong-Input-1)
same => n,WaitExten(1)
same => n,Goto(annoucement_2,s,1)
exten => 0,1,NoOp(User Pressed 0, End the Call)
same => n,Verbose(1, User pressed 0)
same => n,Goto(Thank_You,s,1)
exten => *,1,NoOp(User Pressed *, Listen Again the Menu)
same => n,Verbose(1, User pressed *)
same => n,Goto(annoucement_2,s,1)
exten => _XX.,1,NoOp(User Pressed (${_XX}), Wrong Input)
same => n,Verbose(1, User pressed XX)
same => n,Set(tries=$[${tries} +1])
same => n,GotoIf($[${tries}>=3]?Hangup)
same => n,Playback(Wrong-Input-1)
same => n,WaitExten(1)
same => n,Goto(annoucement_2,s,1)
; SALES MENU
[annoucement_3]
exten => s,1,NoOp(Incoming call from Annoucement_3)
same => n,Set(TIMEOUT(digit)=1)
same => n,Set(busyCount=0)
same => n,Set(SELECTED_PATH=annoucement_3)
same => n,NoOp(User In Path ${SELECTED_PATH})
same => n,Background(For-Networking-Items-and-1)
same => n,Background(press-one-1)
same => n,Background(For-Storage-and-Servers-1)
same => n,Background(press-two-1)
same => n,Background(For-End-User-Computing-1)
same => n,Background(press-three-1)
same => n,Background(For-Imaging-and-Printing-1)
same => n,Background(press-four-1)
same => n,Background(For-Software-Solutions-1)
same => n,Background(press-five-1)
same => n,Background(For-CCTV-Cabling-and-U-P-1)
same => n,Background(press-six-1)
same => n,Background(Listen-again-the-menu-1)
same => n,Background(press-star-key-1)
same => n,Background(exit-the-menu-1)
same => n,Background(press-zero-1)
same => n,WaitExten(10)
same => n,Set(tries=$[${tries} +2])
same => n,GotoIf($[${tries}>=3]?Hangup,s,1)
same => n,Playback(We-have-not-received-vali-1)
same => n,WaitExten(1)
same => n,Goto(annoucement_3,s,1)