Avatar of Matthew_Way
Matthew_Way asked on

Asterisk PHP CRM lookup caller on inbound calls.

We have been using asterisk for a couple of years now.
Integrated into our custom PHP CRM package.
We currently have click to dial feature which does an AMI dial via asterisk.

And now we want to have the CRM application lookup the caller ID number of inbound calls.

I have know idea on how we would implement this?
IP Telephony

Avatar of undefined
Last Comment

8/22/2022 - Mon

You should be able to launch the CRM from a URL.

Packages suck as iSymphony from i9technologies will screen pop on an inbound agent call.

Astassistant would also do this and is free however that package has not been updated in a while.


I would use PHP AGI (http://phpagi.sourceforge.net/).

As calls come in, run them to an AGI script (PHP of course). When the script starts, it will have certain environment variables built into it: one of which is the inbound CID.

Run the number, and interact with CRM as needed. Use the AGI to work with the CID, and then return control back to dial plan code.

If you're looking for screen pop capability, that's a whole new issue because it is a cross platform problem and depends on which extension actually receives the call.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy

Yes that's what I'm after, screen pop.
We have a combination of Linux and Windows clients using FireFox and Xlite.

Is it possible to some how trigger firefox to do a lookup based on the CID


Firefox does not "listen" to anything as a client by default.

In order for a screen pop, you would have to rig up the following:

1. Inbound call hits asterisk
2. Asterisk hits CRM to do a lookup for later usage, sets CID, does CDR, etc...
3. Call is answered.
4. Asterisk fires AGI, that fires PHP (or something else), which notifies a daemon on the asterisk box of who answered the call, and other relevant information.
5. The daemon notifies a client application running on the appropriate Windows box to execute the URL / URI.
6. The client runs a shellex, or some other spawn command to cause firefox to open a specific URL.

There are other ways of skinning this cat, and I am sure my colleagues here will have some opinions on what to do with it. But in theory, this is a very clean way of doing it.

You would need to write a very simple system service for your windows machines that log into the daemon on the asterisk box.

You could write a very simple daemon on the asterisk box to listen and maintain connections.

Astassistant has all of the libraries mentioned.  It will pop the URL of your choice with the caller ID at a user selectable point in the URL.

Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.

Astassistant looks like it would do the trick because it connects to the AMI. If you can configure it to execute the URL at the correct point in time (in between the CRM queries) it might do the trick You would have to try it to find out.

But it looks like something to definitely try.

I wonder if I could use a hidden iFrame with a long lived HTTP connection AKA comet.

I found this.

Looks like bit I'm missing would be a webserver that could efficiently hold open 50 HTTP sessions.

That would allow the running web session could handle the inbound call.

Sure you could write your own application.  It would have to connect to the Asterisk manager to get the events.

Much larger project than using an application that is already written to do screen pops.

Your help has saved me hundreds of hours of internet surfing.

Yeah I know, but the problem keeps coming back to the client PC.

How do I trigger an event on an already running web session within FireFox ?

And if we don't have to install additional software on the client PC that's going to make the job easier.

Been Googling around and found this on GitHub:


Could use it as a proxy between the Asterisk server and the web browsers to pass events back up the line as it were.

>>How do I trigger an event on an already running web session within FireFox ?

THis is the main problem. Firefox doesn't inherently listen for information from other sources. You either have to have a system service listen, and then shellex the URL to firefox, your have to write an xpi plugin.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.

FOP http://www.asternic.org
FOP2 http://www.fop2.com

both can be used to fire popups on inbound calls. An example solution integrating FOP with Sugar CRM:


FOP uses flash xmlsockets (fop2 also uses html5 web sockets when available) for the long lived synchronous connection. And you do not need to expose the Asterisk Manager to the public.


The particular project we have been asked to do is no longer happening.
But I'm sure this is something we are going to need to do in the future with our application.

We can't just simply move to Sugar CRM and through out our existing application.

What I'm thinking of is using nodejs listening to Asterisk for events.
Then have the web browser hold open a connection to the nodejs server.
Probably through web sockets.
Which I understand is now built into the Chrome browser.

The simple answer is that right now there is no simple answer.

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question