2

We're trialling a Asterisk Now server to take over from our ageing PBX system. One of the "nice to have" features would be the ability to pause or lower the volume on the office jukebox if an incoming call is detected.

We currently run a linux jukebox which plays music out of the speakers using mpd and can be controlled by the mpc client. We can manually issue the following command to achieve this:

mpc volume 20

Does anyone know how to get asterisk to execute this command or some action that we could hook into when a phone call is incoming to specific extensions?

Jona
  • 746
  • 1
  • 9
  • 17

2 Answers2

1

What a novel idea! I've not done that but I think I can get you going down the right path. If your system is similar to mine you'll find the following files that will serve as examples:

For digital faxing:

/etc/asterisk/extensions.conf

/var/lib/asterisk/bin/fax-process.pl

For emails with audio message attachments:

/etc/asterisk/extensions_additional.conf

/var/lib/asterisk/bin/audio-email.pl

We'll focus on the second action by taking a look at the part of the extensions_additional.conf file that deals with audio attachments:

[app-dictate-send]
include => app-dictate-send-custom
exten => *35,1,Answer
exten => *35,n,Macro(user-callerid,)
exten => *35,n,Noop(CallerID is ${AMPUSER})
exten => *35,n,Set(DICTENABLED=${DB(AMPUSER/${AMPUSER}/dictate/enabled)})
exten => *35,n,GotoIf($[$["x${DICTENABLED}"="x"]|$["x${DICTENABLED}"="xdisabled"]]?nodict:dictok)
exten => *35,n(nodict),Playback(feature-not-avail-line)
exten => *35,n,Hangup
exten => *35,n(dictok),Read(DICTFILE,enter-filename-short,,,,)
exten => *35,n,Set(DICTEMAIL=${DB(AMPUSER/${AMPUSER}/dictate/email)})
exten => *35,n,Set(DICTFMT=${DB(AMPUSER/${AMPUSER}/dictate/format)})
exten => *35,n,Set(NAME=${DB(AMPUSER/${AMPUSER}/cidname)})
exten => *35,n,Playback(dictation-being-processed)
exten => *35,n,System(/var/lib/asterisk/bin/audio-email.pl --file /var/lib/asterisk/sounds/dictate/${AMPUSER}/${DICTFILE}.raw --attachment dict-${DICTFILE} --format ${DICTFMT} --to ${DICTEMAIL} --subject "Dictation from ${NAME} Attached")
exten => *35,n,Playback(dictation-sent)
exten => *35,n,Macro(hangupcall,)

; end of [app-dictate-send]

You'll see that the /var/lib/asterisk/bin/audio-email.pl is referenced. The function runs line by line so if someone hangsup (ie line 8) then the .pl file is never fired off. But before this function can function it needs to be included like this:

include => app-dictate-send

I'm not going to print out the .pl file here. If you can write a pl file that will turn down the volume on your office jukebox when you manually run it, you can definitely set up Asterisk to fire off the pl when you get an incoming call.

Take a look at the /var/lib/asterisk/bin/fax-process.pl to see how asterisk fires off emails.

Now you'll probably want to adjust the first file I referenced above: /etc/asterisk/extensions.conf. This file tells Asterisk what to do when calls first come in. Take a look near the top of the file for this:

[from-did-direct]
include => ext-findmefollow
include => ext-local

You could create something like "turn_down_music.pl" and include it in a function like [app-lower-music]. You would then include it with:

[from-did-direct]
include => app-lower-music
include => ext-findmefollow
include => ext-local

Note that the [ext-local] file is defined in the extensions_additional.conf file but referenced in the the extensions.conf file. You can create your own custom extensions file and reference it in the extensions.conf file like this:

#include extensions_custom.conf
#include extensions_music.conf

Also note that # does not comment lines out. Instead ; comments lines out.

I have gained a lot from these two books:

Good luck!

Patrick R
  • 2,925
  • 1
  • 18
  • 27
  • Do not edit the extensions or extensions_additional, because they will be overwritten in the next "Apply changes". Please use extensions_custom.conf. – Icapan May 31 '10 at 12:08
0

If this AsteriskNow is similar to Elastix, you should define new section in extensions_custom.conf like:

[from-pstn-custom]
exten = 0123456,n,System(/var/lib/asterisk/bin/whatever-command.pl)

First number is your incoming DID, "n" is the order of executing commands (this one usually goes to the start of the list, because from-pstn-custom is included at the top). This can also be solved with AGI scripts, but this may be an overkill for you.

Icapan
  • 484
  • 1
  • 3
  • 9