2009-10-23

CTI (Computer Telephony Integration) for SugarCRM

Recently I come across SugarCRM. It has a Community Edition which I do not need to pay. Moreover, since it is open-source, I can realize some customization easily.

I have experience in CTI (Computer Telephony Integration). But what I can search around SugarCRM is its integration with Asterisk, which is also an open source telephony project.

Because I have already an Avaya installation base, I study whether I can do some quick start work easily.

What I need are two functions:

(1) Screen Pop
To pop up the SugarCRM screen based on the Calling Line Identity (CLI)

(2) Click to Dial
Turn the phone number in the SugarCRM screen to a link that is clickable and activate automatic phone dialling

For those readers which are familar with CTI, these are just very basic features. But it is achievable for SugarCRM, this is already a great time-saver for the CRM users.

I tackle the problem in the following ways:

(1) Screen Pop
Since SugarCRM is web-based, I can simply ask the browser to navigate to a specific link.

The first question is what the link is.

In SugarCRM, I make a search with a phone number. Then I get the following screen.


Great, I find the URL is
http://127.0.0.1/sugarcrm/index.php?module=Home&query_string=test&advanced=true&action=UnifiedSearch&search_form=false&query_string=5551888&search_mod_Contacts=true
5551888 is the phone number I have typed.
Therefore in .NET code, I use:
url_str = "http://127.0.0.1/sugarcrm/index.php?action=UnifiedSearch&search_form=false&advanced=false&query_string=" _
& SkpSock1.CLID & "&search_mod_Contacts=true"
System.Diagnostics.Process.Start(url_str)
Here, SkpSock1.CLID is my CTI object to collect the CLID (Calling Line Identity) property.

(2) Click to Dial
I find SugarCRM has Skype integration, in which it will convert a phone number to a clickable link. First you need to turn this feature on in the Administration screen, as follows:

After the feature activation, you will find that when you put a mouse pointer over a phone number, you can find it the associated link is :
callto://5551234/

In Windows, each URL protocol can be managed by the "Folder Option" in the Windows Explorer. (Someone suggested registry hack. But I prefer the conventional way.)

After pressing the "Advanced" button and then the "Edit" button, you can set your preferred program to handle this protocol. In my case, I have

written a program called "qcallto.exe". Windows will pass the link a program parameter to it.

Finally, a point of SugarCRM hack. As shown in the SugarCRM adminstration screen, it requires a phone number to conform to certain format (e.g. prefixed with a plus sign). I do not like this convention. Why cannot SugarCRM simply treat all the phone number clickable?

Thanks to the PHP open sources, I find that in "c:\Inetpub\wwwroot\sugarcrm\include\utils.php" (the actual directory depends on your installation), there is a php function will determine whether a phone number is clickable:

Original:
function skype_formatted($number){
 if(isset($_REQUEST['action']) && $_REQUEST['action']=="Popup") {
  return false;
  }
 else {
   return substr($number, 0, 1) == '+' || substr($number, 0, 2) == '00' ||
   substr($number, 0, 2) == '011';
  }
 }

I change it to
function skype_formatted($number){
 if(isset($_REQUEST['action']) && $_REQUEST['action']=="Popup") {
  return false;
  }
 else {
  return 1;
 }
}

Some final words... Although my implemented solution is Avaya-based, it is easily portable to other platforms (even for a modem connected phone line) easily.