TIPS Email Recorded calls to Voicemail Receipient

atsak

Guru
Joined
Sep 7, 2009
Messages
2,386
Reaction score
440
I need to implement this:
http://community.freepbx.org/t/solv...ecordings-post-call-recording-script/26747/13

For a client but I need it to go to the person whose email is assigned for the extension that recorded the call; or put another way I need the script to query the extension, lookup the voicemail email address in the mysql table that stores it, then email the recording in mp3 format to the recipient from that lookup.

Any takers for the programming / instructions or do I wander off to Freelancer? Happy to pay need to tell the client how much once you tell me how much !
 

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,634
Reaction score
846
It's not in the mysql database but here:-

MAILTO=$(grep $5 /etc/asterisk/voicemail.conf|cut -d "," -f3)
 

atsak

Guru
Joined
Sep 7, 2009
Messages
2,386
Reaction score
440
So would it work this way?

Code:
  #!/bin/bash
#This script emails the recorded call right after the call is hung up. Below are    the variables passed through asterisk
# $1 - Time String
# $2 - Source
# $3 - File
# $4 - unique id
# $5 - Destination
# $dt - Date and Time

/bin/nice /bin/sleep 3

dy=$(date '+%Y')
dm=$(date '+%m')
dd=$(date '+%d')
file_age=35
dtpath=/var/spool/asterisk/monitor/$dy/$dm/$dd/

/bin/nice /usr/local/bin/lame -b 16 -m m -q 9-resample $dtpath$3.wav  $dtpath$3.mp3
/bin/nice /bin/chown  asterisk:asterisk $dtpath/$3.mp3

dt=$(date '+%m/%d/%Y %r');

echo $dt

echo -e "You have a new call recording to listen to \n\n
The call date and time was $dt \n\n
The call was from $2 \n\n
The call was to $5 \n\n
And the unique call id was $4\n\n

Please see the attached file \n\n" | mail -a $dtpath$3.mp3 -s "New Call Recording" $(grep $5 /etc/asterisk/voicemail.conf|cut -d "," -f3)

/bin/nice /usr/bin/find /var/spool/asterisk/monitor/  -type f -mtime +"$file_age" |grep wav | \
        while read I; do
               /bin/rm  "$I"
        done
 

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,634
Reaction score
846
In the style of the script I would probably do something like

# $MAILTO - recipient
.
.
MAILTO=$(grep $5 /etc/asterisk/voicemail.conf|cut -d "," -f3)
if [[ ! $MAILTO =~ .*@.*\.*. ]];then [email protected];fi
.
.
Please see the attached file \n\n" | mutt -s "New Call Recording" -a $dtpath$3.mp3 -- $MAILTO
.
.

mail does not have an easy attachment syntax, mutt does, you might need to install it.
 
Last edited:

atsak

Guru
Joined
Sep 7, 2009
Messages
2,386
Reaction score
440
Yes, they said mutt was required for this to work, but that shouldn't be difficult.
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,202
Reaction score
5,224
FWIW: All of this is automagic in XiVO without ANY configuration other than plugging an email address into the VoiceMail setup for each user:

Cn0dM7kWgAA0eR9.jpg
 
Joined
Nov 14, 2008
Messages
1,398
Reaction score
320
Interesting. So I'm assuming that emails a traditional VM recording. Does it also email any call recordings that occur on that extension? If it doesn't there's probably a way to have the system 'see' it as something that should be mailed. Again if it doesn't I would think the XiVO folks could add that easily.
 

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,634
Reaction score
846
Well the script was specific for "Recordings" but the other less obvious function was it converted to mp3, which although not technically open source was readable back then by MS PC's, Apple's, Iphones and Androids, each individually would throw up on one of the file formats defined in voicemail.conf (only the first one would be sent, but a pita to do it by extension) Maybe it's no longer necessary, but my brand new Galaxy note 5 has a fit about playing .wav without massaging. the externnotify= settings in voicemail.conf can be utilized equally for vmails if you need it.
 

atsak

Guru
Joined
Sep 7, 2009
Messages
2,386
Reaction score
440
This is a legacy system running FreePBX so that's good about Xivo but it's 100x more work to convert this client than just figure out this requirement. I will start testing it out on Friday if I can.
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,202
Reaction score
5,224
Interesting. So I'm assuming that emails a traditional VM recording. Does it also email any call recordings that occur on that extension? If it doesn't there's probably a way to have the system 'see' it as something that should be mailed. Again if it doesn't I would think the XiVO folks could add that easily.

With XiVO, you can dial your own extension number and leave any message desired. Those messages are treated just like traditional voicemails.
 
Joined
Nov 14, 2008
Messages
1,398
Reaction score
320
With XiVO, you can dial your own extension number and leave any message desired. Those messages are treated just like traditional voicemails.
I'm wondering about call recordings that result from a user invoking a recording of a phone conversation. It it was deposited in the same place on an XiVO machine maybe it would be mailed too. That would be a great feature for firms that need to keep recorded calls.
 

jerrm

Guru
Joined
Sep 23, 2015
Messages
838
Reaction score
405
FWIW: All of this is automagic in XiVO without ANY configuration other than plugging an email address into the VoiceMail setup for each user:

Cn0dM7kWgAA0eR9.jpg
The script is for call recordings, not voicemail.

Your saying XIVO emails call recordings automatically, with no further customization? I don't recall that happening, but would need to fire up the image again to test.
 
Joined
Nov 14, 2008
Messages
1,398
Reaction score
320
Maybe someone who is up to date on how-where VM's and recorded calls are stored could comment. Even if they are are recorded in different places it may be as simple as running a script and cron to move the recording from one place to another to make it appear as a voicemail recording. Then everything would work as desired. I like the idea of using the existing VM-email nuts and bolts as much as possible.
 
Last edited:

jerrm

Guru
Joined
Sep 23, 2015
Messages
838
Reaction score
405
Maybe someone who is up to date on how-where VM's and recorded calls are stored could comment. Even if they are are recorded in different places it may be as simple as running a script and cron to move the recording from one place to another to make it appear as a voicemail recording. Then everything would work as desired. I like the idea of using the existing VM-email nuts and bolts as much as possible.
Do you want recordings in the voicemail inbox or folder, or do you want to leverage the existing voicemail mail-a-message code to mail call recordings?

Dropping a recording into the VM inbox (or other folder) is pretty simple, but doesn't trigger an email. Not sure hooking into voicemail just to build an email message would be worth the trouble (if possible at all) considering the asterisk generated message has to be taken apart and re-assembled by a user supplied script if an mp3 attachment is desired.
 
Joined
Nov 14, 2008
Messages
1,398
Reaction score
320
Logically I like the idea of keeping the recordings associated to a user with as much of the existing framework as possible but I can see some people might want to email the recordings to a central email box. Maybe a new menu in the gui needs to deal with what happens to call recordings as they are competed. This is a perfect example of a function that many, many businesses need and yet this is an undeveloped area of Asterisk or the GUI's that has languished for years.

In terms of using the existing VM->email functionality I wonder what actually triggers the email. If you are dropping a recording into something it seems like you should be able to make it appear to be a real voicemail.
 

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,634
Reaction score
846
I would have to agree with @jerrm , comedianmail (app_voicemail) is completely different from most of Asterisk so is in fact a predicate of Asterisk ( well, not quite ast here is minivm also)

if you look at app_voicemail.c you will see how "flat-form" it is, if you create a voice mail you will need a t a minimum a msgnnnn.txt that describes it's nature and a msgnnnn.wav (the audio file), BUT if you add it into ../INBOX you need to sort any files there into msgn* to msgn+1.* and add your additional message as msg0000.{txt,msg}, BUT it still won't call either the inbuilt notify_new_message function or the externnotify script. (maybe with pollmailboxes=yes set it probably would, as that will call app_voicemail for every box on the system every pollfreq=n seconds, I havent tried it because it is such a PITA to get working that way anyway)

As I suggested before and pragmatically, for emails use

externnotify=youremailnotifyscript.sh


for call recordings use the "post recording script" as discussed above, It will apply to any Asterisk derived PBX , so FreePBX and Xivo are equally covered.

If you want to also send to a central mailbox then read the script and

man mutt

to add/change mail addresses.
 
Last edited:

jerrm

Guru
Joined
Sep 23, 2015
Messages
838
Reaction score
405
In terms of using the existing VM->email functionality I wonder what actually triggers the email. If you are dropping a recording into something it seems like you should be able to make it appear to be a real voicemail.
The email is generated and message delivered directly from the leave_message function in app_voicemail, the same function that records the message, plays the menus, handles the dtmf selections, etc. It is monolithic. There's not an abstraction layer or process to say "this is a message, go deliver it" to.

It's easy to build a message and drop it into a traditional, imap or odbc mailbox, but as @dicko suggests, if someone does so, they have to take full responsibility for the message and handle any email, renumbering, notifications, etc.
 
Last edited:
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top