Asterisk IVR menu with hotline queue and opening hours

Here is a simple asterisk IVR that you can use as a start to make your own using a queue and allowing you to manage opening hours.

IVR Configuration

This has to be in /etc/asterisk/extensions.conf :

;Some global variables to manage the extensions to be called.
210=SIP/211&SIP/212&SIP/200
240=SIP/244&SIP/245&SIP/249

;We create the specific context IVR.

[IVR]
exten => start,1,Answer()
;Checking opening hours.
same => n,GotoIfTime(00:00-07:00,mon-fri,*,*?closed)
same => n,GotoIfTime(12:00-13:30,mon-thu,*,*?hotline)
same => n,GotoIfTime(17:00-23:59,mon-thu,*,*?closed)
same => n,GotoIfTime(12:30-13:59,fri,*,*?hotline)
same => n,GotoIfTime(14:00-23:59,fri,*,*?closed)
same => n,GotoIfTime(*,sat-sun,*,*,*?closed)
;Announcing the available menu options.
same => n,Background(en/greeting)
same => n,Background(en/1informations)
same => n,Background(en/2ndoption)
same => n,Background(en/3rdoption)
same => n,Background(en/4thoption)
same => n,Background(en/9replay)
;Waiting 10 seconds for input otherwise proceed with next steps.
same => n,WaitExten(10)
same => n,Queue(hotline)
same => n,Dial(${210},30)
same => n,Playback(fr/nbdy-avail-to-take-call)
same => n,Hangup()
;If closed
same => n(closed),Playback(en/message-closed)
same => n,Hangup()
;If calling during lunchtime for instance send all calls to hotline.
same => n(hotline),Queue(hotline)
same => n,Dial(SIP/203&SIP/202&SIP/201,30)
same => n,Playback(en/nbdy-avail-to-take-call)
same => n,Hangup()

exten => 1,1,Queue(hotline)
same => n,Dial(SIP/221,30)
same => n,Dial(${210},30)
same => n,Playback(en/nbdy-avail-to-take-call)
same => n,Hangup()

exten => 2,1,Answer()
same => n,Queue(hotline)
same => n,Dial(${210},30)
same => n,Playback(en/nbdy-avail-to-take-call)
same => n,Hangup()

exten => 3,1,Answer()
same => n,Queue(hotline)
same => n,Dial(${240},30)
same => n,Playback(en/nbdy-avail-to-take-call)
same => n,Hangup()

exten => 4,1,Answer()
same => n,Dial(SIP/246,30)
same => n,Playback(en/nbdy-avail-to-take-call)
same => n,Hangup()

exten => 5,1,Answer()
same => n,Queue(hotline)
same => n,Dial(${210},30)
same => n,Playback(en/nbdy-avail-to-take-call)
same => n,Hangup()

exten => 9,1,Goto(IVR,start,1)

;For all other input which doesn't match what is expected.

exten => i,1,Playback(en/pbx-invalid)
same => n,Goto(IVR,start,1)

Hotline Queue configuration

Here is the part to allow the operators to join/leave the hotline queue in your phones’ context.

The agents will join the hotline queue by typing *98 on their phone and leave it with *99.

exten => *98,1,Verbose(2,Logging In Queue Member)
same => n,Set(MemberChannel=${CHANNEL(channeltype)}/${CHANNEL(peername)})
same => n,AddQueueMember(hotline,${MemberChannel})
same => n,Playback(en/agent-reg)
same => n,Hangup()

exten => *99,1,Verbose(2,Logging Out Queue Member)
same => n,Set(MemberChannel=${CHANNEL(channeltype)}/${CHANNEL(peername)})
same => n,RemoveQueueMember(hotline,${MemberChannel})
same => n,Playback(en/agent-unreg)
same => n,Hangup()

and the queues.conf configuration for the hotline queue :

[general]
autofill=yes ; distribute all waiting callers to available members
shared_lastcall=yes ; respect the wrapup time for members logged into more
persistentmembers=yes

[StandardQueue] ; template to provide common features
musicclass=queue ; play [default] music
strategy=rrmemory ; use the Round Robin Memory strategy
joinempty=no ; do not join the queue when no members available
leavewhenempty=yes ; leave the queue when no members available
ringinuse=no ; don't ring members when already InUse (prevents
; multiple calls to an agent)

[hotline](StandardQueue) ; create the hotline queue using the parameters in the StandardQueue template

Leave a Reply

Your email address will not be published. Required fields are marked *