Sponsor: VoiceMeUp - Corporate & Wholesale VoIP Services

VoIP Mailing List Archives
Mailing list archives for the VoIP community
 SearchSearch 

[asterisk-users] Attatch monitor recording to a voicemail


 
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> Asterisk Users
View previous topic :: View next topic  
Author Message
ben.willcox at british...
Guest





PostPosted: Mon Feb 18, 2008 5:17 pm    Post subject: [asterisk-users] Attatch monitor recording to a voicemail Reply with quote

Hello All,

Our old Lucent Argent system had a feature whereby when you initiate
recording during a call, it would afterwards send the recording as a
voicemail message to the user who initiated the recording.

We use the automon *1 recording function in asterisk, which allows users
to record a call if necessary on the fly. Unfortunately there doesn't
appear to be an easy way for the user to actually access that
recording.
What I'd like to do is replicate the functionality described above, so
that when the call finishes, asterisk sends a voicemail to the user
containing the monitor recording.

I'm not sure of the best way to achieve this - is there a method I can
use within the asterisk dialplan, or do I need to manipulate the automon
wav file and voicemail directory contents outside of asterisk to put the
recording in the users mailbox?

Thanks,
Ben
Back to top
jsmith at digium.com
Guest





PostPosted: Mon Feb 18, 2008 9:21 pm    Post subject: [asterisk-users] Attatch monitor recording to a voicemail Reply with quote

On Mon, 2008-02-18 at 22:17 +0000, Ben Willcox wrote:
Quote:
We use the automon *1 recording function in asterisk, which allows users
to record a call if necessary on the fly. Unfortunately there doesn't
appear to be an easy way for the user to actually access that
recording.

I've always done this by setting the MONITOR_EXEC channel variable to
point to an external program that takes care of moving the recording to
the proper location so that it can be accessed by the user who made the
recording. I'll bet if you search for MONITOR_EXEC and
MONITOR_EXEC_ARGS you'll find exactly what you need.

--
Jared Smith
Community Relations Manager
Digium, Inc.
Back to top
ben.willcox at british...
Guest





PostPosted: Tue Feb 19, 2008 3:59 pm    Post subject: [asterisk-users] Attatch monitor recording to a voicemail Reply with quote

Jared Smith wrote:

Quote:
I've always done this by setting the MONITOR_EXEC channel variable to
point to an external program that takes care of moving the recording to
the proper location so that it can be accessed by the user who made the
recording. I'll bet if you search for MONITOR_EXEC and
MONITOR_EXEC_ARGS you'll find exactly what you need.

Thanks Jared,

That gets me halfway there, but what I'm wondering about is the process
of moving of the recording to the correct place - i.e. should my
external program do the following:

1) Check the users voicemail directory for existing message filenames
2) Copy the recording into the voicemail directory named msgxxxx.WAV
(incremented depending on number of existing messages)
3) Create the msgxxxx.txt file in the correct format

or is there another way that will sort this all out automatically? What
would happen if a real voicemail drops into that directory while my
external script is halfway through copying/creating for example...

Cheers,
Ben
Back to top
jsmith at digium.com
Guest





PostPosted: Tue Feb 19, 2008 4:53 pm    Post subject: [asterisk-users] Attatch monitor recording to a voicemail Reply with quote

On Tue, 2008-02-19 at 20:59 +0000, Ben Willcox wrote:
Quote:
That gets me halfway there, but what I'm wondering about is the process
of moving of the recording to the correct place - i.e. should my
external program do the following:

1) Check the users voicemail directory for existing message filenames
2) Copy the recording into the voicemail directory named msgxxxx.WAV
(incremented depending on number of existing messages)
3) Create the msgxxxx.txt file in the correct format

or is there another way that will sort this all out automatically? What
would happen if a real voicemail drops into that directory while my
external script is halfway through copying/creating for example...

No, you're on the right track.

In a nutshell, you'll have to figure out whether app_voicemail looks a
the .txt files or the actually recordings first (when determining the
next message number), and have your program create that file first. (As
I recall, it's the .txt files that app_voicemail looks at.) Obviously
if you're not careful, there can be a race condition there, but the idea
is that if a caller were to leave a voicemail on the system, it would
see the file already there and choose the next number.

--
Jared Smith
Community Relations Manager
Digium, Inc.
Back to top
asteriskusers at dovid...
Guest





PostPosted: Tue Feb 26, 2008 12:48 pm    Post subject: [asterisk-users] Attatch monitor recording to a voicemail Reply with quote

----- Original Message -----
From: "Jared Smith" <jsmith at digium.com>
To: "Asterisk Users Mailing List - Non-Commercial Discussion"
<asterisk-users at lists.digium.com>
Sent: Tuesday, February 19, 2008 11:53 PM
Subject: Re: [asterisk-users] Attatch monitor recording to a voicemail
Quote:
On Tue, 2008-02-19 at 20:59 +0000, Ben Willcox wrote:
Quote:
That gets me halfway there, but what I'm wondering about is the process
of moving of the recording to the correct place - i.e. should my
external program do the following:

1) Check the users voicemail directory for existing message filenames
2) Copy the recording into the voicemail directory named msgxxxx.WAV
(incremented depending on number of existing messages)
3) Create the msgxxxx.txt file in the correct format

or is there another way that will sort this all out automatically? What
would happen if a real voicemail drops into that directory while my
external script is halfway through copying/creating for example...

No, you're on the right track.

In a nutshell, you'll have to figure out whether app_voicemail looks a
the .txt files or the actually recordings first (when determining the
next message number), and have your program create that file first. (As
I recall, it's the .txt files that app_voicemail looks at.) Obviously
if you're not careful, there can be a race condition there, but the idea
is that if a caller were to leave a voicemail on the system, it would
see the file already there and choose the next number.

--
Jared Smith
Community Relations Manager
Digium, Inc.


Jared,
You mentioned that you have done it in the past.Can you post your code here
?

Thanks.

Dovid
Back to top
jsmith at digium.com
Guest





PostPosted: Tue Feb 26, 2008 1:08 pm    Post subject: [asterisk-users] Attatch monitor recording to a voicemail Reply with quote

On Tue, 2008-02-26 at 19:48 +0200, Dovid B wrote:
Quote:
Jared,
You mentioned that you have done it in the past.Can you post your code here

No, unfortunately this was done under NDA, but the general gist goes
like this:

Dialplan pieces:

A) Get automon working. Don't forget to set the DYNAMIC_FEATURES
variable (either as a global variable, or on a channel-by-channel
basis).

B) Set the MONITOR_EXEC variable to point to the program explained
below. (I suggest learning about how to prepend an underscore or two to
the beginning of a variable name to ensure that it gets inherited by any
created channels.) For example, I set:

exten => example,n,Set(_MONITOR_EXEC=/usr/local/bin/automon-to-vm)

C) Set the MONITOR_EXEC_ARGS variable to tell the program below any
information which it might need. My example is a bit messy (and
probably overengineered), but here it is. (Just promise me you won't
laugh at it.)

exten => example,n,Set(ORIGDATE=${BASE64_ENCODE(${STRFTIME(${EPOCH},,%a
%b %e %r %Z %Y)})})
exten => example,n,Set(_MONITOR_EXEC_ARGS=${MACRO_EXTEN}^${CONTEXT}^
${MACRO_CONTEXT}^${EXTEN}^${PRIORITY}^${CHANNEL}^
${BASE64_ENCODE(${CALLERID(all)})}^${ORIGDATE}^${EPOCH})

OK, now for the program itself to take the recorded audio and send it to
voicemail:

1) Mix the inbound and outbound audio channels. I use soxmix to do
this, and put the inbound on the left channel and the outbound on the
right channel. For completeness' sake, convert into the various formats
you have defined in voicemail.conf (typically wav, WAV, and gsm).
2) Iterate
through /var/spool/asterisk/voicemail/${VM-CONTEXT}/${MAILBOX}/INBOX/,
looking for msg0000.*, msg0001.*, etc. until you no longer find that
message. Move the audio file(s) created in step 2 to this location.
3) Create an appropriate .txt file that goes with the message. If you
look at a regular voicemail recording, you'll see there's a .txt file in
addition to the audio file(s). This text file specifies when the
voicemail recording was left, the duration, the CallerID information,
etc.

Anybody with reasonable programming skills should be able to do this in
a few dozen lines of code -- it's nothing too spectacular.

--
Jared Smith
Community Relations Manager
Digium, Inc.
Back to top
asteriskusers at dovid...
Guest





PostPosted: Tue Feb 26, 2008 1:37 pm    Post subject: [asterisk-users] Attatch monitor recording to a voicemail Reply with quote

----- Original Message -----
From: "Jared Smith" <jsmith at digium.com>
To: "Dovid B" <asteriskusers at dovid.net>
Cc: "Asterisk Users Mailing List - Non-Commercial Discussion"
<asterisk-users at lists.digium.com>
Sent: Tuesday, February 26, 2008 8:08 PM
Subject: Re: [asterisk-users] Attatch monitor recording to a voicemail
Quote:
On Tue, 2008-02-26 at 19:48 +0200, Dovid B wrote:
Quote:
Jared,
You mentioned that you have done it in the past.Can you post your code
here

No, unfortunately this was done under NDA, but the general gist goes
like this:

Dialplan pieces:

A) Get automon working. Don't forget to set the DYNAMIC_FEATURES
variable (either as a global variable, or on a channel-by-channel
basis).

B) Set the MONITOR_EXEC variable to point to the program explained
below. (I suggest learning about how to prepend an underscore or two to
the beginning of a variable name to ensure that it gets inherited by any
created channels.) For example, I set:

exten => example,n,Set(_MONITOR_EXEC=/usr/local/bin/automon-to-vm)

C) Set the MONITOR_EXEC_ARGS variable to tell the program below any
information which it might need. My example is a bit messy (and
probably overengineered), but here it is. (Just promise me you won't
laugh at it.)

exten => example,n,Set(ORIGDATE=${BASE64_ENCODE(${STRFTIME(${EPOCH},,%a
%b %e %r %Z %Y)})})
exten => example,n,Set(_MONITOR_EXEC_ARGS=${MACRO_EXTEN}^${CONTEXT}^
${MACRO_CONTEXT}^${EXTEN}^${PRIORITY}^${CHANNEL}^
${BASE64_ENCODE(${CALLERID(all)})}^${ORIGDATE}^${EPOCH})

OK, now for the program itself to take the recorded audio and send it to
voicemail:

1) Mix the inbound and outbound audio channels. I use soxmix to do
this, and put the inbound on the left channel and the outbound on the
right channel. For completeness' sake, convert into the various formats
you have defined in voicemail.conf (typically wav, WAV, and gsm).
2) Iterate
through /var/spool/asterisk/voicemail/${VM-CONTEXT}/${MAILBOX}/INBOX/,
looking for msg0000.*, msg0001.*, etc. until you no longer find that
message. Move the audio file(s) created in step 2 to this location.
3) Create an appropriate .txt file that goes with the message. If you
look at a regular voicemail recording, you'll see there's a .txt file in
addition to the audio file(s). This text file specifies when the
voicemail recording was left, the duration, the CallerID information,
etc.

Anybody with reasonable programming skills should be able to do this in
a few dozen lines of code -- it's nothing too spectacular.

--
Jared Smith
Community Relations Manager
Digium, Inc.


Thanks a lot.
Back to top
ben.willcox at british...
Guest





PostPosted: Tue Feb 26, 2008 3:59 pm    Post subject: [asterisk-users] Attatch monitor recording to a voicemail Reply with quote

Jared Smith wrote:

Quote:
No, unfortunately this was done under NDA, but the general gist goes like this:

As it happens, I deployed my solution to this on our live PBX today, which I
wrote with some help from another asterisk-users user. Here is what I
came up with:

Firstly, in features.conf I don't use the normal automon function in the
featuremap, but an applicationmap:

[applicationmap]
recordtovm =>*1,self,Macro,recordtovm
Then in extensions.conf we have the following additions:

[globals]
DYNAMIC_FEATURES=>recordtovm

[macro-recordtovm]
exten => s,1,Set(MONITOR_FILENAME=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${CALLERID(num)})
exten => s,n,Set(DYNAMIC_FEATURES=recordtovm)
exten => s,n,MixMonitor(${MONITOR_FILENAME}.wav,b,/etc/asterisk/recordtovm.pl ${CALLERID(num)} ${MONITOR_FILENAME}.wav)

And finally the perl script recordtovm.pl in /etc/asterisk/ is as follows:

#!/usr/bin/perl -w
#
use strict;

my $monitordir="/var/spool/asterisk/monitor/";
my $vmdir="/var/spool/asterisk/voicemail/default/";
my $vmfolder="INBOX";
my $vmbox=$ARGV[0];
my $vmpath=$vmdir."$vmbox/"."$vmfolder";
my $monitorfilename=$ARGV[1];

opendir (DIR, $vmpath);
my @files = grep(/\.txt$/,readdir(DIR));
closedir(DIR);
my @sortedfiles = sort {$b cmp $a} @files;
my $vmid;
if ($sortedfiles[0] =~ /^(msg)(\d\d\d\d)(.txt)/)
{
$vmid=$2;
$vmid++;
}
else
{
$vmid="0000";
};

open VMFILE,"> $vmpath/msg$vmid.txt";
print VMFILE ";\n";
print VMFILE "; Message Information file\n";
print VMFILE ";\n";
print VMFILE "[message]\n";
print VMFILE "origmailbox=$vmbox\n";
print VMFILE "context=\n";
print VMFILE "macrocontext=\n";
print VMFILE "exten=s\n";
print VMFILE "priority=\n";
print VMFILE "callerchan=\n";
print VMFILE "callerid=\n";
print VMFILE "origdate=\n";
print VMFILE "origtime=\n";
print VMFILE "category=\n";
print VMFILE "duration=\n";
close VMFILE;

if ($ARGV[1])
{
system("mv $monitordir"."$monitorfilename $vmpath/msg$vmid.wav");
};


Seems to work pretty well, we have the Record button on our SNOM phones mapped to DTMF *1,
so its a single press to start recording. The perl script doesn't populate the origdate and
origtime fields at the moment so you'll need to add this if you want the time and date saving
with the message.

Hope this helps,

Ben
Back to top
Display posts from previous:   
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> Asterisk Users All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

VoiceMeUp - Corporate & Wholesale VoIP Services