Thursday, 3 September 2015

Asterisk voicemail for Avaya over H.323

If you want to replace your old intuity / audix by something more powerful it’s time to move to Asterisk and use its voicemail solution. In case you only have H.323 protocol activated on your Avaya  then no choice to follow steps below, which will be much more easier with SIP.

I'm using this voicemail for several years now and doesn't have any issue, I'm handling thousand calls with it on different Asterisk servers from different Avaya.

Install pre-requirement prior getting voicemail working


cpan install
cpan install YAML
cpan install threads
cpan install threads::shared
cpan install DBI
cpan install Error
cpan install POSIX
cpan install Log::Dispatch
cpan install Log::Dispatch::File
cpan install File::Spec
cpan install Date::Format
cpan install Net::SMTP
cpan install Asterisk::AGI
cpan install
DBD::SQLite


Create Sqlite database
cd /var/lib/asterisk/agi-bin/
sqlite3 auderix.db

Now you get a shell , you should create table
CREATE TABLE auderix (callednum TEXT,callernum TEXT unique,callername TEXT);
.exit

Create init.d service

cd /etc/init.d/
vi auderix
and copy and paste content below

#!/bin/sh
# Source function library.
prog="Auderix "

start() {
        echo "Starting $prog "
        # start daemon
        /usr/bin/perl /usr/local/bin/auderix-analyzer &> /var/log/auderix.log &
}

stop() {
        echo "Stopping $prog"
        PID=`cat /var/run/auderix-tshark.pid`
        kill -9 $PID
}
reload(){
        stop
        start
}

restart(){
        stop
        start
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        restart
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart}"
esac



once done do command below:

chmod a+x auderix
update-rc.d auderix defaults

vi /usr/local/bin/auderix-analyzer
and copy and paste text below:

#!/usr/bin/perl
use threads;
use threads::shared;
use DBI;
use Error qw(:try);
use POSIX qw(setsid);
use Log::Dispatch;
use Log::Dispatch::File;
use File::Spec;
use Date::Format;


use constant LOG_DIR    => '/var/log/auderix';
use constant LOG_FILE   => 'auderix-analyzer-access.log';
use constant EXCPT_FILE   => 'auderix-analyzer-exception.log';
use constant PIDDIR     => LOG_DIR;

my $log = new Log::Dispatch(
      callbacks => sub { my %h=@_; return Date::Format::time2str('%B %e %T', time)." ".$h{message}."\n"; });
$log->add( Log::Dispatch::File->new( name      => 'file1',
                                     min_level => 'warning',
                                     mode      => 'append',
                                     filename  => File::Spec->catfile(LOG_DIR, LOG_FILE),
                                   )
);
my $exception = new Log::Dispatch(
      callbacks => sub { my %h=@_; return Date::Format::time2str('%B %e %T', time)." ".$h{message}."\n"; });

$exception->add( Log::Dispatch::File->new( name      => 'file1',
                                     min_level => 'warning',
                                     mode      => 'append',
                                     filename  => File::Spec->catfile(LOG_DIR, EXCPT_FILE),
                                   )
);
$log->warning("Starting Processing:  ".time());
#
#open tshark in TSHARK file
#
my $tshark_pid = open (TSHARK,"tshark -l -T fields -e qsig.privateNumberDigits -e q931.calling_party_number.digits -e qsig.na.namePresentationAllowedSimple -Y qsig.privateNumberDigits -E occurrence=l -E separator=#|");

my $pidFile = '/var/run/auderix-tshark.pid';
open PIDFILE, ">$pidFile" or die "can't open $pidFile: $!\n";
print PIDFILE $tshark_pid;
close PIDFILE;

while () {
        my ($called,$caller,$name) = split("#",$_);
        # do whatever I want with the variables here ...
        my $thr = threads->new( \&processit,$called,$caller,$name)->detach();
}

sub processit {
        my ($lcalled,$lcaller,$lname) = @_; #local client
                $lname =~ s/'/''/g;
               
                $log->warning("Repondeur! Called : $lcalled, Caller : $lcaller, Name :$lname");
                $log->warning("INSERT OR REPLACE INTO auderix VALUES ('$lcalled', '$lcaller','''$lname''')");
        my $db = DBI->connect("dbi:SQLite:/var/lib/asterisk/agi-bin/auderix.db", "", "",{RaiseError => 1, AutoCommit => 1});
        $db->do("INSERT OR REPLACE INTO auderix VALUES ('$lcalled', '$lcaller','''$lname''')") or $exception->warning("ERROR a l'insertion de INSERT OR REPLACE INTO auderix VALUES ('$lcalled', '$lcaller','$lname')");;
}

mkdir /var/log/auderix
touch /var/log/auderix/auderix-analyzer-access.log
Now we start the service:
/etc/init.d/auderix start

vi /var/lib/asterisk/agi-bin/Auderixrequester.pl
chmod a+x Auderixrequester.pl
copy and paste inside content below:

#!/usr/bin/perl
use DBI;
use Error qw(:try);
use POSIX qw(setsid);
use Log::Dispatch;
use Log::Dispatch::File;
use File::Spec;
use Date::Format;
use Asterisk::AGI;

#my $caller = $ARGV[0];
$AGI = new Asterisk::AGI;
my %input = $AGI->ReadParse();
my $caller = $AGI->get_variable("CALLERID(num)");
my $db = DBI->connect("dbi:SQLite:/var/lib/asterisk/agi-bin/auderix.db", "", "",
{RaiseError => 1, AutoCommit => 1});
my $all = $db->selectall_arrayref("SELECT * FROM auderix where callernum='$caller'");
foreach my $row (@$all) {
        my ($callednum,$callernum,$calledname) = @$row;
        if (length($callernum) == 9 )
        {
                $callernum="0".$callernum;
        }
        elsif (length($callernum) > 9 )
        {
                $callernum="+".$callernum;
        }
        #$AGI->set_variable("callernum", $callernum);
        #$AGI->set_variable("callednum", $callednum);
        print "SET VARIABLE callernum \"$callernum\"\n";
        print "SET VARIABLE callednum \"$callednum\"\n";
        $db->do("DELETE FROM auderix where callednum='$callednum'");
}

Check that process auderix is running by using command below:
ps aux| grep tsh
you should see
tshark -l -T fields -e qsig.privateNumberDigits -e q931.calling_party_number.digits -e qsig.na.namePresentationAllowedSimple -Y qsig.privateNumberDigits -E occurrence l -E separator #

Into /etc/asterisk/ooh323.conf

[general]

 ;The port asterisk should listen for incoming H323 connections.
;Default - 1720
port=1720

;The dotted IP address asterisk should listen on for incoming H323
;connections
;Default - tries to find out local ip address on it's own
bindaddr=0.0.0.0   

;This parameter indicates whether channel driver should register with
;gatekeeper as a gateway or an endpoint.
;Default - no
;gateway=no

; See https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service for a description of these parameters.
tos_audio=ef           ; Sets TOS for RTP audio packets.
cos_audio=5            ; Sets 802.1p priority for RTP audio packets.

;Whether asterisk should use fast-start and tunneling for H323 connections.
;Default - yes
faststart=yes
;h245tunneling=yes

;Whether media wait for connect
;Default - No
;mediawaitforconnect=yes

;H323-ID to be used for asterisk server
;Default - Asterisk PBX
h323id=Anonyme
;e164=none

;CallerID to use for calls
;Default - Same as h323id
;callerid=asterisk

;Whether this asterisk server will use gatekeeper.
;Default - DISABLE
;gatekeeper = DISCOVER
;gatekeeper = a.b.c.d
gatekeeper = DISABLE

;Location for H323 log file
;Default - /var/log/asterisk/h323_log
;tracelevel=20
;logfile=/var/log/asterisk/h323_log

disallow=all
allow=alaw
canreinvite=no
dtmfmode=rfc2833
context=from-h323


[Avaya]
language = fr
country = fr
type=friend
host=10.147.9.64
port=1720
disallow=all
allow=alaw
canreinvite=no
;h245tunneling=yes
;dtmfmode=rfc2833
;dtmfmode=h245signal

As you can see incoming calls coming from ooh323 will goes to extensions.conf into from-h323 context, into this one we’ll call ParisOfficeVoicemail

[from-h323]
include => ParisOfficeVoicemail

Into /etc/asterisk/extensions.conf create a context that will be dialed by from-h323 context in my case:

[ParisOfficeVoicemail]

exten => 46750,1,Progress()
exten => 46750,n,Wait(1) ;//Important because Asterisk is faster than Tshark so it let time to perl script using tshark to write into database
exten => 46750,n,AGI(Auderixrequester.pl)
exten => 46750,n,NoOp(Callernum: ${callernum})
exten => 46750,n,NoOp(Callednum: ${callednum})
exten => 46750,n,Set(CHANNEL(language)=fr)
exten => 46750,n,Set(CALLERID(num)=${callernum})
exten => 46750,n,GotoIf($["${callednum}" = ""]?2000)
exten => 46750,n,GotoIf($["${CALLERID(num)}" = ""]?1000)
exten => 46750,n,VoiceMail(${callednum}@ParisOfficeVoiceMail,su)
exten => 46750,n,Hangup()
exten => 46750,1000,Set(CALLERID(name)="numéro masqué")
exten => 46750,n,VoiceMail(${callednum}@ParisOfficeVoiceMail,su)
exten => 46750,2000,PlayBack(vm-goodbye)
exten => 46750,n,system(/bin/echo "There is an issue with TSHARK please restart it" | /usr/bin/mail -s "TSHARK ISSUE" cyril.constantin@gmail.com)
exten => 46750,n,system(/etc/init.d/auderix restart)
exten => 46750,n,Hangup()



If you are using realtime for storing your voicemail config then create an entry into this mysql table where context would be “ParisOfficeVoicemail”

Mailbox : Your Avaya IP Phone number so in my case 40053
Fullname: Cyril CONSTANTIN
Attach:yes
Attachfmt:wav49
Deletevoicemail:yes
Sendvoicemail:no


Now on Avaya you should have created a route to go to Asterisk, in our case we have setup 46XXX






So it will use IP trunk 62, for more details on how to create IP trunk through H.323 to Asterisk check on my blog there is all details.





We create a hunt group that would be assigned to a coverage path, which will be attributed to IP Phone station.







We need to configure our voicemail config file which will generate an email with subject and voicemail in attachment vi /etc/asterisk/voicemail.conf:


[general]
format=wav49|gsm|wav
serveremail=asterisk@pt0asterisk01.lenumero.local
attach=no
skipms=3000
maxsilence=10
silencethreshold=128
maxlogins=3
charset=UTF-8
fromstring=Serveur Vocal
emailsubject = Vous avez un nouveau message d'une durée de ${VM_DUR} de la part du ${VM_CALLERID}
emailbody = ${VM_NAME}, \n\nVous avez reçu un nouveau message d'une durée de ${VM_DUR} \nde la part de ${VM_CALLERID}.\n\n\n\n\n\t\t\t\t\t\t\t\t\t\t Votre serveur vocal\n

attachfmt=wav49
endvoicemail=no
delete=no

I’ll let you configure your mail server properly.


Make a test call from another Avaya IP Phone to the Avaya phone using coverage path 100 you call should go to Asterisk and into the console you should see  something like below (use asterisk –r)


[Sep  3 10:44:28]     -- Executing [46750@from-h323:1] Wait("OOH323/AvayaSpecificDTMF-2270", "1") in new stack
[Sep  3 10:44:29]     -- Executing [46750@from-h323:2] AGI("OOH323/AvayaSpecificDTMF-2270", "Auderixrequester.pl") in new stack
[Sep  3 10:44:29]     -- Launched AGI Script /var/lib/asterisk/agi-bin/Auderixrequester.pl
[Sep  3 10:44:29] ERROR[18992][C-00000905]: utils.c:1393 ast_carefulwrite: write() returned error: Broken pipe
[Sep  3 10:44:29]     -- AGI Script Auderixrequester.pl completed, returning 0
[Sep  3 10:44:29]     -- Executing [46750@from-h323:3] NoOp("OOH323/AvayaSpecificDTMF-2270", "Callernum: 44241") in new stack
[Sep  3 10:44:29]     -- Executing [46750@from-h323:4] NoOp("OOH323/AvayaSpecificDTMF-2270", "Callednum: 40053") in new stack
[Sep  3 10:44:29]     -- Executing [46750@from-h323:5] Set("OOH323/AvayaSpecificDTMF-2270", "CHANNEL(language)=fr") in new stack
[Sep  3 10:44:29]     -- Executing [46750@from-h323:6] Set("OOH323/AvayaSpecificDTMF-2270", "CALLERID(num)=44241") in new stack
[Sep  3 10:44:29]     -- Executing [46750@from-h323:7] GotoIf("OOH323/AvayaSpecificDTMF-2270", "0?2000") in new stack
[Sep  3 10:44:29]     -- Executing [46750@from-h323:8] GotoIf("OOH323/AvayaSpecificDTMF-2270", "0?1000") in new stack
[Sep  3 10:44:29]     -- Executing [46750@from-h323:9] VoiceMail("OOH323/AvayaSpecificDTMF-2270", "40053@ParisOfficeVoiceMail,su") in new stack
[Sep  3 10:44:30] WARNING[18992][C-00000905]: app_voicemail.c:6350 leave_voicemail: No entry in voicemail config file for '40053'
[Sep  3 10:44:30]     -- Executing [46750@from-h323:10] Hangup("OOH323/AvayaSpecificDTMF-2270", "") in new stack
[Sep  3 10:44:30]   == Spawn extension (from-h323, 46750, 10) exited non-zero on 'OOH323/AvayaSpecificDTMF-2270'

pt0asterisk01*CLI>



In all case you will have maybe to change a little bit some piece regarding your needs regarding your country digit lengths because it was based on French digits length and international format so it require a little bit of knowledge to edit PERL or bash script if needed. Also this article has been done with using Debian 8 and tshark 1.12.1, I know that with older release of tshark it was need into auderix-analyzer to use a different command like below:

my $tshark_pid = open (TSHARK,"tshark -l -T fields -e qsig.privateNumberDigits -e q931.calling_party_number.digits -e qsig.na.namePresentationAllowedSimple -R qsig.privateNumberDigits -E separator=#|");


In all case prepare your routing on Avaya, set H323 trunk between Avaya and Asterisk then on linux shell  use tshark command manually to see what you get from Avaya normally you should get something under this format:
40053#44241#Cyril, CONSTANT

Called extension#Calling extension#Called Name

So you could move forward on setting all scripts above.

Enjoy it and don't hesitate to ask me question and I'll try to do my best to help you.

Best Regards

Monday, 4 July 2011

Asterisk 1.8.4.4 connected to Avaya with ooh323







Hi everybody,

As I know that lot of people are interested by connecting Avaya to Asterisk and I have already made a tutorial in 2008 about it, I have decided to renew it with latest version of Asterisk which is currently version 1.8.4.4

First we'll configure Avaya and then Asterisk.

You should check on Avaya the options below:
display system-parameters customer-options


Check on page 2 that you have some licence in front of "Maximum Administred H.323 Trunks".

Now do this command:
display system-parameters special-applications


on page 4 you should have option "H245 Support with other Vendors" to Yes

If you don't have one of the options above you can't move forward.

For H245 support with other vendors you can ask to Avaya or business partner to turn it on, generally they can do it for free.

Now we'll start the configuration on Avaya, you just need to know IP address of your future Asterisk server.

Please do command below and add a node-name which will be the name of your asterisk server that you have chosen and it's IP address:
change node-names ip


now we'll add signalling link (chose a number which is free:
add signaling-group 60
















Don't fill yet the field "Trunk Group for Channel Selection"
Regarding the Far-end Node-name chose the one that you have configured when you have added a node-name. The near-end Node name is a CLAN of your choice (in my case I have dedicated one but it's not mandatory).

You can also configure the Far-end Network Region by a number of your choice that we'll dedicate to Asterisk.

Now do command below:
add trunk 60

and configure the option like screenshot below:

















































Now you can go back on your signaling link and add the number of your trunk into the field "Trunk Group for Channel selection" and put in my example the value 60.


Now we'll confiure the network region:
change ip-network-region 5




















now the codec used:
change ip-codec-set 5














Now we'll configure how Avaya will call Asterisk let say that the extension on Asterisk will be 60000.

Do change uniform-dialplan 0 and add entry below:
60 5 0 aar n

then do:
change aar analysis 60 and add entry below:
60 5 5 60 lev2

then change route 60 and enter command below:
60 0

then change dialplan analysis and enter command below:
6 5 ext


Now on your asterisk server you'll install a Debian 6 version:

and do command below:

cd /usr/src/
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-1.8-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4-current.tar.gz
wget http://srtp.sourceforge.net/srtp-1.4.2.tgz

aptitude install libncurses5-dev linux-headers-$(uname -r) tar ssh libxml2-dev flex bison gcc g++ build-essential openssl libssl-dev libspeex-dev speex libspeexdsp-dev libldap-2.4-2 libldap2-dev festival-dev festival curl libcurl4-openssl-dev lua5.1 uw-mailutils libgsm1 libiksemel3 libogg0 libspeex1 libspeexdsp1 libvorbis0a libvorbisenc2 doxygen libnewt-dev libogg-dev libvorbis-dev liblua5.1-posix-dev libgsm1-dev screen flex bison openssl doxygen mlocate lynx tar nmap bzip2 unixODBC mysql-server mysql-client libmysqlclient-dev


tar -xvzf srtp-1.4.2.tgz
cd srtp-1.4.2
make
make runtest

cd ..

tar -xvzf libpri-1.4-current.tar.gz
cd libpri-1.4.11.5/
make
make install

cd ..


tar -xvzf dahdi-linux-complete-current.tar.gz
cd dahdi-linux-complete-2.4.1.2+2.4.1/
make all
make install
make config

cd ..

tar -xvzf asterisk-1.8-current.tar.gz

Now before compiling Asterisk we can add all librairies for Asterisk which will unlock lot of features is not mandatory, settings that I have provided above with aptitude command will be sufficient, it's up to you.

cd asterisk-1.8.4.4/contrib/scripts
./install_prereq
./get_mp3_source.sh

cd ../..

./configure --prefix=/usr
make menuselect
check into "add-ons" section the chan_ooh323 and uncheck into "Channel Drivers" the "chan_h323", after that you can select the option that you require, after that save and exit.

make
make install
make samples

cd /contrib/init.d/
cp rc.debian.asterisk /etc/init.d/
cd /etc/init.d/
mv rc.debian.asterisk asterisk
vi asterisk

and modify value by these values:
# Full path to asterisk binary
DAEMON=/usr/sbin/asterisk
ASTVARRUNDIR=/var/run/asterisk/
ASTETCDIR=/etc/asterisk/

:wq

/etc/init.d/asterisk restart

cd /etc/asterisk/
cp chan_ooh323.conf ooh323.conf

asterisk -r

module unload chan_ooh323.so
module load chan_ooh323.so and then it should find our file

exit

now we'll configure the file ooh323.conf I'll put you only the interesting features:

vi ooh323.conf

[general]
port=1720
bindaddr=0.0.0.0 ;(replace by IP address of your server but it's not mandatory)
context=h323
disallow=all
allow=alaw
allow=ulaw
canreinvite=no
dtmfmode=rfc2833

[Avaya]
type=friend
host=10.147.9.64 ;#CLAN IP address that you have used to configure your signaling link
port=1720
disallow=all
allow=alaw
canreinvite=no
dtmfmode=rfc2833


Now we'll see the extensions.conf file with the most important features:
[general]
[from-sip]
exten => _4XXXX,1,Dial(OOH323/${EXTEN}@Avaya)
;my Dial plan on Avaya is on 5 digit and start with digit 4
[h323]
include => sip-extensions

[sip-extensions]
;Number dialed from Avaya
exten => _600XX,1,Dial(SIP/${EXTEN})
exten => _600XX,n,Wait(25)
exten => _600XX,n,HangUp()


Now On sip.conf

[general]
language=fr
dtmfmode=rfc2833
allowguest=yes
srvlookup=no
qualify=yes
nat=yes
externip=10.147.113.243 ;Replace by your Asterisk server IP address
canreinvite=no
videosupport=yes
tcpenable=yes


[features](!)
type=friend
transport=tcp
secret=Ex€mpl$!
host=dynamic
disallow=all
allow=alaw
;allow=g722
allow=h263
allow=h264
context=from-sip
limitonpeers=yes
callcounter=yes
call-limit=100
;incominglimit=1
nat=yes
qualify=yes
canreinvite=no

[60000](features)
callerid="Cyril CONSTANTIN" <60000>
transport=tcp


asterisk -r
core restart now

asterisk -r
core show channeltypes

you should see OOH323 Objective Systems H323 channels Driver

Register to asterisk by using Jitsi and account 60000 and password Ex€mpl$!
Don't forget to change it after you have tried that it works.

On jitsi don't forget to configure port 5060 and TCP, I'll not show you how to use TLS but it's very simple.

When you are properly registered on Asterisk with jitsi make a call from Avaya to extension 60000 you should receive a call on Jitsi from "Anonymous", answer and check that you have both way audio.

Do it now from your Jitsi to Avaya extension that you have configured in extensions.conf in my case I'll call 40075 but it can be different in your case, answer call from Avaya phone and check that you have both way audio.

Once done we'll configure Avaya to send correctly the CALLID number instead of having "Anonymous"

Do change public-unknown-numbering 0 and add an entry:
5 4 60 emtpy 5


Now you are able to make and receive calls from both way.

I hope that it will help lot of people like it was the case for my previous article.

Best Regards.

Cyril CONSTANTIN

Tuesday, 27 May 2008

How to Activate the log on AES Server

Hi All,

You have probably met this problem when sometimes you get strange CTI issue and that you are aware about the issue some hours later, but the logs are already overwritted.

To activate the logs on AES Server version 3.1.1 (it will be the same for previous and next release normally):


Log in to AES server as root.

[sroot@is_che_aes1 sroot]# cd /opt/mvap/conf

[sroot@is_che_aes1 conf]# vi tracemask

Tracemask needs to be edited for the traces required by TSAPI. Therefore include following values:

TSAPI=0x3f
asailink =0x0001e00e


And then you need to save your change with the command below:
:wq!


Now is needed to restart the MVAP services

Root> service mvap restart

That will impact your service if you do that please be carefull to schedule this change and to stop your production or to switch to another CTI AES Server.

To see the logs which have been created you need one call generated on the MOS, so just make a CTI call.

Now we can view G3trace in TSAPI on AES-:

cd /opt/mvap/logs/TSAPI

G3trace will be named as -: g3trace-trace.out

I hope it will be usefull for everybody.

Regards.

Friday, 25 April 2008

HOWTO Connect Nokia E65 to Asterisk

Hi All,

This tutorial will be very usefull for some people who are looking to connect a Nokia E65 to Asterisk.

SIP Parameter

Name Mode : You need to define the name
Service Mode : IETF
Access Point : Your access point
Username : sip:userid@IP_address_asterisk_server
Compression : no
Register : Always active
Use security : Non


Proxy Parameter

Server address : sip :IP_address_asterisk_server
Domain : realm (default asterisk value)
Username : userid extension on Asterisk
Password : userpassword
Allow routing : yes
Type of transport : UDP
Port : 5060


Registrar Parameter

Server address registrar : sip :IP_address_asterisk_server
Domain : none
Username : userid extension on Asterisk
Password : none
Type of transport : UDP
Port : 5060


When everything is done, normally you will have a small icon (phone icon) on your E65 mobile phone

Let me know if you have a problem.


Best Regards.

Thursday, 24 April 2008

Automatic Script for CMS (Call Management System) for Avaya

Hi All,

Sometimes it's arrives that you need to have to change a big list of login name or delete lot of login manually, so I think taht the scripts below will be very interesting for the majority of the people, so in first we'll see how to have a script in order to modify a list of login name and if the login doesn't exist then it will be created:

1) CMS Script to change agent and/or add the agent if he doesn't exist:

The value below must be changed in order to work with your system:

SERVERNAME= IP ADDRESS OF YOUR CMS SERVER
Dictionary.ACD = This is the value of your ACD on CMS
OpenTextFile("C:\agents.txt", 1) = This is the path where the list of your agent will be stored, so you need to create a file agents.txt on your hard drive C:\























Copy the content below in a file with the extension below .acsup so for example the name of my file will be "Script to change or add an agent.acsup" so you just need to doble click on this file and CMS will be started then enter your password and the script will be started automatically:


'LANGUAGE=ENG
'SERVERNAME=xx.xx.xx.xx
Public Sub Main()

'Place a ";" separated file name agents.txt on the root of C drive
'This file needs to have the agent format: Cyril;1234 on every line
'This line will be read and split on the ";" and put in an array to add into CMS


l=0 'loop value for read loop
result=0 'Answer on adding
c=0 'counter for giving the messagebox

dim regel, a 'variabel for readline and for splitting on ";"
dim sString 'variable for information on adding data
dim NameArray(999) 'define array for agent name. All data is read into this from agents.txt
dim NumberArray(999) 'define array for agent number
dim fs, f 'define filesystem stuff for read
Dim agAdded
Dim agModif
Dim ress
cvsSrv.Dictionary.ACD = 3

'Reads file one line at a time into name and number array
'Place the textfile on the root of C drive

Set fs=CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile("C:\agents.txt", 1)

Dim ss


Do While f.AtEndOfStream <> True

'result = msgbox (regel, 1, "regel")
regel = f.ReadLine
a = split(regel,";")
NameArray(l) = a(0)
NumberArray(l) = a(1)
l=l+1
'regel = f.ReadLine
Loop 'keep reading in data until EOF hit.

'a = split(regel,";")
'NameArray(l) = a(0)
'NumberArray(l) = a(1)

f.Close 'close agents.txt file

Set f=Nothing 'clear f and fs
Set fs=Nothing

'Read all agents into string and display it in a messagebox

for c = 0 to l-1
sString = sString & NumberArray(c) & " - " & nameArray (c) & (Chr(13) & Chr(10))
next
result = msgbox (sString, 1, "Sure to Modify these Agents?")
if result = 1 then

sString = "" 'make string empty for next use

'Modify entries

b = cvsSrv.Dictionary.CreateOperation("Login Identifications",Op)
'b2 = cvsSrv.Dictionary.CreateOperation("Login Identifications",Op)
Op.Window.Top = 4490
Op.Window.Left = 4680
Op.Window.Width = 6000
Op.Window.Height = 2540


agAdded = 0
agModif = 0
for c = 0 to l-1

If b Then
Op.SetProperty "login_id", NumberArray(c)
Op.SetProperty "ag_name", NameArray(c)

On Error Resume Next

if b = Op.DoAction("Modify") then

agModif = agModif + 1
else
sString = sString & " " & NumberArray(c) & (Chr(13) & Chr(10))


b2 = Op.DoAction("Add")
if Not(b2) Then
result = msgbox (NameArray(c), 64, "failed adding user")
else
agAdded = agAdded + 1
End If
end if

End If

next


ress = "Agents Added " & agAdded & " Agents Modified " & agModif
result = msgbox (ress, 64, "Result")

' if sString <> "toto" then
'msgbox sString, 64, "Following Agents Already Exist"
'else
'msgbox "All Agents Modify", 64, "Operation Succesfull"
' end if

If Not cvsSrv.Interactive Then cvsSrv.ActiveTasks.Remove Op.TaskID
Set Op = Nothing

end if

end Sub




This is the code to delete automatically a list of agent:


'LANGUAGE=ENG
'SERVERNAME=xx.xx.xx.xx
Public Sub Main()

'Place a ";" separated file name agents.txt on the root of C drive
'This file needs to have the agent format: Cyril;1234 on every line
'This line will be read and split on the ";" and put in an array to delete in CMS


l=0 'loop value for read loop
result=0 'Answer on deleting
c=0 'counter for giving the messagebox

dim regel, a 'variable for readline and for splitting on ";"
dim sString 'variable for information on adding data
dim NameArray(999) 'define array for agent name. All data is read into this from agents.txt
dim NumberArray(999) 'define array for agent number
dim fs, f 'define filesystem stuff for read

cvsSrv.Dictionary.ACD = 3

'Reads file one line at a time into name and number array
'Place the textfile on the root of C drive

Set fs=CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile("C:\agents.txt", 1)

Do While f.AtEndOfStream <> True
regel = f.ReadLine
a = split(regel,";")
NameArray(l) = a(0)
NumberArray(l) = a(1)
l=l+1
Loop 'keep reading in data until EOF hit.

f.Close 'close agents.txt file

Set f=Nothing 'clear f and fs
Set fs=Nothing

'Read all agents into string and display it in a messagebox

for c = 0 to l-1
sString = sString & NumberArray(c) & " - " & nameArray (c) & (Chr(13) & Chr(10))
next
result = msgbox (sString, 1, "Sure to Delete these Agents?")
if result = 1 then

sString = "" 'make string empty for next use

'Delete entries

b = cvsSrv.Dictionary.CreateOperation("Login Identifications",Op)
Op.Window.Top = 4490
Op.Window.Left = 4680
Op.Window.Width = 6000
Op.Window.Height = 2540

for c = 0 to l-1

If b Then
Op.SetProperty "login_id", NumberArray(c)
Op.SetProperty "ag_name", NameArray(c)

On Error Resume Next

if b = Op.DoAction("Delete") then
else
sString = sString & NumberArray(c) & " - " & nameArray (c) & (Chr(13) & Chr(10))
end if

End If

next
if sString <> "" then
msgbox sString, 64, "Following Agents Not in System"
else
msgbox "All Agents Deleted", 64, "Operation Succesfull"
end if

If Not cvsSrv.Interactive Then cvsSrv.ActiveTasks.Remove Op.TaskID
Set Op = Nothing

end if

end Sub



Take care when you want to start your script if you have some different version language available on CMS it could try to start the wrong one so just start your english version log you on CMS and run the script.

If some french people need to have an adaptation I can also try to change my version to work with a French CMS Supervisor version.

I hope this tutorial could help some people!!

Monday, 21 April 2008

HOWTO Connect Avaya to Asterisk

Hi All,

I think that it could be nice to share my knowledge on this subject and help the others people to connect Asterisk to Avaya:

In first we need to add on Avaya a new node-name:

Make on Avaya "change node-names ip"

And attribute the name Sip_server for our example and also the IP address of your Asterisk server:


Create a new signaling group, you need to use a CLAN of your system and the node-name that you have created above, keep the fiedl "Trunk group for Channel Selection" empty, this field will be fill after creation of the Trunk.



After the creation of the signalling we can create the trunk, in my example I'll create the trunk 42 but you can use a different number:

Page 1 of the trunk:



Page 2 of the trunk:





Page 3 of the trunk:



Page 4 of the trunk:



Page 5 of the trunk:



Page 6 of the trunk:



Creation of the uniform dialplan:



AAR Table:























Route pattern:





Now the trunk has been created don't forget to go back the signalling group that you have created and add in the field "Trunk group for channels selection" the value of your trunk in my example I have created a trunk 42 so it will be the value 42 in the field.

Now on Avaya we are ready to connect on Asterisk so we need to configure Asterisk:

You just need to follow my example below:

In H323.conf

[general]
port = 1720
bindaddr = 10.148.20.26
progress_setup = 8
progress_alert = 8
faststart=yes

h245tunneling=yes
gatekeeper = DISABLE

;We need to conserve the main parameters to allow the h323 to call to the SIP phone
disallow=all
allow=alaw
dtmfmode=inband
context=internal ; name of your context


[Avaya]
type=friend
context=internal
host=10.147.9.64; IP Address of your CLAN
port=1720; port used to connect on CLAN it could be some others port regarding your configuration in signalling group.
disallow=all
allow=alaw
canreinvite=no
dtmfmode=inband




In extensions.conf

[general]
static=yes
autofallthrough=yes


[internal]
;My extension 59xxx
exten => 59000,1,Dial(SIP/59000)
exten => 59000,2,VoiceMail(59000@118218)
exten => 59000,3,PlayBack(vm-goodbye)
exten => 59000,4,Wait(2)
exten => 59000,5,HangUp()



exten => _7XXXXX,1,Dial(H323/${EXTEN}@Avaya); Avaya Extension
exten => _5XXXX,1,Dial(H323/${EXTEN}@Avaya); to call on SIP Extension
exten => _4XXXX,1,Dial(H323/${EXTEN}@Avaya); Your extension on Avaya
exten => _006XXXXXXXX,1,Dial(H323/${EXTEN}@Avaya); to call on mobile
exten => _00XXXXXXXXX,1,Dial(H323/${EXTEN}@Avaya); to call on National


In Sip.conf
[general]
context=internal
bindaddr=10.148.20.26; IP Address of your Asterisk
srvlookup=yes
videosupport=yes ; if you want activate video support
canreinvite=no

[59000]
type=friend
secret=XXXXXXXXXX ;your password
host=dynamic
dtmfmode=inband
disallow=all
allow=alaw
allow=h263 ; to use a video codec if needed
callerid="Cyril CONSTANTIN" <59000>
nat=yes

Do not forget to restart Asterisk when you have finished to configure the .conf files.


I hope that this tutorial will help lot of people, if you follow this tutorial it will be easy for everybody to interconnect the both system.

Tuesday, 8 April 2008

HOWTO Compil Asterisk 1.4.19 with H323

Hi All,

You are probably interesting to compile Asterisk with H323, after lot of test it has been successfully compiled but is not easy when you don't know Linux so if you follow this tutorial it will be easy for the majority of the people:


Installation of the package necessary on CentOS 5.1:
yum -y install ncurses ncurses-devel openssl openssl-devel zlib zlib-devel bison bison-devel glibc gcc kernel-devel flex


Installation of the package on Debian:

pt-get install libc6 libc6-dev libncurses5 libncurses5-dev libssl-dev openssl libssl0.9.8 flex m4 bison libpopt-dev libdv4-dev libpopt-dev zlib1g zlib1g-dev



Now you need to download the package for Asterisk from the folder /usr/src/:


mkdir -p /usr/src/Asterisk_and_H323
wget -P /usr/src/Asterisk_and_H323 http://www.voxgratia.org/releases/pwlib-v1_10_0-src-tar.gz
wget -P /usr/src/Asterisk_and_H323 http://www.voxgratia.org/releases/openh323-v1_18_0-src-tar.gz
wget -P /usr/src/Asterisk_and_H323 http://downloads.digium.com/pub/libpri/releases/libpri-1.4.3.tar.gz
wget -P /usr/src/Asterisk_and_H323 http://downloads.digium.com/pub/asterisk/releases/asterisk-1.4.19.tar.gz


Do not use another release more recent of OpenH323/Pwlib because the dependencies are not stable.

It can arrives sometimes that the compilation doesn't work due to a missing files /usr/include/linux/compiler.h, so it could be nice to create in all case the file below:

vi /usr/include/linux/compiler.h


Below the content of the compiler.h:


#ifndef __LINUX_COMPILER_H
#define __LINUX_COMPILER_H
#define likely(x) __builtin_expect((x),1)
#define unlikely(x) __builtin_expect((x),0)
#endif /* __LINUX_COMPILER_H */



Compilation de PWLib:


cd /usr/src/Asterisk_and_H323
tar -xvzf pwlib-v1_10_0-src-tar.gz
cd pwlib_v1_10_0/
./configure --prefix=/usr
make opt
make install
export PWLIBDIR=/usr/src/Asterisk_and_H323/pwlib_v1_10_0


Compilation of the library OpenH323:

cd /usr/src/Asterisk_and_H323
tar -xvzf openh323-v1_18_0-src-tar.gz
cd openh323_v1_18_0
./configure --prefix=/usr
make opt
make install
export OPENH323DIR=/usr/src/Asterisk_and_H323/openh323_v1_18_0


Compilation de Libpri:

cd /usr/src/Asterisk_and_H323
tar -xvzf libpri-1.4.3.tar.gz
cd libpri-1.4.3
make install


Compilation d'Asterisk:

You can observe that there is 2 times the make command, it permits to check if the compilation of H323 has been successfully done, if it is not the case please re-check the step above.

cd /usr/src/Asterisk_and_H323
tar -xvzf asterisk-1.4.19.tar.gz
cd asterisk-1.4.19/
./configure --prefix=/usr
make menuselect (The modification can damage the compilation)
make
make
make install
make samples
make config
asterisk


In case of failure:

- Check the version of the software used. I can certify that all version used on CentOS works correctly. Take care about "./configure --prefix=/usr".

To uninstall:
In the installation folder (/usr/src/Asterisk_and_H323/...): make uninstall et rm

Please find the French version of this HOWTO originally made by my colleague Etienne:

Compiler Asterisk avec H323