1

Hello I am trying to make a module that will make a popup window inside of SugarCRM when we receive a phone call. I have seen that some others have accomplished this already (expensive paid modules) and I am hoping to get some insight on the actual popup triggering part....

Our phone system has an API that sends an HTTP post to a URL when we have an incoming phone call.

Inside of SugarCRM, in my Modules code, I am not sure how I can use this HTTP POST from my Phone to do the Popup, the reason is I do not see how it can be fast enough, If I were to set a Cron job to check a page every 1 minute, that would still be too slow.

So does anyone have any ideas how the other similar Phone integration modules are doing it and having the Popup happen almost immediately as the phone call comes in?

Any ideas on how to do such a task? I am planning to do a Desktop application that just sits in the Tray and waits for the POST but seeing others have been able to get the same result inside of SugarCRM without a separate program really interests me.

1 Answer 1

1

I am working in a company that has created a expensive paid module to accomplished this, but I can give you hints for 2 ways to achieve this ;-)

1) With GenericHook in custom/modules create a logic_hooks.php and a YOURCHOICEHERE.php

in the logic hooks create an after ui hook

$hook_array['after_ui_frame'] = Array();
$hook_array['after_ui_frame'][] = Array(1, 'Display Javascript for Telephone','custom/modules/YOURCHOICEHERE.php','GenericHooks', 'displayTelephoneJS');

and in YOURCHOICEHERE.php

class GenericHooks {

    function displayTelephoneJS() {     

        if(!$_REQUEST['to_pdf']) echo '<div id=\"telephone_div\"></div>
        <script type=\"text/javascript\" src=\"custom/somewherewhereyouwant/Telephone.js\"/></script>';
        // you yould also add a stylesheet here


    }
}

in the Telephone.js you can do what ever you want for example:

function Telephone_poll() { 

$.post("some.php?poll=1,function(data){
    if(data != 0)
    {
        var result= JSON.parse(data);

        //HERE you can do manipulate your telephone_div and populate it with response data "result" from the call to some.php 
        $('#telephone_div').html("<span>HELLO<span>");
        $('#telephone_div').show();
        //Here you can also add styles and so on
    }
    setTimeout("Telephone_poll()", 1000);   //restart the function every 1000ms
});

}
Telephone_poll(); //initial start of script

2) An other approach would be creating a demon/service from a php file that reruns itself. Here you would need some way to identify users and Phones to ensure the popup is displayed for the correct user/phone.

2
  • Thanks for the ideas. What I ended up doing is very similar at first. So I have used the After UI hook to insert my CS and JS files...however I am running JS that uses WebSockets. So I am using the service from pusher.com for my WebSockets...it works great so far, when I get a call, it pops up within a couple seconds at most! Your idea of a Daemon is interesting though, I would like to find out more info about that as I hate relying on a 3rd part site for our WebSockets.
    – JasonDavis
    Mar 10, 2014 at 19:50
  • Your first method seems like it could not be that great for performance as it seems to keep polling the script every x seconds. I have had some bad experience doing this before as it can kill bandwidth sometimes.
    – JasonDavis
    Mar 10, 2014 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.