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!
With SIP, the signaling is done via SIP and the digitized audio is sent via a different protocol, RTP. The SIP and RTP can and often are sent to different IP addresses. Thats normally not a problem, as long as the IP addresses are all reachable..
Whats happening in your situation, is something like this:
PBX2 sends a SIP INVITE to PBX1. Included in that INVITE is information about where to send the audio. PBX2 specifies its own IP address. Since its IP address is reachable from PBX1, calls between the two work.
Now, when the callee is an outside line, PBX1 sends its own INVITE to your provider, and passes on in that INVITE the information about where to send the audio (ie, the IP address of PBX2) If both PBXs were on public IPs, this would be fine. Since they are not both reachable from the outside, you need to modify the behavior of PBX1
On PBX1, in your sip.conf
file, there should be a peer configuration for PBX2. In that peer configuration, you need to add the following line:
canreinvite=no
(On more recent versions of asterisk, you would use directmedia=no
instead.)
This will cause PBX1 to stay in the media path whenever it is involved with a call with PBX2. In otherwords, when you call the outside world, PBX1 will give your provider its own IP address for where to send the audio, it will then proxy that audio, and send it on to PBX2.
Hope this helps!
Best Answer
To call out you will need one or more
phone lines
, either physical (PSTN/ISDN/PRI) or voip (SIP/IAX/H323).The easiest way is to get one or more numbers from a local SIP provider and setup a
trunk
in yoursip.conf
. Then is just a matter of configuring your dialplan to use thattrunk
to call external numbers.There are lots of examples here.