What I Do At Work

This is an archived post
This is an archived post

Conditional music on hold without the use of queues

March 26 2013, 4:07 PM by Mike Boylan

Last week, RMU won the first round of the NIT tournament against Kentucky. We got a request this week to make the hold music for the athletic department be a radio clip of the final minute of the game. Using a call queue, this would incredibly easy. But unfortunately, not all of the numbers in the athletic department are part of a call queue. I devised a solution to this problem today using AstDB. We'll automate the process of loading the extentions that require special hold music into AstDB along with the department name.

Example:database put department 9001 Athletics

We'll then add an entry into musiconhold.conf with a context name that matches the department name:[Athletics]mode=filesdirectory=/var/lib/asterisk/moh/athletics

From there, we just need to modify stdexten to check for a database entry and modify the channel variable musicclass on the fly:exten => n,Set(CHANNEL(musicclass)=${IF($[${DB_EXISTS(department/${EXTEN})}]?${DB_RESULT}:default)})

This line checks to see if a database entry exists at department/${EXTEN}, and if so, sets the musicclass channel variable equal to the department name, ${DB_RESULT}. If there is no entry in the database, it simply uses the default music class.