[asterisk-users] Attatch monitor recording to a voicemail

Jared Smith jsmith at digium.com
Tue Feb 26 12:08:27 CST 2008


On Tue, 2008-02-26 at 19:48 +0200, Dovid B wrote:
> 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.




More information about the asterisk-users mailing list