?
Solved

Cleaning up Outbound Recording Names in Asterisk

Posted on 2006-04-18
17
Medium Priority
?
792 Views
Last Modified: 2012-05-05
Hi all..

I’m once again attempting to make a messy feature in Asterisk actually useful.   I’ve managed to correctly tag inbound .wav files to appear as something meaningful:  5551212-20060418-095359.wav.  Well, sort of.  I’m not sure where the 095359 is coming from, or how to get rid of that.  I’m using the following snippet, but slightly modified, however:

exten => s,1,SetVar(CALLFILENAME=${CALLERIDNUM:0:9}-${TIMESTAMP})
exten => s,2,Monitor(wav,${CALLFILENAME},m)
exten => s,3,Dial(SIP/204,30)

Hmm.. Something doesn’t look quite right here.  Not a big deal, but if someone wants to suggest a cleaner filename method, I’d welcome it :-)


Here’s the real problem:

The outbound files names in /var/spool/asterisk/monitor are even more useless.  Have a look: OUT204-20060417-173818-1145309898.156.WAV  The only thing remotely useful here is this name of the local extension number/ date.  The rest of it is essentially dung.

I’m trying to get the outbound numbers in /var/spool/asterisk/monitor to appear as follows:  3165551212-20060417.wav    Or… This would be even more useful:  316-555-1212@2006-04-17.wav   It’d also be nice to place OutBound .wavs in an Outbound folder:  Perhaps, /var/spool/asterisk/monitor/Outbound

In extensions.conf, I’ve tried messing with the following contexts:  

[macro-dialout-default]
exten => s,2,Macro(record-enable,${CALLERID(number)},OUT)

[macro-dialout-trunk]
exten => s,4,Macro(record-enable,${CALLERID(number)},OUT)
exten => s,5,Macro(outbound-callerid,${ARG1})

Playing around with these has not done a great deal, except disabling Outbound recordings completely.   Am I barking up the wrong tree here?

Question:

Is there a really simple way to do this?  Is there a sample recipe someone can post, which will at least get me started, or point me in the right direction?   If I’m going to put Asterisk in a production environment, then I need to sift through these features; find the flaws, then figure out the appropriate fixes/ tweaks.

Any help would be greatly appreciated,

Dave

Asterisk 1.2.6
FreePbx 2.8-Beta
0
Comment
Question by:dholingw
  • 10
  • 7
17 Comments
 
LVL 36

Expert Comment

by:grblades
ID: 16481129
20060418-095359 should be 18th april 2006  09:53:59am. The time is probably in UTC so you would need to apply your local timezone offset to it (not 100% sure of this).

A number like 1145309898.156 would be the unique call reference that * assigns to the specific call.
0
 

Author Comment

by:dholingw
ID: 16481396
Right now, I’d be quite happy with just getting the outbound call wavs to appear with the ‘Outbound called number’, i.e., 315-555-1212.wav.  

I really don't need to see Asterisk's call reference, as it's rather meaningless to the average human.  To make the files useful, you need to reference them some how.  I think the outbound phone number would likely make the most logical sense, unless one could somehow figure out what significance 1145309898.156 has :)

Thanks,

D.
0
 
LVL 36

Expert Comment

by:grblades
ID: 16481843
So you are happy with the naming of the inbound calls?

For the outbound calls what are you using to record them?
You are showing that you are calling a macro but how is this macro defined?

You normally only have one section for outbound calls so there is no real point defining a macro for it as it will only be called in one place. The following example will record a call in the format "3155551212@20060418-091212.wav". A '9' is used to access the outside line and the leading 9 is stripped off when the call is placed over the zaptel interface.

exten => _9.,1,SetVar(CALLFILENAME=${EXTEN:1}@${TIMESTAMP})
exten => _9.,2,Monitor(wav,${CALLFILENAME},m)
exten => _9.,3,Dial(ZAP/g1/${EXTEN:1})
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

by:dholingw
ID: 16482311
That’s not quite was I was looking for, but it did provide my missing piece to the “inbound calls”, which was being able to add the @ symbol: 5551212@20060418-165957.wav  hey, now that’s beginning to look better :-)   Ugh… I wish there was a way to stop the unique ID from being echoed to the inbound call file though.  Btw... I don't run any Zap channels. I have the SPA3000.  

Now, onto the Outbound call thing.

You said…

> For the outbound calls what are you using to record them?
> You are showing that you are calling a macro but how is this macro defined?

Sorry, I thought I explained that in the original post.   I wasn’t sure where the outbound recording subroutines were, so I started rifling through the extensions.conf file.  This was the only file that seem to have anything remotely related to the record-call stuff.  

Starting nosing around and found this:

; dialout using default OUT trunk - no prefix
[macro-dialout-default]
exten => s,1,Macro(user-callerid)
exten => s,2,Macro(record-enable,${CALLERID(number)},OUT)
exten => s,3,Macro(outbound-callerid,${ARG1})
exten => s,4,Dial(${OUT}/${ARG1})
exten => s,5,Congestion
exten => s,105,Macro(outisbusy)

I played around with exten => s,2 in hopes of changing the file name on ‘outbound’ calls.  I want the ‘Called number” and “date” to appear in the file name –nothing else.   Well… No luck here, so I tried messing with this one:

; dialout using a trunk, using pattern matching (don't strip any prefix)
; arg1 = trunk number, arg2 = number, arg3 = route password
[macro-dialout-trunk]
exten => s,1,GotoIf($["${ARG3}" = ""]?3:2)      ; arg3 is pattern password
exten => s,2,Authenticate(${ARG3})
exten => s,3,Macro(user-callerid)
exten => s,4,Macro(record-enable,${CALLERID(number)},OUT)
exten => s,5,Macro(outbound-callerid,${ARG1})
exten => s,6,Set(GROUP()=OUT_${ARG1})
exten => s,7,GotoIf($[ ${GROUP_COUNT()} > ${OUTMAXCHANS_${ARG1}} ]?108)
; if we've used up the max channels, continue at (n+101)
exten => s,8,Set(DIAL_NUMBER=${ARG2})
exten => s,9,Set(DIAL_TRUNK=${ARG1})
exten => s,10,AGI(fixlocalprefix) ; this sets DIAL_NUMBER to the proper dial string for this trunk
exten => s,11,Set(OUTNUM=${OUTPREFIX_${ARG1}}${DIAL_NUMBER})  ; OUTNUM is the final dial number
exten => s,12,Set(custom=${CUT(OUT_${ARG1},:,1)})  ; Custom trunks are prefixed with "AMP:"
exten => s,13,GotoIf($["${custom}" = "AMP"]?16)
exten => s,14,Dial(${OUT_${ARG1}}/${OUTNUM}|120|W)  ; Regular Trunk Dial, allow recording.
exten => s,15,Goto(s-${DIALSTATUS},1)

In here, I fooled around with s,4 and s,5.  No luck… Either I killed recording completely, and anything else I changed, did nothing.  

Forgive the verbose response, but I just wanted to make sure you knew what I was trying to do, and how.  This is probably the wrong way to go about it anyway, but I had to start somewhere, right :)  So, this is what I’d like to do for ‘Outbound’ calls:

Send them here:  /var/spool/asterisk/monitor/outbound
Have them appear as: 5551212@20060418.wav

Many thanks again,

D.


0
 

Author Comment

by:dholingw
ID: 16483674
See what I’m saying grblades?

If “Record Outgoing Calls” is selected in AMP, then it has to be using one of the two following contexts in extensions.conf, which are:

[macro-dialout-default]
exten => s,1,Macro(user-callerid)
exten => s,2,Macro(record-enable,${CALLERID(number)},OUT)

Or these particular lines under [macro-dialout-trunk] :

exten => s,1,Macro(user-callerid)
exten => s,2,Macro(record-enable,${CALLERID(number)},OUT)


For me, the hint is ‘OUT’, as that’s what shows up at the beginning of outbound files names like so:

OUT204-20060418-192358-1145402638.295.WAV

So the changes I think would be done to one of the above.  I can’t find anything else in /etc/Aterisk that has anything to do with the Record feature.  

D.
0
 
LVL 36

Expert Comment

by:grblades
ID: 16485002
> Macro(record-enable,${CALLERID(number)},OUT)
This is calling a macro called record-enable. It is this macro you need to find as it is probably defining a filename and just using the callerid as part of that filename. Once you find the macro it should be easy to change the format to whatever you wish.
0
 

Author Comment

by:dholingw
ID: 16487729
Yes, I know that.  As I mentioned already, I’ve fiddled with these, but only one of two things happen:

- Absolutely nothing at all
- Recording is broken completely

In other words, it bears little forgiveness. Either you know the magic edit, or it just pukes.  I honestly can’t believe this feature has been out for this long, yet anyone that wants to make use of it, had better get ready to hack the half-baked code.  Unbelievable..  

D.  
0
 
LVL 36

Expert Comment

by:grblades
ID: 16487831
The problem is that the recording macro is not standard asterisk. It has been added as part of @home.

If you go to the /etc/asterisk directory and enter the following command it should show you which file contains the macro
fgrep -R macro-record *
0
 

Author Comment

by:dholingw
ID: 16488447
-> The problem is that the recording macro is not standard asterisk. It has been added as part of @home.

Yes, and like many developers of  exciting projects such as this, they focus more on bloating future versions with a barrage of new gizmos, while failing to make sure that A. (the features they already have) are actually stable, and B., They haven’t broken 'existing' functionality, prior to banging out the next latest greatest beta release.   Case in point =2.8.  However, the recording features have never worked properly anyway.

Back to the problem at hand...

Hey… [macro-record-enable]  Seems to be having some effect on things.  At least now I can alter the Outbound file name –not to what, but it’s still progress.  

[macro-record-enable]
exten => s,1,GotoIf(${LEN(${BLINDTRANSFER})} > 0?2:4)
exten => s,2,ResetCDR(w)
exten => s,3,StopMonitor()
exten => s,4,AGI(recordingcheck,${TIMESTAMP},${UNIQUEID})
exten => s,5,Noop(No recording needed)
exten => s,999,Monitor(wav49,${CALLFILENAME},

The problem is, I have no idea what Asterisk is using to grab the ‘outbound’ called number.  Could be (user-callerid), ${CALLERID(number)},OUT), or outbound-callerid,${ARG1}).  I’ve tried swapping out the necessary snippets in the following:

exten => s,4,AGI(recordingcheck,${TIMESTAMP},${UNIQUEID})
exten => s,999,Monitor(wav49,${CALLFILENAME}

Nothing seems to happen when I alter these, other than my modified statement appearing in the .wav filename.  

The confusing thing, is that it doesn’t really do a good job of explaining what it considers the “internal extension caller ID”, and what it uses to capture the “Called number ID.”  As a result, you keep seeing EXT 204 coming up, which is my wireless phone, used to initiate the call.    Any suggestions on what to change so that the Outbound called number appears in the file name?

D.
0
 
LVL 36

Expert Comment

by:grblades
ID: 16490017
Can you post what [macro-record-enable] contained before you changed it.
At the moment there appears to be two variables being passed to it which are never used so it looks like you have changed it.

Looking at [macro-dialout-trunk] you have the line
exten => s,4,Macro(record-enable,${CALLERID(number)},OUT)
This passed two variables to the macro. One is the source extension callerid number and the other is the word 'OUT'.
You could change the line to
exten => s,4,Macro(record-enable,${ARG2},OUT)
and this will replace the source extension with the nmber dialed. Then just change the record-enable macro to change the rest of the filename as you wish.

For what you want to do asterisk@home is not really the right solution. It is designed to be controlled from the web interface and everything done through it. If you need more advanced features you should ideally install Asterisk on a normal linux machine and set it up yourself. That way you wont have to try and understand all the customisations @home have added which makes the dialplan far more complicated.
0
 

Author Comment

by:dholingw
ID: 16493189
I never changed anything in [macro-record-enable] .  

> You could change the line to
> exten => s,4,Macro(record-enable,${ARG2},OUT)

Unfortunately, that just breaks it, in that now no .wav is created when you place an outbound call ):

As for the vanilla version of Asterisk, that’s what I originally had.  The problem however, is that it’s so crippled right out of the box, even attempting to get something as simple as MOH to work could take days or weeks.  I figured AMP would provide some help (early in the game) to get used to the way Asterisk works, but sadly, it often makes a bigger mess of things.  I understand it’s supposed to dummy down the basic tasks, but yeah you’re right… Trying doing any real customizing just result in an endless slew of headaches.

D.    
0
 

Author Comment

by:dholingw
ID: 16494091
Hey, this simple little snippet seems to work ok.  

[macro-record-enable]
exten => s,1,SetVar(CALLFILENAME=${EXTEN:1}-${TIMESTAMP})
exten => s,2,Monitor(wav,${CALLFILENAME},m)

The hell with all the Macro crap, why don’t we work with this?  The only thing missing is the Outbound Phone number in the filename.  Other than that, it works perfectly.  As I said, ARG2 doesn’t seem to do a whole lot, so what else is could it be?  Man.. I’ve hacked Postfix, Sendmail, Procmail, and many more, but have NEVER experienced the bizarre types of problems I’m having here.  I mean… How hard can it be to capture the outbound number, then place it into a filename?   Anyhow, hopefully we can find the magic statement.  

Thanks,

D.  
0
 

Author Comment

by:dholingw
ID: 16495024
Got it working...

Check out what I added --see lines 4 and 5.  

[macro-dialout-trunk]
exten => s,1,GotoIf($["${ARG3}" = ""]?3:2)      ; arg3 is pattern password
exten => s,2,Authenticate(${ARG3})
exten => s,3,Macro(user-callerid)
exten => s,4,SetVar(CALLFILENAME=${ARG2}@${TIMESTAMP})
exten => s,5,Monitor(wav,/var/spool/asterisk/monitor/outbound/${CALLFILENAME},mb)
exten => s,6,Macro(outbound-callerid,${ARG1})
exten => s,7,Set(GROUP()=OUT_${ARG1})
exten => s,8,GotoIf($[ ${GROUP_COUNT()} > ${OUTMAXCHANS_${ARG1}} ]?108)
; if we've used up the max channels, continue at (n+101)
exten => s,9,Set(DIAL_NUMBER=${ARG2})
exten => s,10,Set(DIAL_TRUNK=${ARG1})
exten => s,11,AGI(fixlocalprefix) ; this sets DIAL_NUMBER to the proper dial string for this trunk
exten => s,12,Set(OUTNUM=${OUTPREFIX_${ARG1}}${DIAL_NUMBER})  ; OUTNUM is the final dial number
exten => s,13,Set(custom=${CUT(OUT_${ARG1},:,1)})  ; Custom trunks are prefixed with "AMP:"
exten => s,14,GotoIf($["${custom}" = "AMP"]?16)
exten => s,15,Dial(${OUT_${ARG1}}/${OUTNUM}|120|W)  ; Regular Trunk Dial, allow recording.
exten => s,16,Goto(s-${DIALSTATUS},1)

I also dumped the Macro Recording context.  This seems to work well.  I haven’t done much testing with it, but do you think it could mess anything else up?

Thanks,

D.


0
 
LVL 36

Expert Comment

by:grblades
ID: 16495650
If it is basically working then I dont think removing the context will have any effect.

What type of phone line are you using for the outgoing calls (PRI, BRI, pots , voip etc...)?

I think there is some more to the [macro-dialout-trunk] section as the final command is a goto statement which jumps to a specific section depending on the result of the call.
0
 

Author Comment

by:dholingw
ID: 16498599
Yeah, I was just looking at that.  Potential problems could be s,14 and s.16, since everything been moved down 1-position.  S,14 points to a custom AMP thingy of some type, which this is probably harmless.   S,16 could be worrisome, as I don’t know when, or in what event it’s called from.  I did try a bunch of calls both inbound and out too all my extensions with no problems.  

I’m running the SPA3000, so that’d be analog I suppose.  

 Hey… One quick question:  In this statement, what is the difference between placing an m or mb on the end? In both cases, files sound the same, and are both merged as one at the end of a call.  

exten => s,5,Monitor(wav,/var/spool/asterisk/monitor/outbound/${CALLFILENAME},m)
exten => s,5,Monitor(wav,/var/spool/asterisk/monitor/outbound/${CALLFILENAME},mb)

Thanks,

D.
0
 
LVL 36

Accepted Solution

by:
grblades earned 2000 total points
ID: 16498853
The 'b' means dont start recording unless a call is bridged to another channel. Basically this means dont record if the call does not get through.

s,14 probably does not matter as it only matches if you are using a custom AMP channel (whatever that is).

s,16 jumps to a particular entry depending what the dial status is after the dial command finishes. This does not matter because there is nothing configured for it to jump to anyway!
Normally you would do this to indicate a busy tony if the remote end indicates the line was busy etc...
This is what I do for making a call out of a PRI (E1/T1) interface :-

exten => _90[1-9].,5,Dial(ZAP/g1/${EXTEN:1},60,Tr)
exten => _90[1-9].,6,GotoIf($[ "${DIALSTATUS}" = "BUSY" ]?20)
exten => _90[1-9].,7,GotoIf($[ "${DIALSTATUS}" = "CONGESTION" ]?30)
exten => _90[1-9].,8,GotoIf($[ "${DIALSTATUS}" = "CHANUNAVAIL" ]?30)
exten => _90[1-9].,9,GotoIf($[ "${HANGUPCAUSE}" = "28" ]?40)
exten => _90[1-9].,10,GotoIf($[ "${HANGUPCAUSE}" = "1" ]?50)
exten => _90[1-9].,11,Hangup
exten => _90[1-9].,20,Busy
exten => _90[1-9].,30,Congestion
exten => _90[1-9].,40,Answer
exten => _90[1-9].,41,Wait(1)
exten => _90[1-9].,42,Playback(that-is-not-rec-phn-num)
exten => _90[1-9].,43,Hangup
exten => _90[1-9].,50,Answer
exten => _90[1-9].,51,Wait(1)
exten => _90[1-9].,52,Playback(discon-or-out-of-service)
exten => _90[1-9].,53,Hangup

This gives the correct indication to the end phone if the destination number is busy or there is general congestion. In addition I am also matching some of the PRI ISDN return codes to detect specific errors (number not valid and number disconnected) and playing a specific recorded message in these cases.
0
 

Author Comment

by:dholingw
ID: 16499342
Appreciate the help grblades…  

PRI.. Man, I could only dream of doing an install like that.  Give me another few months and I may be ready.  

Asterisk is a truly revolutionary, but beware…  As powerful as open source is, and all the wonderful contributions to such projects, a slew of growing pains can emerge.  That dial context we were working on has changed unteen times.  I was looking at early versions of Asterisk, and it almost looks as if 2.8 is actually missing stuff –same with the Record-Enable context –so it’s no wonder you were asking me if I changed the original record-enable context.  

Regardless… That feature still sits in a broken state, unless you modify it like we did.  Documentation on the project is so so.  Most of its donated, which is generally based on someone’s personal experience, but in many cases, there’s no official documentation on the feature.     To further confuse this, many of the documents on Wiki are posted without a date, or the VERSION that the example is relevant to.   When you combine this with rate of newly released versions, AND the radical changes to the code in many cases, trying to make any sense of Asterisk can be a full time job in itself.   New release?  Ok... Get ready to relearn Asterisk all over again :-)  

AMP is a great addition, but as typical with these projects, they’re pushing it ahead far faster than they can fix the things they break, or that just plain don’t work properly.  Record-Enable being one example.   Asterisk has unlimited potential, but could benefit from a dedicated group, which manages the rate that new features are added, in addition to providing UP TO DATE documentation on WHAT they’ve added, and what they’ve REMOVED in some cases.   Not doing so, just discourages many from trying out a new version until many months later, which in turn, does not help the progress of the broader based project.  

This COULD be a growing opportunity for Experts Exchange, since most people are using Asterisk for mission critical applications, and need help, like now!  

Thanks again!  
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although VoiceOver IP has been around for a while, internet connections have only recently become fast enough to provide good call quality. Now, VoIP has become a real option for businesses looking at ways to improve their business model. In this ar…
Hey there Heard about jingle, the add on for XMPP that enables point to point audio between two XMPP clients. No server config necessary. Actually quite a cool feature. However, how good is it if you can not use those voice capabilities to do a P…
Integration Management Part 2
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question