Tutorial May 5, 2025 10 min read

Asterisk Call Queues: Setup, Strategies, and Best Practices

Call queues distribute incoming calls among agents efficiently. This guide covers everything from basic queue setup to advanced ring strategies and real-time monitoring.

Queue Basics

An Asterisk call queue holds incoming calls and distributes them to available agents (extensions) using a configurable ring strategy. Callers hear music on hold or periodic announcements while waiting. When an agent becomes available, the next call in the queue is delivered to them.

Queues are essential for:

  • Support desks handling multiple incoming calls
  • Sales teams distributing leads fairly
  • Any scenario where more calls arrive than agents can immediately answer

Module Required: Queues require app_queue. Verify it is loaded with module show like app_queue on the Asterisk CLI.

Configuring queues.conf

Queue configuration lives in /etc/asterisk/queues.conf. Here is a complete support queue example:

/etc/asterisk/queues.conf
[general]
persistentmembers=yes
autofill=yes
shared_lastcall=yes
log_membername_as_agent=yes

[support]
; Ring strategy
strategy=leastrecent
; Timeout for each agent ring attempt (seconds)
timeout=15
; How long to wait before trying the next agent
retry=5
; Max wait time in queue (seconds) - 0 for unlimited
maxlen=0
; Max callers allowed in queue - 0 for unlimited
maxlen=20
; Wrap-up time after a call (seconds)
wrapuptime=10
; Music on hold class
musicclass=default
; Join announcement
joinempty=yes
leavewhenempty=no
; Announce position in queue
announce-frequency=60
announce-position=yes
announce-holdtime=yes
; Periodic announcements
periodic-announce=queue-thankyou
periodic-announce-frequency=120
; Service level target (seconds)
servicelevel=60
; Ring an in-use agent?
ringinuse=no
; Static members (always in queue)
member => PJSIP/100,0,John Smith,hint:100@default
member => PJSIP/101,0,Jane Doe,hint:101@default
member => PJSIP/102,0,Bob Wilson,hint:102@default

Tip: Set persistentmembers=yes in [general] to save dynamic agent membership across Asterisk restarts. Without this, dynamically added agents are lost on reload.

Ring Strategies

The ring strategy determines how calls are distributed among agents. Choose based on your team's workflow:

ringall

Rings all available agents simultaneously. First to answer gets the call. Good for small teams where speed matters.

leastrecent

Rings the agent who has been idle the longest since their last call. Distributes calls evenly over time.

fewestcalls

Rings the agent with the fewest completed calls. Balances total call count across agents.

random

Randomly selects an available agent. Simple and fair over large volumes.

rrmemory

Round-robin with memory. Remembers where it left off and continues to the next agent. Predictable and fair.

linear

Always tries agents in order (first member first). Good when you have a preferred agent or skill-based tiering.

Recommendation: For most support teams, leastrecent or rrmemory provides the fairest distribution. Use ringall only for small teams (under 5) where answer speed is the top priority.

Agent Management

Agents can be added to queues statically (in queues.conf) or dynamically (via the dialplan or AMI). Dynamic membership is more flexible for shift-based operations:

extensions.conf - Dynamic agent login/logout
[agents]
; Login to support queue - dial *500
exten => *500,1,NoOp(Agent login to support queue)
 same => n,AddQueueMember(support,PJSIP/${CALLERID(num)})
 same => n,Playback(agent-loginok)
 same => n,Hangup()

; Logout from support queue - dial *501
exten => *501,1,NoOp(Agent logout from support queue)
 same => n,RemoveQueueMember(support,PJSIP/${CALLERID(num)})
 same => n,Playback(agent-loggedoff)
 same => n,Hangup()

; Pause/unpause (toggle) - dial *502
exten => *502,1,NoOp(Toggle agent pause)
 same => n,Set(QSTATUS=${QUEUE_MEMBER(support,paused,PJSIP/${CALLERID(num)})})
 same => n,GotoIf($["${QSTATUS}"="1"]?unpause)
 same => n,PauseQueueMember(support,PJSIP/${CALLERID(num)},,Break)
 same => n,Playback(beep)
 same => n,Hangup()
 same => n(unpause),UnpauseQueueMember(support,PJSIP/${CALLERID(num)})
 same => n,Playback(beep&beep)
 same => n,Hangup()

Tip: Use PauseQueueMember for breaks and after-call work rather than removing agents. This preserves their queue membership and statistics while temporarily stopping call delivery.

Queue Announcements

Keep callers informed while they wait with these announcement options:

  • announce-frequency: How often (seconds) to announce the caller's position and estimated hold time. Set to 0 to disable.
  • announce-position: Tell callers their position in queue ("You are caller number 3").
  • announce-holdtime: Announce estimated hold time based on recent call data. Only announces if the estimate is meaningful.
  • periodic-announce: Play a custom recording periodically (e.g., "Thank you for holding, your call is important to us").
  • periodic-announce-frequency: How often (seconds) to play periodic announcements.

Balance Announcements: Too-frequent announcements annoy callers. Set announce-frequency to 60-90 seconds and periodic announcements to 120+ seconds. If estimated hold time is unreliable (small queue), disable announce-holdtime.

Dialplan Integration

Connect incoming calls to your queue through the dialplan. Handle queue exits gracefully:

extensions.conf - Queue with failover
[from-ipcomms]
; Route inbound DID to support queue
exten => 2125551000,1,NoOp(Inbound to support)
 same => n,Answer()
 same => n,Playback(welcome-message)
 same => n,Queue(support,t,,,300)
 ; If caller times out after 300 seconds (5 min)
 same => n,VoiceMail(support@default,u)
 same => n,Hangup()

; Alternative: IVR then queue
exten => 2125551001,1,NoOp(Main IVR)
 same => n,Answer()
 same => n,Background(main-ivr-greeting)
 same => n,WaitExten(5)

exten => 1,1,Queue(sales,t,,,180)
 same => n,VoiceMail(sales@default,u)
 same => n,Hangup()

exten => 2,1,Queue(support,t,,,300)
 same => n,VoiceMail(support@default,u)
 same => n,Hangup()

The Queue() application options include:

  • t - Allow the called agent to transfer the call
  • T - Allow the caller to transfer
  • n - No retry on timeout (exit queue if no agent answers)
  • H - Allow the caller to hang up by pressing *
  • The 5th parameter (300) - Maximum wait time in seconds

Queue Monitoring and Stats

Monitor queue performance in real-time from the Asterisk CLI:

Asterisk CLI - Queue commands
; Show all queues with stats
queue show

; Show specific queue
queue show support

; Show queue summary (compact view)
queue stats

; Real-time queue log
queue set log on

; Output example:
; support has 2 calls (max 20) in 'leastrecent' strategy
;   (service level: 60s)
;   Members:
;     PJSIP/100 (John Smith) (ringinuse disabled) (Not in use) has taken 15 calls
;     PJSIP/101 (Jane Doe) (ringinuse disabled) (In use) has taken 12 calls
;   Callers:
;     1. PJSIP/trunk-00000023 (wait: 0:45, prio: 0)

For historical reporting, Asterisk writes queue events to /var/log/asterisk/queue_log. Key events include ENTERQUEUE, CONNECT, ABANDON, COMPLETECALLER, and COMPLETEAGENT. Third-party tools like QueueMetrics can parse these logs into detailed reports.

Best Practices

  • Set ringinuse=no: Prevents delivering queue calls to agents already on a call. Without this, agents on a call will hear another ring.
  • Use wrapuptime: Give agents 10-30 seconds after each call to complete notes before the next call arrives.
  • Set a maxlen: Limit the number of callers in queue to prevent extremely long wait times. It is better to send the 21st caller to voicemail than make them wait 30 minutes.
  • Configure a timeout: Always set a max wait time in the Queue() dialplan application. Send callers to voicemail or a callback option if they wait too long.
  • Monitor service levels: Track what percentage of calls are answered within your target time (e.g., 80% within 60 seconds). This is the industry-standard metric.
  • Record queue calls: Use MixMonitor() in the queue member's context to record calls for quality assurance and training.

Reliable SIP Trunking for Your Call Center

IPComms provides high-capacity SIP trunks built for call centers. Handle large call volumes with crystal-clear quality and competitive per-minute pricing.

Related Articles