Many of our clients want to be able to use Voice Elements, but need a way to notify people that they have calls. So we thought, we’d just build something out and give them the code.
Use of ScreenPop in your Web-Based Telephony App
Generally with AJAX, you have the client poll constantly; however, the issue with that is that there can be a delay in getting the ScreenPop, and that can cause a lot of load on the server.
To solve this we wrote a Comet application so that the client is notified whenever a call comes in.
How it Works
We set up the web server so that it handles any requests to *.nfy asynchronously. This is essential because, IIS can only handle a couple hundred synchronous requests at a time.
When the server gets a request from a client, it checks shared memory to see if there is anything pending and then creates a new instance of a manual reset event and waits up to 60 seconds before it is either triggered or times out.
When the IVR wants to notify a client that there is a call waiting for it, it just makes an HttpRequest to notify.nfy and passes a few different parameters (more on that below). When the web server gets the request it stores it into shared memory.
We have a separate thread that checks the shared memory every few milliseconds (set to 10 — but adjustable by you) to see if there are any messages for any of the agents that are connected. If there are any messages available for any waiting agents, it triggers the reset event, and the messages goes off to the agent.
Although a few hundred milliseconds may not seem like a big difference, in practice it seems much, much faster. More importantly, the stresses on both your webserver (and potentially database server) will be greatly reduced because your AJAX will be making far fewer requests per minute.
How To Test It Out
Here is how to test it out:
You can bring up as many agents as you wish. Just make sure they each have a unique AgentId. In your browser go to this link. This will open web page. In the future, you could put your own dashboard on this page and show some statistics. You can just minimize this web page – you won’t need to interact with it.
When you have a screen to pop to a particular agent, then the IVR can send the following URL. For testing purposes you can open up a separate browser and key in the URL.
Please make sure you put the correct AgentId in the query string above. Optional Parameters are Height and Width (which specify how big you want the new browser window).
You can even pass parameters that will get passed on to the browser when opening the new window. Below is an example:
Notice how the URL is all enclosed in quotes “ParameterTest.aspx?Name=Ron Tanner&Product=HmpElements”. This makes it possible to pass on any custom parameters to the web page that gets loaded.
Keep in mind that most browsers block popup windows, so you’ll have to allow from the website, and then try again. In the case of the Chrome browser after you have allowed pop-up always from this site, you will have to close that browser and re-open it to work.
Calling a URL from any .NET application is very, very easy. This should make it very simple to add ScreenPop capabilities to your web app.
To deploy it to your web server, you will need the compiled DLL (which you can compile yourself!, or use a binary that we give to you) and add a configuration setting to the web.config to handle .nfy requests.