[SOLVED] How To Email Call Recordings Post Call Recording Script


(Zamin) #8

Thanks dear Its a good and Pretty good feature i tried its to much good


(Zamin) #9

dear i try Asterisk 11.14 its not working kindly plz tell can i install mail server in centos then it will work now


#10

I installed this script and there are no emails. I have a question the email@domain.com entry what is that for? Is that supposed to be the email that the system is using? Or the smtp server for the system? Sorry for the noob question.


#11

I suspect that @dslauter might have aliased mail to mutt for the -a to work

man mail
man mutt

If you don’t have mutt then

yum|apt-get install mutt


Email on demand recording
#12

+1
This should be included in the wiki pages.


(Ian Plain) #13

In case anyone comes across this post I have extened teh script to convert the recording to mp3 before emailing it.

  #!/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" mail@domain.com

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

The post record string in freepbx is as below

/usr/local/sbin/postrecord.sh ^{TIMESTR} ^{FROMEXTEN} ^{CALLFILENAME} ^{UNIQUEID} ^{ARG3}

Finally remember to set the masquerade in sendmail so that the email correctly addressed

Enjoy


Converting recorded wav calls to mp3
(Aaron Gustafson) #14

Sorry I’m a bit of a noob, can you explain this?

Also is there any chance someone could explain or add the code so that this would then DELETE the recording? I have a limited storage space…

Thx


(Ian Plain) #15

Hi the last but one deletes file sover a certain age $file_age which is defined up the top in this case as 35 days but could change that to say 2

Ian


(Vlad) #16

For some reason my ^{TIMESTR} ^{FROMEXTEN} ^{CALLFILENAME} ^{UNIQUEID} ^{ARG3}
are blank for the script, which runs fine and sends test email etc


#17

You would have to state better your problem, that is the the interpreted ( by asterisk/Comedian mail) string that would be passed to your script as the first argument, be that a bash, perl, php whatever script.


(Vlad) #18

turns out it only happens with on demand recording (*1)
if whole session is recorded it transfers parameters to .sh fine
it is clear in logs

[2016-09-30 00:59:20] VERBOSE[2265] app_mixmonitor.c: Executing [/var/lib/asterisk/bin/emailrecording.sh]

[2016-09-30 00:50:50] VERBOSE[27016][C-00000017] app_mixmonitor.c: Executing [/var/lib/asterisk/bin/emailrecording.sh 20160930-005041 007 internal-008-007-20160930-005041-1475211041.43 1475211041.43 008]

might be a bug
can someone check if on demand recording sends?


Post Call Recording Script not sent correctly to MixMonitor
(Vlad) #19

had another minute for this
It does not because MixMonitor call is happening in /var/lib/asterisk/bin/one_touch_record.php which has no idea and doesn’t read ^ well. With regular recording it calls MixMonitor in extensions_additional.conf

in extensions_additional.conf:
[macro-one-touch-record]
include => macro-one-touch-record-custom
exten => s,1,Set(ONETOUCH_REC_SCRIPT_STATUS=)
exten => s,n,System(/var/lib/asterisk/bin/one_touch_record.php “${CHANNEL(name)}”)

in /var/lib/asterisk/bin/one_touch_record.php:
$astman->mixmonitor($masterChannel, “{$mixMonDir}{$year}/{$month}/{$day}/{$callFileName}.{$mixMonFormat}”, “ai(LOCAL_MIXMON_ID)$beep”, $mixMonPost, rand());

guess we need to fix one_touch_record.php to forward those ^ correctly as it seems they are processed by MixMonitor itself


(Vlad) #20

moved it out of this topic to FreePBX as php one is it


(Renato Fiuza) #21

Very good, it works great.
Thank you guys.


(Anton Dragushin) #22

Hello, guys, thanks a lot for this solution.

Could someone help me with adding call duration into the e-mail body?
I’ve added # $6 - Call duration as a comment and Call duration: $6\n into e-mail body, but I still have no idea what variable to use in Post Call Recording Script. I’ve tried ^{DIALEDTIME} (which gives nothing) and ^{CDR(duration)} (which gives 0 as the result).

Thanks in advance.


(Alireza M) #23

Hi, Thanks,
Is there any documentation for variables that i can use ?


(Otto) #24

If someone who has gotten this to work could post the last few resultant log file lines so others can compare with theirs it would be much appreciated.

Here is mine. The app_mixmonitor.c seems to be ending the recording after executing the email script. Is this normal?

NOTE: I know there are no FREEPBX passed variables; I was testing with a hard-coded email to see what was broken and why my emails aren’t being sent by the script.

UPDATE: The script works as intended when called directly from command line. This leaves only the possibility that the server is preventing the complete execution somehow for some reason. As noted above, file-dependent variables are not factors.


(Otto) #25

A list from 2016…
https://www.voip-info.org/wiki/view/Asterisk+variables

Not sure if this is what FREEPBX also uses because {TIMESTR} isn’t mentioned.
Still, if you look at the Asterisk log file you’ll see that variable works.


(Otto) #26

UPDATE:
Finally got this working. Make certain that any email configuration file (.muttrc for instance) is where it is expected to be by the user (in this case asterisk) running the post-call script. In mutt’s case, the file needs to be in ~/ of the asterisk user.

Also, remember variables need to be “$var”, not ‘$var’ in order to pass their values in the echo.

After the above was fixed, call recordings went to my inbox without a hitch!


(Arun Shah) #27

Great thread guys, thanks very much for the script.

I have been struggling to send out HTML emails using this script, can anyone show me how?

I want the HTML to have variables just like this script.

thanks.