How to integrate Openfire XMPP chat server with Asterisk PBX server

After successfully installing the Asterisk PBX server and the Openfire XMPP Chat server, it is time to integrate the two so that our Chat server can be used in the VOIP infrastructure built by Asterisk.

  1. Installed Asterisk PBX server
  2. Installed Openfire XMPP server
  3. Asterisk and Openfire are networked so they can communicate successfully.
  4. Linux basics and file editing
  5. Compiled the res_xmpp.so and res_jabber.so Asterisk modules.

If you are interested in this tutorial but have not completed any installations, feel free to use the following tutorials:
Install Openfire XMPP chat server: Complete guide on how to install Openfire XMPP chat server on Centos 7

How to install Openfire XMPP chat server on Ubuntu 18.04 / Ubuntu 16.04

Asterisk PBX installation: step-by-step guide on how to install Asterisk PBX 13.x step by step on CentOS 7

We will follow the steps to complete the integration.
> After installing Asterisk and Openfire, start Openfire and log in to the web configuration interface. If you have Openfire installed on the host, use ip 127.0.0.1; if on a remote system or virtual machine, use the IP address of the Openfire server.

http://127.0.0.1:9090
http://your_ip_address:9090

> Log in with the username and password you configured during installation.
> In the “Menu” section, go to “Plugins” >> “Available Plugins” and search for plugins named “Asterisk-IM” and “SIP Phone Plugin”. Click the + (plus sign) in the upper right corner of the plugin name section to install the plugin.
If you can’t seem to find the above plugins under the “Available plugins” submenu, you can download the plugins manually and put them in the “Openfire plugin directory”.
Do the following on the Openfire XMPP server.

su -

Enter your root password and

cd /opt/openfire/plugins/
wget http://www.igniterealtime.org/projects/openfire/plugins/sip.jar
wget http://suse.mes.edu.cu/Utiles/Jabber/Openfire-3.8.x/Plugins/2013/asterisk-im.jar

In order for Openfire to recognize the added plugin, please restart with the following command

 service openfire restart

> After restarting Openfire, you should see the Asterisk-IM menu on the openfire dashboard menu. Click on it to configure.
> Under Asterisk-IM> General Settings, make sure the Asteris-IM plugin is enabled.
On the Configure Phone Manager, add the Asterisk context, my name is test. If a context is already configured in your Asterisk Server, add it here. If you don’t have any context, use “test” and we will add it later.

How to integrate Openfire XMPP chat server with Asterisk PBX server

> It’s time to add the Asterisk server. Just click on the “Add Server” option under General Settings. Then provide the following information server name: Alias ​​of Asterisk server. It can be any name server IP: Asterisk Server’s IP address Port: The connection port used to connect to Asterisk Server, the default value is 5038 Username: the username that will connect to the Asterisk Manager. Next, we add it to the Asterisk manager.conf file. Save the configuration. Password: The user password that will be used to connect to the Asterisk PBX server.
For my configuration, see the screenshot below.How to integrate Openfire XMPP chat server with Asterisk PBX server

Go to Asterisk Server and add the user you specified in the previous step to the /etc/asterisk/manager.conf file.

Start your Asterisk PBX server, then:

su -
nano /etc/asterisk/manager.conf

nano /etc/asterisk/manager.conf

Ensure that the general section has the following configuration options.

[general] 
enabled = yes 
webenabled = yes 
port = 5038; This is the Asterisk AMI Port number
httptimeout = 120
bindaddr = 0.0.0.0 
allowmultiplelogin = yes 
displayconnects = yes 
timestampevents = yes

Add the user and password you specified in step 5.

[openfire] 
secret =password-that-you'll-set-on-next-step
displayconnects = yes 
read = system, call, log, verbose, agent, user, config, DTMF,reporting
write = system, call, agent, user, config, comman, reporting

How to integrate Openfire XMPP chat server with Asterisk PBX server

Add users who will connect to Asterisk Server, go to Users and Groups, and add users. User name: openfire name: openfire password: openfire

How to integrate Openfire XMPP chat server with Asterisk PBX server

Restart the asterisk.

service asterisk restart

Either

/etc/init.d/asterisk reload

Let’s create a context “test” on Asterisk.

nano /etc/asterisk/extensions.conf

Go to the end of the file and add the following lines.

[test] 
exten => _XXX,1,Answer
exten => _XXX,n,No0p ( This-is-a-sample-context) 
exten => _XXX,n,Dial(SIP/${EXTEN},10,r)
exten => _XXX,n,Hangup

How to integrate Openfire XMPP chat server with Asterisk PBX server

_XXX: This is a pattern match that represents any three-digit extension. $ {EXTEN} is a variable that holds the dialed extension number.

> Add a SIP user to be mapped to an XMPP chat account.

 nano /etc/asterisk/sip.conf

Add the following line in the general section:

callevents = yes

Then add the following lines at the end of the file.

[101] ; Account name
context=test ; default context for incoming calls
type=friend ;Access type
secret=password ; a secure password for this device 
usernam=kim
nat=no ;Disabled NAT for LAN
bindport=5060 ; UDP port for Asterisk
disallow=all ;Disallow all Call Codecs
allow=ulaw
language=en
host=dynamic ;use DHCP to get ip address
qualify=yes 
allowguest=no ; disable unauthenticated calls
dtmfmode=auto ; accept touch-tones from the devices, negotiated automatically

[102] ; Account name
context=test ; default context for incoming calls
type=friend ; Access type
secret=password ; a secure password for this device 
username=val
nat=no ;Disabled NAT for LAN
bindport=5060 ; UDP port for Asterisk
disallow=all ;Disallow all Call Codecs
allow= ulaw
language=en
host=dynamic ; use DHCP to get ip address
qualify=yes 
allowguest=no ; disable unauthenticated calls
dtmfmode=auto ; accept touch-tones from the devices, negotiated automatically

How to integrate Openfire XMPP chat server with Asterisk PBX server

Now go back to Openfire and add users to map to the SIP account we added. You will configure the following: username: your username name: your full name email address: your email address

How to integrate Openfire XMPP chat server with Asterisk PBX server

> Under Asterisk-IM >> Phone Map >> Add User / Asterisk Phone Map, specify:

  • * Username: jose
  • * Equipment: SIP / 101
  • * Extension: 101
  • Caller ID: jose
  • Elementary school: yes

How to integrate Openfire XMPP chat server with Asterisk PBX server

Save the settings and you have successfully completed the configuration.
> Before we start sending messages to XMPP friends, we need to connect to an XMPP-enabled server. Add the following configuration to the xmpp.conf file.

 nano /etc/asterisk/xmpp.conf

plus:

[asterisk]
type=client
serverhost=192.168.1.105 ; ip addresss of XMPP server(Openfire)
[email protected] 
secret=openfire
priority=1
usetls=yes
port=5222
usesasl=yes
status=available 
statusmessage="Asterisk Server"
endtodialplan=yes
context=from_xmpp
keepalive=yes

> To install res_xmpp, we need the iksemel development library. If the OpenSSL development library is installed, res_xmpp will also use the library for secure connections. First, install iksemel and the OpenSSL library.
For Ubuntu and Debian based systems:

sudo apt-get install libiksemel-dev libssl-dev

For CentOS 7 and RedHat Bases:

sudo yum install iksemel-devel openssl-devel

Restart the Asterisk server and install res_xmpp as shown below. Install res_xmpp
After installing the dependencies, you need to run ./configure in the Asterisk source code and make menuselect. Then go to the Resource Module menu and make sure res_xmpp is enabled. After that, run make install to get the new module.

cd asterisk-source-directory
./configure
make menuselect

Then go to the Resource Module menu and make sure res_xmpp is enabled. After that, install it.

make install

test.

  • Test to confirm that the Sip user was successfully added to the asterisk
service asterisk restart
asterisk -rvvvvvv 
sip show peers

How to integrate Openfire XMPP chat server with Asterisk PBX server

  • Test on Asterisk CLI type to confirm that Asterisk and Openfire XMPP server are communicating:
manager reload
manager show connected

How to integrate Openfire XMPP chat server with Asterisk PBX server

You can now install Sparkweb, which is an open source, web-based IM client and Spark IM client optimized for businesses and organizations. You will be able to answer calls through the SIP account we added to Asterisk.
In the next tutorial, we will discuss how to use Zoiper and X-Lite softphone to send instant messages through Openfire XMPP server.
How to install Openfire and integrate it with Asterisk PBX server
How to integrate Openfire with Asterisk
Asterisk running on CentOS 7 server and Openfire on CentOS 7 server integration.
How to make a softphone; X-Lite and Zoiper use Openfire XMPP server to chat.

Ranch

Sidebar