Queue with Failover
Queue with Failover
A call queue that distributes calls to agents, with failover to voicemail when no one answers or the queue times out.
Requirements
queues.conf: queue definition (shown below)agents.confor dynamic queue members (SIP/PJSIP peers)- Voicemail configured for the failover mailbox
Queue Configuration (queues.conf)
[support-queue]
musicclass = default
strategy = ringall
timeout = 15
retry = 5
maxlen = 10
wrapuptime = 5
announce-frequency = 30
announce-holdtime = yes
joinempty = yes
leavewhenempty = no
Dialplan
[main-queue]
exten => s,1,NoOp(Entering support queue)
same => n,Set(CHANNEL(musicclass)=default)
same => n,Answer()
same => n,Queue(support-queue,t,,,120)
same => n,NoOp(Queue returned: ${QUEUESTATUS})
same => n,GotoIf($["${QUEUESTATUS}" = "TIMEOUT"]?timeout)
same => n,GotoIf($["${QUEUESTATUS}" = "FULL"]?full)
same => n,Goto(failover)
same => n(timeout),NoOp(Queue timed out after 120s)
same => n,Goto(failover)
same => n(full),NoOp(Queue is full)
same => n,Goto(failover)
same => n(failover),Playback(custom/all-agents-busy)
same => n,VoiceMail(100@default,u)
same => n,Hangup()
How it works
- Queue(queuename,options,URL,announceoverride,timeout): The fifth argument is the maximum time (in seconds) a caller will wait in the queue before it returns.
- QUEUESTATUS: After
Queue()returns, this channel variable indicates why:TIMEOUT,FULL,JOINEMPTY,LEAVEEMPTY,JOINUNAVAIL, orLEAVEUNAVAIL. - Strategy:
ringallrings every available member simultaneously. Other options:leastrecent,fewestcalls,random,rrmemory(round-robin with memory). - Failover chain: The
GotoIfchecks route to a common failover label that plays a message and sends the caller to voicemail.
Tips
- Add dynamic members with
AddQueueMember(support-queue,SIP/${EXTEN})in a login extension. - Use
penaltyvalues to create tiered routing (primary agents get calls first, backup agents only when primary is busy). - Monitor queue performance with
queue show support-queueon the Asterisk CLI. - Set
joinempty=strictif you don't want callers joining when no agents are logged in.
User Notes
No notes yet. Be the first to contribute a tip or example.
Contribute a note
Share a tip, gotcha, or practical example. Keep it under 2000 characters. No questions (use the Asterisk community forums for support). Wrap code in backticks.