Chapter 25. Using the WebRTC softphone on the Icon agent page

This chapter is a reference guide to install Asterisk 12 and QueueMetrics 14.06 in order to use the softphone embedded in Icon, the new realtime agent page. The softphone is based on sipML5.


The support offered for WebRTC by different browsers is in flux, so expect minor differences in the set-up. We welcome your comments and suggestions.

25.1. Prerequisites

We focus on:

  • A fresh install of Centos 6.4, i686 (32bit) version.
  • Asterisk 12.3.0 and required libraries compiled from sources.
  • QueueMetrics 14.06 served through HTTPS (Secured HTTP or HTTP over SSL) in single server mode.
  • Chrome 35.0.1916.153 m running on a Windows 8.1 machine.

At the end of the chapter the reader will have:

  • A regular SIP phone configured as caller.
  • An inbound queue.
  • An agent accessing the QueueMetrics agent page, able to receive calls through the integrated WebRTC softphone.

25.2. Installing Asterisk 12.3.0

We suppose to have an already installed Centos 6.4 with working Internet connection and a root privileges. The first step installs the bare minimum tools needed to compile Asterisk and other required libraries.

Perform the following steps from a console or remote shell:

yum update
yum install gcc-c++ make gnutls-devel kernel-devel libxml2-devel
yum install ncurses-devel subversion doxygen texinfo curl-devel
yum install net-snmp-devel neon-devel
yum install uuid-devel libuuid-devel sqlite-devel sqlite git speex-devel gsm-devel
yum install wget

It is now time to compile the SRTP library. We focus on version 1.4.2. What you need is to download the sources and unpack in a suitable folder:

tar zxvf srtp-1.4.2.tgz

Then configure, compile and install the library.

cd srtp
make install
cp /usr/local/lib/libsrtp.a /lib
cd ..

PJSIP was introduced in Asterisk 12 in order to replace the SIP channel. Even if we don’t use this new channel in this tutorial, PJSIP is needed by WebRTC in order to properly handle STUN/ICE transactions. Follows these steps to download, configure and install the latest PJSIP version available on GitHub.

git clone pjproject
cd pjproject/
./configure --prefix=/usr --enable-shared --disable-sound --disable-resample \
   --disable-video --disable-opencore-amr --with-external-speex \
   --with-external-srtp --with-external-gsm
make dep
make install

Jansson is a JSON library needed by Asterisk 12. We focus on the 2.5 version of this library.

tar zxvf jansson-2.5.tar.gz
cd jansson-2.5
./configure --prefix=/usr
make install
cd ..

All required dependencies are now satisfied and it’s time to download Asterisk 12.3.0 and compile it:

wget ""
tar -xvf asterisk-12.3.0.tar.gz
cd asterisk-12.3.0
make menuselect

If building on a KVM box, it’s better to uncheck BUILD_NATIVE under Compiler Flags (press x to save). Disable all res_pjsip modules except res_pjsip_log_forwarder. Disable chan_pjsip.

make install
make samples

Asterisk provides a set of init scripts you can copy and use in your distribution. Centos 6.4 requires to copy the file rc.redhat.asterisk in your init.d folder:

cp ./contrib/init.d/rc.redhat.asterisk /etc/init.d/asterisk

then edit the copied file by changing the line:


and assigning the root and execution privileges

chown root:root /etc/init.d/asterisk
chmod 544 /etc/init.d/asterisk

You should now have Asterisk 12 installed and ready to be configured.

25.3. Install QueueMetrics

QueueMetrics must be installed following the regular procedures. We will do an automated yum installation. For more detailed information, please refer to the QueueMetrics user manual.

Type the follwing commands:

wget -P /etc/yum.repos.d

yum install queuemetrics

The yum command will download QueueMetrics and all of its dependencies and install it on your system. This may take a while, depending on your internet connection speed. When asked to confirm the installation, type "y" to proceed.

To test that everything is fine, you’ll have to point your browser to the address http://yourserverip:8080/queuemetrics - on the first access, a database will be created.


Google Chrome currently limits microphone and speaker sharing to well known SSL certified connections. If no HTTPS protocol is used, Chrome asks to the user to allow microphone and speaker usages on each call. For this reason you need to configure your servlet container to serve QueueMetrics through SSL connections. Details are reported in this manual - see Chapter 20, Securing QueueMetrics (Tomcat) With A SSL Certificate

25.4. Configuring Asterisk

Asterisk configuration files are located at /etc/asterisk folder.

cd /etc/asterisk

The first operation we want to do is to enable the websocket transport. This must be done by editing the http.conf file and changing the following keys:

enabled = yes

then Save and exit.

Our target is to have a softphone for the agent and a regular SIP phone for the caller. We need to configure them by editing the sip.conf file.

With a text editor, change the key:


This enables the websocket transport, then change the realm key to something valid for your site like, for example:


The new peers will be added though the help of templates. The first template is targeted to softphones, the second is targeted to regular SIP phones. Add these lines to your sip.conf file:



Then specialize the templates by adding two peers:


callerid= "customer" 1

QueueMetrics needs to connect to Asterisk 12 through AMI. This could be enabled by editing the manager.conf file and changing the following relevant keys:

enabled = yes

secret = password
read = system,call,log,verbose,command,agent,user,config,command, \
write = system,call,log,verbose,command,agent,user,config,command, \

In this example we want to have an inbound queue. This has to be specified in the queues.conf file by adding, at the end of the file, the following code:

strategy = ringall

We suppose the caller (impersoned by our regular SIP phone registered with username 200) would be able to place calls into the queue. To enable this we need to modify the extensions.conf file by adding the following code at the end of the file:

exten => 300,1,NoOp("Called Queue ${EXTEN})
exten => 300,n,Queue(${EXTEN},t,,)

Don’t forget to add:

#include extensions_queuemetrics.conf

at the very beginning of the extensions.conf file. This includes the QueueMetrics dialplan logic needed by Asterisk/QueueMetrics integration.

You are now ready to start Asterisk 12 by issuing a /etc/init.d/asterisk start

25.5. Configuring QueueMetrics

Access to QueueMetrics by pointing Chrome to the URL https://yourserverip:8443/queuemetrics and specifying the default administrative username and password (demoadmin, demo).

Click on Edit system parameters on the Administrative tools menu section you find in the main page. Perform the following changes through the editor shown in the page:



# Default keys for the sofphone definition

You need to specify to QueueMetrics to operate on the queue we defined in Asterisk. This could be done by adding a new queue through the Edit queues link in the main page and clicking on the button Create New.

Specify 300 in the Queue alias and Queue(s) fields then select Inbound calls from the Call flow dropdown. Save the queue then assign the agent/101 as Main by clicking on the Agents button located at the bottom of the queue definition page.

To enable the softphone for the agent/101 click on the Cfg Agents on the top menu, then enter on the agent/101 detail page. In this page, fill the fields WebPhone Username and WebPhone Password with the proper values (we defined in Asterisk the SIP peer 101 with 101 as username and password), then fill the Current terminal field with the extension you want to assign to a specific user. In this example you need to set it at 101.


Make sure your agents hold the security key NEWAGENTPAGE so they see the Icon page.

Log off as administator and log back in as agent/101. Through the agent page, login to the 300 inbound queue. You’re now ready to use the softphone to answer to any call to the extension 300, generated by the regular SIP phone.

Good luck!