« Divide and conquer with Servoy headless client plugin | Main | I Love You Wakanda…but I'm Breaking Up »

June 24, 2013

Phone calls from web client with Asterisk

by Lachlan Dunlop

Note: Guest post! On one of my daily perusals of SVN commits I saw some code that perked my "whoa...too cool" radar. Crazy creative stuff. - David

Moving a Servoy smart client solution to the web brought with it a number of challenges. Our original solution was based on Data Sutra which is a robust smart client (and now web client) application platform for Servoy solutions. To keep our headaches to a manageable level during the transition process, we worked closely with the Data Mosaic folks as they developed the web client version of the Data Sutra framework.

Our solution is a CRM application that interfaces with an Open Systems OSAS Accounting system. In the original smart client phone app, dialers were interfaced through modems connected to the client computers' serial ports and linked into the main phone system. It was a wiring mess and the sales reps had to be in the office where the phone system was located.

In migrating to web client, we changed the phone system to the very successful open source system Asterisk. Sales reps now have "soft phones" on their computers (sip device) for phone calls. This allows them to have phone and application access wherever they open their laptops.


Green rows = incoming calls, red rows = calls over 5 minutes

Interfacing into Asterisk is done in a couple of ways. The simplest (our current approach) is to generate a call file and send it over to the Asterisk server via scp (by default code runs on the server when using web client): 

var str = 'MaxRetries: 0'
	str += '\n'+'RetryTime: 60'
	str += '\n'+'WaitTime: 30'
	str += '\n'+'Context: sip-outbound'
	str += '\n'+'Accountcode: customer'
	str += '\n'+'Channel: SIP/'+solutionPrefs.access.extend['customer'].station
	str += '\n'+'Callerid: '+solutionPrefs.access.extend['customer'].init
	phone = phone.replace(/^\+1 /,'')
	str += '\n'+'Extension: '+phone
var file = plugins.file.createFile('/tmp/'+ solutionPrefs.access.extend['customer'].station + '_' + globals.CODE_date_format(null,'specify','yyyy_M_d_HH_mm_ss') + '.txt')
var saved = plugins.file.writeTXTFile(file,str)
var scp = application.executeProgram('scp',file,'asterisk@')

The process to make a call:

1) Sales Rep clicks a phone number in the CRM solution.
2) A call file is generated containing the phone number to be dialed, and the sales rep sip device and some context info.
3) The Sales reps phone is then called, when the sales rep answers the call, Asterisk then dials the requested phone number.

The next step in development is interfacing with the Asterisk-java library (https://asterisk-java.org) which integrates with the Asterisk Management Interface (AMI). This will require the development of a Servoy plugin and will provide advanced access/control of the inner workings of Asterisk. Very Exciting.

A by-product of this development is a call reporting engine ("Call Metrics" navigation item in the screen shot) that was developed for the corner office folks. Gives them the ability to analyze rep performance based on calls placed/received, length of calls, dollars sold, etc. This module after 2 weeks of collecting and reporting data has made the application almost priceless in training and educating reps new and old.

Moving this application to the web was not without hassles as web programming is a new beast for us. But we were able to get it done and deployed without losing any performance or functionality using Data Sutra—and in some cases like making calls—greatly improve on what was there before.

Posted by David Workman on June 24, 2013 at 04:27 PM in Articles | Permalink


The comments to this entry are closed.