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 on CentOS 7

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

Installation of Asterisk PBX:

How To Install Asterisk on CentOS 8 / RHEL 8

Install Asterisk on Ubuntu

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.
openfire login
  • 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.

Type your root password, then

su -
cd /opt/openfire/plugins/

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

sudo  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
asterisk manager openfire configuration

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

openfire user

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.

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
test extensions configuration

_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.

[101] ; Account name
context=test ; default context for incoming calls
type=friend ;Access type
secret=password ; a secure password for this device 
nat=no ;Disabled NAT for LAN
bindport=5060 ; UDP port for Asterisk
disallow=all ;Disallow all Call Codecs
host=dynamic ;use DHCP to get ip address
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 
nat=no ;Disabled NAT for LAN
bindport=5060 ; UDP port for Asterisk
disallow=all ;Disallow all Call Codecs
allow= ulaw
host=dynamic ; use DHCP to get ip address
allowguest=no ; disable unauthenticated calls
dtmfmode=auto ; accept touch-tones from the devices, negotiated automatically
asterisk sip configuration

> 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

user add openfire

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

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

Save settingsand 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


serverhost= ; ip addresss of XMPP server(Openfire)
[email protected] 
statusmessage="Asterisk Server"

> 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.

make install


  • Test to confirm that sip users were successfully added to asterisk
service asterisk restart
asterisk -rvvvvvv 
sip show peers
sip show users
  • 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 serverHow 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.

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


  1. Hi, thank you for this excellent tutorial. I’d like to integrate Openfire with FreePBX (also based on Asterisk 13). Would there be any reason this tutorial could not work for this case?

    Thank you,

    • @ioan. Thanks ioan. It should work just fine since FreePBX is a fork of Asterisk. Maybe few differences on location of Configuration files and use of web based configuration interface.

  2. Hi, thank you very much for your tutorial.

    Asterisk-IM is no longer supported, is there any alternative to use with Asterisk?


    Haid Avila

  3. i had installed asterisk and openfire serveur but i have this error when i tried to integrate betwen them :
    ERROR[31623]: res_xmpp.c:3648 xmpp_client_reconnect: No XMPP connection available when trying to connect client ‘asterisk’


Please enter your comment!
Please enter your name here