After successfully Installing Asterisk PBX server and Installing Openfire XMPP Chat server, it’s time to integrate the two so that our Chat server can be used within the VOIP infrastructure build with Asterisk.

  1. Installed Asterisk PBX server
  2. Installed Openfire XMPP server
  3. Asterisk and Openfire networked so that both can communicate successfully. 
  4. Basic knowledge of Linux and files editing 
  5. Compiled and  Asterisk modules.

If you are interested in this tutorial and you haven’t done any installation, feel free to use the following tutorials:
Installation of Openfire XMPP Chat Server:
Complete guide on how Install Openfire XMPP chat server on Centos 7

How to Install Openfire XMPP chat server on Ubuntu 18.04 / Ubuntu16.04

Installation of Asterisk PBX:
How to install Asterisk PBX 13.x on CentOS 7 step by step guide

We’ll follow steps below to complete the integration.
> Once you’ve installed both Asterisk and Openfire, start Openfire and login to Web configuration interface. Use ip if you have Openfire installed on your host computer and ip address of Openfire server if it’s on a remote system or on a Virtual Machine.

> Login with the username and password you configured during installation.
> On the Menu section, go to Plugins >> “Available Plugins” and Search for plugins named “Asterisk-IM” and “SIP Phone Plugin”. Install the Plugins by clicking on the + (Plus sign) at the right corner of the plugin name section.
> If you can’t seem to find above plugins under “Available Plugins” sub-menu, you may download the plugins manually and put them inside “Openfire plugins directory”.
Do the following on Openfire XMPP server.

su -
Type your root password, then
cd /opt/openfire/plugins/

For Openfire to recognize added plugins, restart it using the command below

 service openfire restart

> Once you restart Openfire, you should see Asterisk-IM menu on openfire dashboard’s menu. Click on it to configure it.
> Under Asterisk-IM > General settings, make sure Asteris-IM plugin is enabled.
On “Configure Phone Manager”, add Asterisk Context, mine is named test.If you have context already configured in your Asterisk Server, add it here. In case you don’t have any context, use “test” as we’ll add it later.

> Now it’s time to add Asterisk Server. This is done by just clicking on “Add Server” option under General settings. Then provide the following information
Server Name: Alias name of your Asterisk Server. Can be any name
Server IP: Ip address of your Asterisk Server
Port: connection port used to connect to Asterisk Server, the default is 5038
Username: username that will connect to the asterisk manager. We’ll add it to Asterisk manager.conf file in the next step. Save the configurations.
Password: user password that will be used to connect to Asterisk PBX server.
See screenshot below for my configuration.

> Head over to Asterisk Server and add the user you specified on the previous step to /etc/asterisk/manager.conf file.

Start your Asterisk PBX server, then:

su -
nano /etc/asterisk/manager.conf


nano /etc/asterisk/manager.conf

Make sure the general section has the following configuration options.

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

Add the user you specified on step 5 and the password.

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

Add the user that will connect to Asterisk Server, go to users and Groups then add user.
Username: openfire
Name: openfire
Password: openfire

Restart Asterisk.

service asterisk restart


/etc/init.d/asterisk reload

> Let’s create the context “test” on Asterisk.

nano /etc/asterisk/extensions.conf

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

[pastacode lang=”bash” message=”” highlight=”” provider=”manual” manual=”%5Btest%5D%20%0Aexten%20%3D%3E%20_XXX%2C1%2CAnswer%0Aexten%20%3D%3E%20_XXX%2Cn%2CNo0p%20(%20This-is-a-sample-context)%20%0Aexten%20%3D%3E%20_XXX%2Cn%2CDial(SIP%2F%24%7BEXTEN%7D%2C10%2Cr)%0Aexten%20%3D%3E%20_XXX%2Cn%2CHangup”/]

_XXX: It is a pattern matching meaning any extension with three digits.
${EXTEN} is a variable holding extension number dialed.

> Add SIP users to be mapped to XMPP chat accounts.

 nano /etc/asterisk/sip.conf

On general section add the line:

callevents = yes

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

[pastacode lang=”bash” message=”” highlight=”” provider=”manual” manual=”%5B101%5D%20%3B%20Account%20name%0Acontext%3Dtest%20%3B%20default%20context%20for%20incoming%20calls%0Atype%3Dfriend%20%3BAccess%20type%0Asecret%3Dpassword%20%3B%20a%20secure%20password%20for%20this%20device%20%0Ausernam%3Dkim%0Anat%3Dno%20%3BDisabled%20NAT%20for%20LAN%0Abindport%3D5060%20%3B%20UDP%20port%20for%20Asterisk%0Adisallow%3Dall%20%3BDisallow%20all%20Call%20Codecs%0Aallow%3Dulaw%0Alanguage%3Den%0Ahost%3Ddynamic%20%3Buse%20DHCP%20to%20get%20ip%20address%0Aqualify%3Dyes%20%0Aallowguest%3Dno%20%3B%20disable%20unauthenticated%20calls%0Adtmfmode%3Dauto%20%3B%20accept%20touch-tones%20from%20the%20devices%2C%20negotiated%20automatically%0A%0A%5B102%5D%20%3B%20Account%20name%0Acontext%3Dtest%20%3B%20default%20context%20for%20incoming%20calls%0Atype%3Dfriend%20%3B%20Access%20type%0Asecret%3Dpassword%20%3B%20a%20secure%20password%20for%20this%20device%20%0Ausername%3Dval%0Anat%3Dno%20%3BDisabled%20NAT%20for%20LAN%0Abindport%3D5060%20%3B%20UDP%20port%20for%20Asterisk%0Adisallow%3Dall%20%3BDisallow%20all%20Call%20Codecs%0Aallow%3D%20ulaw%0Alanguage%3Den%0Ahost%3Ddynamic%20%3B%20use%20DHCP%20to%20get%20ip%20address%0Aqualify%3Dyes%20%0Aallowguest%3Dno%20%3B%20disable%20unauthenticated%20calls%0Adtmfmode%3Dauto%20%3B%20accept%20touch-tones%20from%20the%20devices%2C%20negotiated%20automatically%0A”/]

> Let’s now go back to Openfire and add users to map to the SIP accounts we’ve added.You’ll configure:
Username: Your username
Name: Your Full name
Email: Your email address

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

  • * Username: jose
  • * Device: SIP/101
  • * Extension: 101
  • Caller ID: jose
  • Primary: yes

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

 nano /etc/asterisk/xmpp.conf


[pastacode lang=”bash” message=”” highlight=”” provider=”manual” manual=”%5Basterisk%5D%0Atype%3Dclient%0Aserverhost%3D192.168.1.105%20%3B%20ip%20addresss%20of%20XMPP%20server(Openfire)%0Ausername%3Dopenfire%40192.168.1.105%20%0Asecret%3Dopenfire%0Apriority%3D1%0Ausetls%3Dyes%0Aport%3D5222%0Ausesasl%3Dyes%0Astatus%3Davailable%20%0Astatusmessage%3D%22Asterisk%20Server%22%0Aendtodialplan%3Dyes%0Acontext%3Dfrom_xmpp%0Akeepalive%3Dyes”/]

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

sudo apt-get install libiksemel-dev libssl-dev

For CentOS 7 and RedHat Bases systems:

sudo yum install iksemel-devel openssl-devel

Restart your Asterisk Server then install res_xmpp as below.
> Installing res_xmpp
Once you’ve installed the dependencies, you need to run ./configure in your Asterisk source and make menuselect. Then go into the Resource Modules menu and make sure res_xmpp is enabled. After that, run make install to get the new modules.

cd asterisk-source-directory
make menuselect

Then go into the Resource Modules menu and make sure res_xmpp is enabled. After that do the installation.

[pastacode lang=”bash” message=”” highlight=”” provider=”manual” manual=”make%20install”/]


  • Test to confirm that sip users were successfully added to asterisk
service asterisk restart
asterisk -rvvvvvv 
sip show peers
  • Test to confirm that Asterisk and Openfire XMPP server are communicating, on Asterisk CLI type:
manager reload
manager show connected
You can now install Sparkweb which is an Open Source, web-based IM client optimized for businesses and organizations and Spark IM client to use. You will be able to receive a call via SIP account we added to Asterisk.
On our next tutorial, we’ll talk about how to Use Zoiper and X-Lite Softphones to send instant messages over 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 Softphones; X-Lite and Zoiper chat using Openfire XMPP server.