Alerting on International (or special) Calls

Hi,

We have International calling enabled on PSTN as a couple execs have satellite phones on their boat. We only want a few people to have this capability. Those that get the ability to call international are matched in my main outbound route with patterns. Below I detail the changes needed to extensions_custom.conf, the adding of an AGI script, adding a trunk and then modifying outbound routes.

I began by adding a trunk called “International Trap” and left everything as the default except the Custom Dial String:

Local/[email protected]/n

I then added an AGI to generate the email to me. There are many ways to do this. I use perl in this example:

#!/usr/bin/perl -w
$|=1;
########################

peter 26 Dec 2012

########################

use Mail::Sendmail;

my $targetnum = $ARGV[0];
my $originnum = $ARGV[1];
my $originname = $ARGV[2];

my $from = ‘[email protected]’;
my $rcpt = ‘[email protected]’;;
my $cc = ‘’;
my $body = ‘’;
my $subject = ‘’;

my %AGI;
while() {
chomp;
last unless length($);
if (/^agi
(\w+):\s+(.*)$/) {
$AGI{$1} = $2;
}
}

$subject = “International Call to $targetnum from $originnum $originname”;
$body = ‘Who you gonna call?’;
$body .= “.\n\n\n”;

sendmail(From=>$from, Subject=>$subject, To=>$rcpt, Cc=>$cc, Message=>$body)

This AGI script got saved to the path /var/lib/asterisk/agi-bin/internationaltrap.agi and be sure to (chmod it to 755!)

Now we need to tie the context noted in the Custom Dial String to this AGI. Edit extensions_custom.conf and add this:

[internationaltrap-custom]
exten => _X.,1,NoOp(Trapping International Call from ${CALLERID(num)} to ${EXTEN})
exten => _X.,n,AGI(internationaltrap.agi,${EXTEN},${CALLERID(num)},${CALLERID(name)})
exten => _X.,n,Goto(app-blackhole,ring,1)

That will give the caller infinite ringback(*) after sending the email.

Next we have to define which callers are allowed to call Internationally. We do this by matching all their calls explicity in our main outbound route. In our case we use 9+ dialing and we have a 9_outside outbound route. Entries exist for each caller who is permitted to call international For the CFO (ext: 4315, 5552224315) the patterns look like:

( ) + 9 | [ . / 4315 ]
( ) + 9 | [ . / 5552224315 ]

Listed after my 9_outside route, I have added a route, named it “International,” which then matches these patterns:

( ) + 9 | [011. / ]
( ) + 9 | [011. / ]
( ) + 91 | [011. / ]

Then the Trunk Sequence for Matched Routes has selected the trunk “InternationalTrap” as the only route. Submit your changes and Apply the configuration.

peter

    • We recently had a new C-level executive hired. He was attempting to call a number in India. I received the trap email and called him asking if his international call was an error or intentional. He noted it was intentional. I said that I’m adding him to have international calling and that his call work go through after I had applied the change.

It was a “positive monitoring” experience for the new executive who saw my pro-active call in a very good way.

thanks