How to Integrate asterisk with legacy PBX via E1

Topic: Asterisk Integrate with the Legacy PBX via E1 Tunk

    Step by step guide to integrate the Asterisk IPPBX with Legacy PBX using E1 trunk. If you are still using old Legacy EPBX or PBX and looking to interconnect with Asterisk to leverage the asterisk features like call recording , conference , Inter office calls through your internet or LAN connectivity then this article is for your.

asterisk interconnect to EPBX

What is Asterisk and EPBX?
Asterisk is a Open source Communication software , You can use Asterisk to build communications applications, things like business phone systems (also known as IP PBXs), call distributors, VoIP gateways and conference bridges.
EPABX stands for Electronic Private Automatic Branch Exchange which is a private telephone network used by the organizations and the companies for various types of communication, either between the employees or outside the clients.

Asterisk with Coral EPABX

This is my personal experience in integrating Asterisk with Coral epabx via E1 trunking, The major purpose of integration is to record all the calls dialed from EPBX ,also setup a small call center using vicidial using the Phones connected to the EPBX ,that is Analog phones.

Setpup overview.
1. I have Server with Asterisk installed with Dahdi and vicidial for Caller center purpose.
2. Digium Two port card used to connect E1 Line from Telco and Interconnect with EPBX
3. E1 cable Crimped with Proper Color coding

Steps 1: Dahdi Configuration

Once asterisk installed you need to configure the E1 cards to receive and make calls from the service provider
in this guide i used port 1 for the service provider and port2 for the epabx connection.
vi /etc/asterisk/chan_dahdi.conf or dahdi-channels.conf

; Span 1: TE2/0/1 "T2XXP (PCI) Card 0 Span 1"
context=from-pstn ; context to handle the calls from the PRI line
switchtype = euroisdn
signalling = pri_cpe
channel => 1-15,17-31
context = default
group = 63

; Span 2: TE2/0/2 "T2XXP (PCI) Card 0 Span 2"
context=from-epabx ; context to receive the calls from the EPABX
switchtype = euroisdn
signalling = pri_net ; very important if you use a EPABX this to be used.
channel => 32-46,48-62
context = default
group = 63

Now save and close the file.

Step2 : Asterisk Dialplan To make and receive calls

    Next we need to create a Asterisk Dialplan to make and receive calls from Telco as well from the EPBX. using vi or nano editor edit the file named extensions.conf under /etc/asterisk folder.
vi /etc/asterisk/extensions.conf
Under Globals Context enter the Trunk variables as shown below


We have grouped the Port 1 of E1 as g0 to connect to Telco and Port 2 as g1 to connect to EPBX, Each group consumes 30 channels each. 

Next we  need the dialplan to use thes channels groups to dial in an dout.
in my case the epabx needs DID to reach the extension, and my provider sends last three digits of the DID as DID number .

Edit the extensions.conf file and add the below dialplan under default context.
; dialplan to dial the outside numbers (mobile or landline , prefix is 9 and number above 6 digits)
exten => _9XXXXXX.,1,Dial(${TRUNKPRI}/${EXTEN:1},,tTo)
exten => _9XXXXXX.,2,Hangup()
; dialplan to dial the epabx extensions - in my case epabx extensions is 3 digits (400 to 499)
exten => _4XX,1,Dial(${TRUNKPBX}/${EXTEN},,TtoR)
exten => _4XX,2,Hangup()
[from-pstn] ; context to receive incoming calls from the Telco
; dialplan to route the incomming calls from the service provider
; my provider send last 3 digits from my DID ie: my did is 4004400 so he sends 400 , 401 ...

exten => _XXX,1,Dial(SIP/${EXTEN}) ; rings my asteirsk sip extension which matches the 3 Digits.
exten => _XXX,2,Hangup()
; if you want to ring the EPABX extension then use the below dialplan
exten => _XXX,1,Dial(${TRUNKPBX}/${EXTEN},,TtoR)
exten => _XXX,2,Hangup()

Step 3: Dialplan to Receive call from EPBX

    Now we need to write one more dialplan to accept call from EPBX and bridge to Telco or Asterisk extensions. Add the below dialplan in the extensions.conf at the last line. Here I used to Separate the calls based on the length and send to asterisk extensions or Landline or mobile number by adding 0 as prefix.

 ; inbound cotext to handle the incomming from the epabx as mentioned in dahdi-channels.conf
exten => s,1,Answer()
exten => s,n(start),Read(PHONE,Ringneww,14,,2,3)
exten => s,n,GotoIf($[${LEN(${PHONE})} = 4]?asterisk)
exten => s,n,GotoIf($[${LEN(${PHONE})} < 8]?landline)
exten => s,n,GotoIf($[${LEN(${PHONE})} > 8]?mobile)
exten => s,n(end),Playback(invalid)
exten => s,n(try),Goto(start)
exten => s,n(asterisk),Goto(asterisk,${PHONE},1)
exten => s,n(landline),Goto(landline,${PHONE},1)
exten => s,n(mobile),Goto(mobile,${PHONE},1)
Dialplan to handle invalid number
exten => i,1,Playback(invalid)
exten => i,n,Hangup()
Dialplan to handle Timeout on Digits received from PBX
exten => t,1,Playback(unavailable)
exten => t,n,Hangup
exten => _XXXX,1,Dial(SIP/${EXTEN:1}) ; discard first digit as my asterisk is a 3digit extension.
exten => _XXXX,2,Hangup
exten => _X.,1,Dial(${TRUNKPRI}/${EXTEN},,tToR)
exten => _X.,2,Hangup
exten => _X.,1,Dial(${TRUNKPRI}/0${EXTEN},,tToR) ; to dial mobile sometimes need zero prefix
exten => _X.,2,Hangup


    Hope this article is helpful in interconnecting your legacy EPBX with asterisk IPPBX using E1 or T1 Trunking. For professional support reach me on skype or telegram: striker24x7 

  • Ajit Kumar
    Ajit Kumar April 4, 2022 at 11:36 AM

    Integrating Asterisk with Tranditional pbx ie: epabx or leagacy pbx using E1 trunking

Add Comment
comment url