2

I always get what seems the most head-scratching configurations to do on Asterisk.

Company has an asterisk server connected direct to SIP trunks and all work fine. Been asked to introduce call recording to inbound and outbound calls automatically after them trialling the automixmon (*3) command.

Their requirements are simple, only the MD and sales manager will have access to the calls, everything's internal so just getting dumped into the /var/spool/asterisk/monitor folder and a web server with authentication allows them to view the folder - when they're happy we'll clean this bit up.

I've got the outbound calls doing what we want with this (we use AEL) so the following snippet is triggered on dialling out from any extension.

  _9. => {
    Monitor(wav,${STRFTIME(${EPOCH},,%Y%m%d-%H:%M:%S)}-OUT-${CALLERID(num)}-${EXTEN:${ABSORB}},m);
    Dial(SIP/${EXTEN:${ABSORB}}@MAINTRUNK,90,X);
  };

ABSORB is a global variable which is mostly just set to 1 so that the 9 is not passed to the Dial() application.

The inbound calls are a bit trickier as the incoming calls go through this:

Dial(SIP/2000&SIP/2001&SIP/2002&SIP/2003&SIP/2004&SIP/2005,35,Tt);

So for now i've just set it up like this:

Monitor(wav,${STRFTIME(${EPOCH},,%Y%m%d-%H:%M:%S)}-IN-${CALLERID(num)},m);
Dial(SIP/2000&SIP/2001&SIP/2002&SIP/2003&SIP/2004&SIP/2005,35,Tt);

Which at least gets a file with a date/time the "IN" state and the incoming caller ID.

What the MD wants is that the file gets tagged with the extension that actually answered the call.

Is there any way to say put a placeholder in the filename like 'XXXX' and then use MONITOR_EXEC to get to a shell and rename the file after the call hangs up by replacing the XXXX with the last connected channel?

I realise it won't take transferred calls into account.

I can't see a way to determine the active extension for the call as I have to enable monitoring just before the dial command.

any suggestions?

miken32
  • 42,008
  • 16
  • 111
  • 154
JamesB
  • 499
  • 8
  • 23

1 Answers1

2

My suggestion in overcoming the problem is to make control variable, MonitorIncoming for exaple, and then set it first before Monitor is called:

MonitorIncoming=${STRFTIME(${EPOCH},,%Y%m%d-%H:%M:%S)}-IN-${CALLERID(num)};

Then do the rest

Monitor(wav,${MonitorIncoming},m);
Dial(SIP/2000&SIP/2001&SIP/2002&SIP/2003&SIP/2004&SIP/2005,35,gTt);

*with g flag to let call continue in dialplan, and then just do something like(before the call leaves all dialplans):

if(${LEN(${MonitorIncoming})}>0)
     System(mv /var/spool/asterisk/monitor/${MonitorIncoming} /var/spool/asterisk/monitor/${MonitorIncoming}-${${CDR(dstchannel)}:4:8});

*I haven't tested this, maybe you need to assign ${CDR(dstchannel)} to variable first and then :4:8. :) Or you can write a simple shell script and call it with System() and pass it ${CDR(dstchannel)}
Hope this helped,
Mirko

mirkobrankovic
  • 2,389
  • 1
  • 21
  • 24
  • I *always* forget about the 'g' option! I'll give this a try at the weekend on my own server before unleashing it on the client. – JamesB Jun 21 '13 at 09:07
  • Sorry I haven't had time to test this yet, had another job landed on me urgently, will be doing this shortly. – JamesB Jul 04 '13 at 16:09