Asterisk Call Center: Music On Hold (Latest Versions)
Updated guide for modern Asterisk (PJSIP era): music on hold with real configs, common mistakes, and troubleshooting steps.
When callers are waiting in a queue, silence feels like a broken system. Music on Hold (MOH) keeps callers engaged and reduces hang-ups, while also making your call center feel professional.
In modern Asterisk deployments, Music on Hold is used in:
- Call queues
- Call transfers
- IVR hold states
- Agent consult calls
This guide explains how Music on Hold works in latest Asterisk (PJSIP), how to configure it cleanly, and how to troubleshoot audio issues.
What Is Music on Hold in Asterisk?
Music on Hold is audio played to a caller while they are placed on hold or waiting in a queue.
Asterisk supports different Music on Hold classes, allowing different departments to play different audio.
Where Music on Hold Is Configured
Music on Hold configuration file:
/etc/asterisk/musiconhold.conf
Common audio storage path:
/var/lib/asterisk/moh/
Step 1 — Create a Music on Hold Folder
Example: create a folder for a support queue:
sudo mkdir -p /var/lib/asterisk/moh/support
Copy audio files into the folder (wav recommended).
Then set permissions:
sudo chown -R asterisk:asterisk /var/lib/asterisk/moh/support
Step 2 — Configure a MOH Class
Edit:
sudo nano /etc/asterisk/musiconhold.conf
Example MOH class:
[support]
mode=files
directory=/var/lib/asterisk/moh/support
random=yes
Meaning:
- mode=files → play audio files from directory
- random=yes → random playback order
Step 3 — Reload Music on Hold
asterisk -rx "moh reload"
Verify classes:
asterisk -rx "mोह show classes"
If your terminal does not show it, use:
asterisk -rx "moh show classes"
Step 4 — Attach MOH to a Queue
In /etc/asterisk/queues.conf:
[support]
musicclass=support
strategy=leastrecent
timeout=20
retry=5
maxlen=0
Reload queues:
asterisk -rx "queue reload all"
Testing Music on Hold (Quick Dialplan Test)
You can test MOH without a queue:
[from-internal]
exten => 600,1,Answer()
same => n,MusicOnHold(support)
same => n,Hangup()
Call extension 600 from any phone and confirm audio plays.
Audio File Requirements for Best Results
For telephony compatibility, use audio files in:
- Mono
- 8000 Hz sample rate
- 16-bit PCM wav preferred
Converting audio incorrectly is a common reason MOH sounds distorted.
Common Music on Hold Problems and Fixes
Caller Hears Silence
- MOH directory path wrong
- No audio files in folder
- Wrong permissions for asterisk user
Music Plays But Sounds Choppy
- Codec mismatch (Opus vs G.711 vs PCM)
- CPU overload on server
- Network jitter causing RTP issues
Music Works Internally but Not for Trunks
- RTP/NAT problem — caller cannot receive media
- Firewall blocking RTP ports
Best Practices for Production Call Centers
- Use different MOH classes for different departments
- Use short loopable tracks, not full songs
- Keep volume normalized (avoid sudden spikes)
- Test MOH from external trunk, not only internal calls
Music on Hold is part of customer experience, not just a technical feature.
Key Takeaway
Music on Hold prevents callers from hanging up and makes your call center sound professional.
Configure MOH classes in musiconhold.conf,
attach them to queues using musicclass,
and always test audio end-to-end through trunks
to confirm RTP and codecs are working correctly.
Want to see API-driven CRM + Telecom workflows in action? Try the WhatsApp bot or explore the demos.
Comments (0)
Be the first to comment.