Description
Asterisk’s Music On Hold (moh) is a great feature to enhance the ergonomy of an auto attendant (IVR).
Nevertheless, it lacks provision to play music for a limited given length of time.
As a result, one cannot trivially rely on basic moh features for providing the incoming call with a few seconds of music before connecting to the auto-attendant.
A solution
What if we could dial a fake number for a given length of time, say 10 seconds, and tell Dial() to play moh (option m in third argument) during this time, something like :
Dial(${FakeNumber},10,m)
This idea makes the basis of our solution.
- Step 1 : Define a moh timer.
First, define a section in the Asterisk’s dialplan (file extensions.conf) to mimic a timer, something that takes one argument (the extension) to set the number of seconds the timer should run before going off :
[moh_timer]
exten => _X!,1,Wait(${EXTEN})
- Step 2 : Call this timer by dialing it through a local channel (reentrant call to the Dialplan)
Dial(local/10@moh_timer,10,m) ; play 10 seconds of moh !
- Step 3 : Use an Asterisk’s macro to provide the user with a friendly interface
[macro-moh]
exten => s,1,Dial(local/${ARG1}@moh_timer,${ARG1},m)
- Step 4 : Plug the whole thing to the general diaplan
[incoming]
exten => s,1,Answer()
exten => s,n,Macro(moh,5) ; Please give the incoming call 5 seconds of music on hold! Thanks :-)
exten => s,n,Goto(ivr,s,1)
[ivr]
...
Author
Franck PORCHER,Ph.D.
Date
Fri 17 of Oct, 2008 (10:25 UTC)