Voice Prompt Playback Delays in IVR System

After the call connects to the IVR, there’s a 6-7 second delay when the DTMF input enter (For English, press 01) Stay 6-7 Sec and plays the Sub menus . Similarly, after selecting submenus, there’s also a delay in the playback.

; DMSE IVR

[from_external]

exten => 100,1,NoOp(call to chandima)
same => n,Dial(SIP/100)
same => n,Hangup()

exten => 200,1,NoOp(call to Jega)
same => n,Dial(SIP/200)
same => n,Hangup()

exten => 3000,1,NoOp(call to Hirushi)
same => n,Dial(SIP/3000)
same => n,Hangup()

exten => 1001,1,NoOp(call to 1001)
same => n,Dial(SIP/1001)
same => n,Hangup()

exten => 200,1,NoOp(call to 200)
same => n,Dial(SIP/200)
same => n,Hangup()

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()

;exten => 0112019510,1,Goto(dmse_IVR,s,1) ; route calls from SIP number ‘0112019510’ to IVR menu
;exten => 0112019511,1,Goto(dmse_IVR,s,1) ; route calls from SIP number ‘0112019511’ to IVR menu
;exten => 0112019512,1,Goto(dmse_IVR,s,1) ; route calls from SIP number ‘0112019512’ to IVR menu
;exten => 0112019513,1,Goto(dmse_IVR,s,1) ; route calls from SIP number ‘0112019513’ to IVR menu
;exten => 0112019514,1,Goto(dmse_IVR,s,1) ; route calls from SIP number ‘0112019514’ to IVR menu
;exten => 0112019515,1,Goto(dmse_IVR,s,1) ; route calls from SIP number ‘0112019515’ to IVR menu
;exten => 0112019516,1,Goto(dmse_IVR,s,1) ; route calls from SIP number ‘0112019516’ to IVR menu
;exten => 0112019517,1,Goto(dmse_IVR,s,1) ; route calls from SIP number ‘0112019517’ to IVR menu
;exten => 0112019518,1,Goto(dmse_IVR,s,1) ; route calls from SIP number ‘0112019518’ to IVR menu
;exten => 0112019519,1,Goto(dmse_IVR,s,1) ; route calls from SIP number ‘0112019519’ to IVR menu
exten => _01120195XX,1,NoOp(Incoming call from ${EXTEN})
same => n,Set(DIALED_NUMBER=${EXTEN})
same => n,Goto(dmse_IVR,s,1)

[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)})

; Insert call details into the database including the destination number
;same => n,Set(ODBC_WRITE(‘${CDR(calldate)}’, ‘${CDR(clid)}’, ‘${CDR(src)}’, ‘${CDR(dst)}’, ‘${CDR(destination_number)}’, ‘${CDR(dcontext)}’, ‘${CDR(channel)}’, ‘${CDR(dstchannel)}’, ‘${CDR(lastapp)}’, ‘${CDR(lastdata)}’, ${CDR(duration)}, ${CDR(billsec)}, ‘${CDR(disposition)}’, ${CDR(amaflags)}, ‘${CDR(accountcode)}’, ‘${CDR(linkedid)}’, ‘${CDR(userfield)}’, ‘${CDR(uniqueid)}’))

;same => n,Set(ODBC_WRITE(${CDR(clid)}, ${CDR(src)}, ‘${DIALED_NUMBER}’, ${CDR(dcontext)}, ${CDR(channel)}, ${CDR(dstchannel)}, ${CDR(lastapp)}, ${CDR(lastdata)}, ${CDR(duration)}, ${CDR(billsec)}, ${CDR(disposition)}, ${CDR(amaflags)}, ${CDR(accountcode)}, ${CDR(uniqueid)}, ${CDR(linkedid)}, ${CDR(userfield)}))

; Store call details in the cdr table
;same => n,odbc(Connect connid localhost asterisk asterisk asterisk)
;same => n,odbc(Query resultid ${connid} INSERT INTO cdr (calldate, clid, src, dst, dcontext, channel, dstchannel, lastapp, lastdata, duration, billsec, disposition, amaflags, accountcode, uniqueid, userfield) VALUES (NOW(), ‘${CALLERID(name)}’, ‘${CALLERID(num)}’, ‘chandima1’, ‘’, ‘${CHANNEL}’, ‘${DSTCHANNEL}’, ‘Dial’, ‘${EXTEN}’, 0, 0, ‘answered’, 0, ‘’, ‘${CONFID}’, ‘’))
;same => n,odbc(Disconnect ${connid})

; same => n,Set(CDR(userfield)=Your custom userfield data) ; Optional: Set custom CDR userfield
; same => n,Set(ODBC_WRITE(${CDR(clid)}, ${CDR(src)}, ${CDR(dst)}, ${CDR(dcontext)}, ${CDR(channel)}, ${CDR(dstchannel)}, ${CDR(lastapp)}, ${CDR(lastdata)}, ${CDR(duration)}, ${CDR(billsec)}, ${CDR(disposition)}, ${CDR(amaflags)}, ${CDR(accountcode)}, ${CDR(uniqueid)}, ${CDR(linkedid)}, ${CDR(userfield)}))

; same => n,Set(CDR(userfield)=Your_custom_userfield_data) ; Optional: Set custom CDR userfield
; same => n,Set(ODBC_WRITE(${CDR(clid)},${CDR(src)},${CDR(dst)},${CDR(dcontext)},${CDR(channel)},${CDR(dstchannel)},${CDR(lastapp)},${CDR(lastdata)},${CDR(duration)},${CDR(billsec)},${CDR(disposition)},${CDR(amaflags)},${CDR(accountcode)},${CDR(uniqueid)},${CDR(linkedid)},${CDR(userfield)}))

same => n,Set(tries=0)
same => n,Goto(testing,s,1)

[welcomeloop]
; play welcome dms message for Language Selection
exten => s,1,NoOp(Incoming call to ‘welcomeloop’)
same => n,Background(welcomedmse)

; Check for DTMF while playing the prompt
;same => n,Set(user_inputs=${CHANNEL(dtmf)})

; If ‘1’ is pressed, stop the playback and go to English_lang
;same => n,GotoIf($[“${user_inputs}” = “1”]?English_lang,s,1)

; If ‘2’ is pressed, stop the playback and go to Sinhala_lang
;same => n,GotoIf($[“${user_inputs}” = “2”]?Sinhala_lang,s,1)

; If ‘3’ is pressed, stop the playback and go to Tamil_lang
;same => n,GotoIf($[“${user_inputs}” = “3”]?Tamil_lang,s,1)

same => n,Read(user_inputs)

; User Inputs
same => n,WaitExten(2)
same => n,GotoIf($[“${user_inputs}” = “1”]?English_lang,s,1)
same => n,GotoIf($[“${user_inputs}” = “2”]?Sinhala_lang,s,1)
same => n,GotoIf($[“${user_inputs}” = “3”]?Tamil_lang,s,1)
same => n,Playback(wrongInput)
same => n,WaitExten(2)
same => n,Set(tries=$[${tries} +1])

; Check user input 3 wrong inputs
same => n,GotoIf($[${tries}>=3]?Hangup)

; If user enters wrong input, Play welcomedmse voice again
same => n,Goto(welcomeloop,s,1)

; Handle unexpected input
same => n,Playback(wrongInput)
same => n,WaitExten(2)
same => n,Goto(welcomeloop,s,1)

[English_lang]
; If user presses 1, go to English Language
exten => s,1,NoOp(User Pressed 1 and go to English path)
same => n,Playback(dmsevoice)
same => n,Hangup()

[Sinhala_lang]
; If user presses 2, go to Sinhala Language
exten => s,1,NoOp(User Pressed 2 and go to Sinhala path)
same => n,Playback(dmsevoice)
same => n,Hangup()

[Tamil_lang]
; If user presses 3, go to Tamil Language
exten => s,1,NoOp(User Pressed 3 and go to Tamil path)
same => n,Playback(dmsevoice)
same => n,Hangup()

[Hangup]
; Hangup after 3 wrong inputs or no user response
exten => s,1,NoOp(No user response or 3 wrong inputs)
same => n,Playback(thankyou)
same => n,Hangup()

[testing]
exten => s,1,NoOp(Incoming call to ‘welcomeloop’)
same => n,WaitExten(1)
same => n,Set(UNIQUEID=${UNIQUEID})
same => n,MixMonitor(/var/spool/asterisk/monitor/${UNIQUEID}.wav)
;same => n,MixMonitor(wav,${UNIQUEID},m)
;same => n,Monitor(wav,${STRFTIME(${EPOCH},%Y%m%d-%H%M%S)}-${CALLERID(num)}-${EXTEN},m)
same => n,Background(welcomedmse)
;same => n,VoiceMail(6001@default,u)
same => n,WaitExten(10)
same => n,Set(tries=$[${tries} +1])
same => n,GotoIf($[${tries}>=3]?Hangup,s,1)
same => n,Playback(tryAgain)
same => n,WaitExten(2)
same => n,Goto(testing,s,1)

;If user press 1, go to English menu
exten => 1,1,NoOp(User Pressed 1, Goto English menu)
same => n,Verbose(1, User pressed 1)
same => n,Goto(English_lang_testing,s,1)

exten => 2,1,NoOp(User Pressed 2, Goto Sinhala menu)
same => n,Verbose(1, User pressed 2)
same => n,Goto(Sinhala_lang,s,1)

exten => 3,1,NoOp(User Pressed 3, Goto Tamil_lang menu)
same => n,Verbose(1, User pressed 3)
same => n,Goto(Tamil_lang,s,1)

exten => 4,1,NoOp(User Pressed 4, Wrong Input)
same => n,Verbose(1, User pressed 4)
same => n,Set(tries=$[${tries} +1])
same => n,GotoIf($[${tries}>=3]?Hangup)
same => n,Playback(wrongInput)
same => n,WaitExten(1)
same => n,Goto(testing,s,1)

exten => 5,1,NoOp(User Pressed 5, Wrong Input)
same => n,Verbose(1, User pressed 5)
same => n,Set(tries=$[${tries} +1])
same => n,GotoIf($[${tries}>=3]?Hangup)
same => n,Playback(wrongInput)
same => n,WaitExten(1)
same => n,Goto(testing,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,GotoIf($[${tries}>=3]?Hangup)
same => n,Playback(wrongInput)
same => n,WaitExten(1)
same => n,Goto(testing,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(wrongInput)
same => n,WaitExten(1)
same => n,Goto(testing,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(wrongInput)
same => n,WaitExten(1)
same => n,Goto(testing,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(wrongInput)
same => n,WaitExten(1)
same => n,Goto(testing,s,1)

exten => 0,1,NoOp(User Pressed 0, Wrong Input)
same => n,Verbose(1, User pressed 0)
same => n,Set(tries=$[${tries} +1])
same => n,GotoIf($[${tries}>=3]?Hangup)
same => n,Playback(wrongInput)
same => n,WaitExten(1)
same => n,Goto(testing,s,1)

exten => _XX.,1,NoOp(User Pressed (${_XX}), Wrong Input)
same => n,Verbose(1, User pressed 0)
same => n,Set(tries=$[${tries} +1])
same => n,GotoIf($[${tries}>=3]?Hangup)
same => n,Playback(wrongInput)
same => n,WaitExten(1)
same => n,Goto(testing,s,1)

exten => 100,1,NoOp(call to Rinushan)
same => n,Dial(SIP/rinushan)
same => n,Hangup()

exten => 200,1,NoOp(call to Sachith)
same => n,Dial(SIP/sachith1)
same => n,Hangup()

[English_lang_testing]
exten => s,1,NoOp(User Pressed 1 and go to English path)
same => n,Background(dmsevoice)
same => n,WaitExten(10)
same => n,Set(tries=$[${tries} +2])
same => n,GotoIf($[${tries}>=6]?Hangup,s,1)
same => n,Playback(tryAgain)
same => n,WaitExten(1)
same => n,Goto(English_lang_testing,s,1)

exten => 1,1,NoOp(User Pressed 1)
same => n,Verbose(1, User pressed 1)
same => n,Set(CONFID=${UNIQUEID})
same => n,Answer()
;same => n,Playback(welcome2)
same => n,Verbose(1, Call forwarding… one)
same => n,Set(QUEUE_ENTRY_TIME=${GETDATEANDTIME()})
same => n,Queue(software,60)
same => n,Dial(SIP/100,30,tTmL(${CONFID}))
same => n,GotoIf($[“${DIALSTATUS}”=“BUSY”]?chandima_busy)
same => n,Verbose(1, Call forwarded, But not answered by Agent)
same => n,Answer()
same => n,Verbose(1, Agent answered the call)
same => n,Hangup()
same => n,Verbose(1, Call end)

; Label to jump to if sachith is busy
same => n(chandima_busy),NoOp(rinushan is busy, transferring to chandima)
same => n,Dial(SIP/3000,30,tTmL(${CONFID}))
same => n,Verbose(1, Call forwarded to chandima)
same => n,GotoIf($[“${DIALSTATUS}” != “ANSWER”]?agent_busy,s,1)
same => n,Hangup()

exten => 2,1,NoOp(User Pressed 2)
same => n,Verbose(1, User pressed 2)
same => n,Set(CONFID=${UNIQUEID})
same => n,Answer()
;same => n,Playback(welcome2)
same => n,Verbose(1, Call forwarding… one)
same => n,Queue(network,120)
same => n,Dial(SIP/3000,30,tTmL(${CONFID}))

same => n,GotoIf($[“${DIALSTATUS}”=“BUSY”]?rinushan_busy)
same => n,Verbose(1, Call forwarded, But not answered by Agent)
same => n,Answer()
same => n,Verbose(1, Agent answered the call)
same => n,Set(ANSWER_TIME=${EPOCH})

same => n,Set(HANGUPCAUSE=${CHANNEL(hangupcause)})
same => n,GotoIf($[“${HANGUPCAUSE}” = “16”]?agent_hangup:customer_hangup)

; Agent hung up
same => n(agent_hangup),NoOp(Call ended by Agent)
same => n,Hangup()

; Customer hung up
same => n(customer_hangup),NoOp(Call ended by Customer)
same => n,Hangup()

; Label to jump to if chandima is busy
same => n(rinushan_busy),NoOp(rinushan is busy, transferring to chandima)
same => n,Dial(SIP/rinushan,30,tTmL(${CONFID}))
same => n,Verbose(1, Call forwarded to chandima)
same => n,GotoIf($[“${DIALSTATUS}” != “ANSWER”]?agent_busy,s,1)
same => n,Hangup()

exten => 3,1,NoOp(User Pressed 3, Goto Sales Team)
same => n,Verbose(1, User pressed 3)
same => n,Set(QUEUE_ENTRY_TIME=${STRFTIME(${EPOCH},%Y-%m-%d %H:%M:%S)})
same => n,System(mysql -u asterisk -p’asterisk’ -D asterisk -e “INSERT INTO call_path (caller_id, path_A, path_B, queue_name, dield_number) VALUES (‘${CALLERID(num)}’, ‘Eng_Lang_test’,‘’, ‘network’, ‘${DIALED_NUMBER}’)”)
same => n,Queue(network,30)
same => n,Set(WAITING_TIME=$[${EPOCH} - ${QUEUE_ENTRY_TIME}])
same => n,Answer()
same => n,Set(ANSWER_TIME=${STRFTIME(${EPOCH},%Y-%m-%d %H:%M:%S)})
same => n,NoOp(Waiting time: ${STRFTIME(${DIFF(${ANSWER_TIME},${QUEUE_ENTRY_TIME})},%H:%M:%S)})
same => n,NoOp(Call duration: ${CDR(duration)})
same => n,Hangup()

exten => 4,1,NoOp(User Pressed 4, Goto HR team Team)
same => n,Verbose(1, User pressed 4)
same => n,System(mysql -u asterisk -p’asterisk’ -D asterisk -e “INSERT INTO call_path (caller_id, path_A, path_B, queue_name, dield_number) VALUES (‘${CALLERID(num)}’, ‘Eng_Lang_test’, ‘’, ‘software’, ‘${DIALED_NUMBER}’)”)
same => n,Queue(software,60)
same => n,Answer()
same => n,Hangup()

exten => 5,1,NoOp(Incoming call for Extension ${EXTEN})
same => n,Verbose(1, User pressed 5)
same => n,GotoIf($[“${DB(availability/${EXTEN})}” = “INUSE”]?dial:queue)
same => n(dial),Dial(SIP/${EXTEN},20)
same => n,Goto(end)
same => n(queue),Queue(software,30)
same => n(end),Hangup()

exten => 6,1,NoOp(User Pressed 6, Goto Finance Team)
same => n,Verbose(1, User pressed 6)
same => n,Dial(PJSIP/6001,60,tTmL(${CONFID}))
same => n,Answer()
same => n,Hangup()

exten => 7,1,NoOp(User Pressed 7, Wrong Input)
same => n,Verbose(1, User pressed 7)
same => n,Dial(PJSIP/6002,60,tTmL(${CONFID}))
same => n,Answer()
same => n,Hangup()

exten => 8,1,NoOp(User Pressed 8, )
same => n,Verbose(1, User pressed 8)
same => n,Dial(PJSIP/100,60,tTmL(${CONFID}))
same => n,Answer()
same => n,Hangup()

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(wrongInput)
same => n,WaitExten(1)
same => n,Goto(English_lang_testing,s,1)

exten => 0,1,NoOp(User Pressed 0, Exit the menue)
same => n,Verbose(1, User pressed 0)
same => n,Goto(testing,s,1)

exten => _XX.,1,NoOp(User Pressed (${_XX}), Wrong Input)
same => n,Verbose(1, User pressed 0)
same => n,Set(tries=$[${tries} +1])
same => n,GotoIf($[${tries}>=3]?Hangup)
same => n,Playback(wrongInput)
same => n,WaitExten(1)
same => n,Goto(testing,s,1)

exten => 100,1,NoOp(call to Rinushan)
same => n,Dial(SIP/rinushan)
same => n,Hangup()

exten => 200,1,NoOp(call to Sachith)
same => n,Dial(SIP/sachith1)
same => n,Hangup()

[agent_busy]
exten => s,1,NoOp(If All users are Busy)
same => n,Background(allAgentBusy)
same => n,WaitExten(10)
same => n,Set(tries=$[${tries} +4])
same => n,GotoIf($[${tries}>=8]?Hangup,s,1)
same => n,Playback(tryAgain)
same => n,WaitExten(1)
same => n,Goto(agent_busy,s,1)

exten => 1,1,NoOp(User Pressed 1, User need to call back)
same => n,Verbose(1, User pressed 1)
same => n,Playback(weWillCallBack)
same => n,WaitExten(2)
same => n,Hangup()

exten => 2,1,NoOp(User Pressed 2, User need to keep VoiceMail)
same => n,Verbose(2, User pressed 2)
same => n,VoiceMail(6001@default,u)
same => n,WaitExten(2)
same => n,Hangup()

exten => 9,1,NoOp(User Pressed 9, User need to go previous menu)
same => n,Verbose(9, User pressed 9)
same => n,WaitExten(2)
same => n,Goto(English_lang_testing,s,1)

exten => 0,1,NoOp(User Pressed 0, Hangup the call)
same => n,Verbose(9, User pressed 9)
same => n,WaitExten(2)
same => n,Hangup()

You seem to be mixing up the Read and WaitExten method of handling IVR input, resulting in your doing WaitExten when no input is expected.