Sound Card Paging

I was able to make all our Polycom phones to be paged all together (global paging) but in my configuration which was found at voip-info.com everything works great but the problem is when the receptionist ending the announcement she have to press the # sign or the extensions will not hang up.

in my extensions_custom.conf

exten => 999,1,AGI,allpage.agi
exten => 999,2,MeetMe(999,dtqp)
exten => 999,3,Playback(beep)
exten => 999,4,MeetMeAdmin(999,K)
exten => 999,4,Hangup

[all-page]
exten => s,1,AbsoluteTimeout(10)
exten => s,2,MeetMe(999,dmq)
exten => s,3,Hangup
exten => t,1,Hangup
exten => T,1,Hangup

i could use the AbsoluteTimeout() insted of the kick option but the problem is sometimes the paging take more than 30 seconds or more because it is used at school.

also we are using the sound card for paging as well but in this case we have to dial another number like 9999

exten => 9999,1,Dial(CONSOLE/dsp,20,A(beep))
exten => 9999,2,Hangup

my questions now are:
1-is there any option to hangup all extensions automatically after paging?
2-can the extensions and external speaker through the sound card be paged all together when dialing 999?
please help , any info will be appreciated, i’m including the allpage.agi file which i use for paging here .

#!/usr/bin/perl
if (eval “require Net::Telnet;”) {
use Net::Telnet;
} else {
print “VERBOSE “Net::Telnet NOT INSTALLED - this is required” 0\n”;
exit 0;
}

You need to configure this: Your manager API username and password. This

is the information from /etc/asterisk/manager.conf. You need something like

this in it:

[admin]

secret = amp111

deny=0.0.0.0/0.0.0.0

permit=127.0.0.0/255.0.0.0

read = system,call,log,verbose,command,agent,user

write = system,call,log,verbose,command,agent,user

IF that’s what you have in your conf file, this is what you should have here:

my $mgruser = “admin”;
my $mgrpass = “amp111”;
my $mgrport = 5038;

If you’re using a SNOM they need a ‘sip:ip.add.re.ss’ added to the Call-Info field,

with the IP address of the registrar. Most other phones will silently ignore this,

but if you have trouble, you may need to fiddle with this line. Change the IP Address

to be that of your Asterisk Server.

my $callinfo = ‘Call-Info: sip:192.168.1.1; answer-after=0’;

This is for Polycom phones - see

voip-info.org/tiki-index.php … wer+config

my $alertinfo = ‘Ring Answer’;

That’s it. Nothing else should need to be changed

Some variables we use later…

my @tocall;
my %useref;

Get all SIP channels:

my @allsip = asterisk -rx "sip show peers";

Get all that are in use:

my @inuse = asterisk -rx "sip show channels";

Strip off carrige returns and take off the top line

chomp @allsip;
chomp @inuse;
shift @allsip;
shift @inuse;

First, we want to get the phones that are in use. We need the second field

of every line.

while (my $line = shift @inuse) {
my @tmparr = split(/\s+/,$line);

The second last, or possibly last, line says ‘n active SIP channel(s)’

goto endinuse if ($tmparr[1] eq “active”);
print “VERBOSE “Found extension $tmparr[1] in use.” 1\n”;
$useref{$tmparr[1]} = “In Use”;
}
endinuse:

We only want the first column, and, we only want the first part before the

slash

while (my $line = shift @allsip) {

This may break if there’s more than one / in a line. There shouldn’t.

$line =~ /(.+)/.+/;

Sanity check. This may be a peer for outgoing calls, rather than an

extension. Basically, if it’s 5 numbers or less, it’s an extension.

my $result = $1;

If your dialplan is different, sucks to be you. Change this regexp to

match your dialplans and EXCLUDE your SIP trunks.

if ($result =~ /^\d{1,5}$/) {
if (defined $useref{$result}) {
print “VERBOSE “NOT Adding extension $result to call list” 2\n”;
} else {
print “VERBOSE “Adding extension $result to call list” 1\n”;
push @tocall, $result;
}
}
}

If you don’t want any intelligence, you can just delete all the logic above

here, and specify the SIP extensions to call here. Also useful for debugging.

#@tocall = (303, 301);

Now, we have an array (@tocall) with all valid SIP extensions.

while (my $sipxtn = shift @tocall) {
print “VERBOSE “Doing $sipxtn” 0\n”;

Open connection to AGI

my $tn = new Net::Telnet ( Port => $mgrport,
Prompt => ‘/.*[$%#>] $/’,
Output_record_separator => ‘’,
Input_Log=> “/tmp/input.log”,
Output_Log=> “/tmp/output.log”,
Errmode => ‘return’, );

$tn->open(“127.0.0.1”);
$tn->waitfor(’/0\n$/’);
$tn->print(“Action: Login\n”);
$tn->print(“Username: $mgruser\n”);
$tn->print(“Secret: $mgrpass\n”);
$tn->print(“Events: off\n\n”);
my ($pm, $m) = $tn->waitfor(’/Authentication (.+)\n\n/’);
if ($m =~ /Authentication failed/) {
print “VERBOSE “Incorrect MGRUSER or MGRPASS - unable to connect to manager interface” 0\n”;
exit;
}
$tn->print(“Action: Originate\nChannel: SIP/$sipxtn\nContext: all-page\nPriority: 1\n”);
$tn->print(“Variable: SIPADDHEADER=”$callinfo"\n");
$tn->print(“Variable: ALERT_INFO=”$alertinfo"\n");
$tn->print(“Extension: s\nCallerID: System Page\n\n”);
$tn->print(“Action: Logoff\n\n”);
$tn->close;
}