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.

[Tip]

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:

wget http://srtp.sourceforge.net/srtp-1.4.2.tgz
tar zxvf srtp-1.4.2.tgz

Then configure, compile and install the library.

cd srtp
autoconf
./configure
make
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 https://github.com/asterisk/pjproject 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
make install
cd..

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

wget http://www.digip.org/jansson/releases/jansson-2.5.tar.gz
tar zxvf jansson-2.5.tar.gz
cd jansson-2.5
./configure --prefix=/usr
make
make install
cd ..

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

wget "http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-12.3.0.tar.gz"
tar -xvf asterisk-12.3.0.tar.gz
cd asterisk-12.3.0
./configure
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
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:

AST_SBIN=/usr/sbin

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 http://yum.loway.ch/loway.repo

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.

[Important]

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
bindport=8088
bindaddr=0.0.0.0

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:

transport=udp,ws

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

realm=LowayResearch

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:

[WebRTC](!)
type=peer
host=dynamic
nat=force_rport,comedia
context=from-internal
callcounter=yes
busylevel=1
call-limit=1
encryption=yes
qualify=yes
avpf=yes
allow=all
icesupport=yes
srtpcapable=yes
videosupport=no

[SIPPhone](!)
deny=0.0.0.0/0.0.0.0
dtmfmode=rfc2833
canreinvite=no
context=from-internal
host=dynamic
type=friend
qualify=yes
permit=0.0.0.0/0.0.0.0
call-limit=1

Then specialize the templates by adding two peers:

[101](WebRTC)
username=101
secret=101

[200](SIPPhone)
username=200
secret=200
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

[admin]
secret = password
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.0
read = system,call,log,verbose,command,agent,user,config,command, \
        dtmf,reporting,cdr,dialplan,originate
write = system,call,log,verbose,command,agent,user,config,command, \
        dtmf,reporting,cdr,dialplan,originate

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:

[300]
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:

[from-internal]
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.queue_log_file=sql:P001
callfile.dir=tcp:admin:password@127.0.0.1

default.rewriteLocalChannels=true
default.hotdesking=86400

# Default keys for the sofphone definition
default.sipaddress=yourasteriskip
default.websocketurl=ws://youasteriskip:8088/ws
default.rtcWebBreaker=false

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.

[Tip]

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!