FOP2 Popups and Variables
FOP2 has the option to open a window popup when a phone is ringing or when an agent call is connected. This feature can be used to integrate your phone system with a web based CRM, for showing up the greeting for an Answering service, etc.The feature is powerful, and for that very same reason has lots of options and might be a little complicated at first. Be sure that your browser is allowed to display popups for your FOP2 url. Default behaviour in browsers is to *block* popups, the first time one is fired you will probably see a RED/YELLOW notification icon somewhere telling you about it, where you can whitelist a site so it can open popups.
POPUP on Ringing
In order to configure FOP2 to send popup events when your extension is ringing, you must configure in /usr/local/fop2/fop2.cfg the following:
notify_on_ringing=1
If this setting is not present or commented, the default value is still 1, so this notifications are enabled by default.
Whenever your extension Rings, if you are logged into FOP2 you will receive an incoming call notification, and if popups are enabled it will open up. We will discuss later how to enable/configure this popups.
POPUP on Connect
Another option is to receive a call notification/popup when you answer a call that comes from a queue. Asterisk provides a special event for agents answering queue delivered calls, and FOP2 can be configured to fire the popup on that event. Note that this does not work for regular inbound calls, only for queue delivered calls as it requires the AgentConnect in the Asterisk Manager, an event that is not normally sent for regular calls. However, there is a plugin named "Bridge Popup" that will mimic the AgentConnect event for regular calls. If you want a connect popup for regular calls, you might want to try that plugin (but it can fire duplicate popups for queue delivered calls, or it might fire for internal calls, etc. So use it at your own risk.).
In order for Asterisk to send the AgentConnect event, you must set in your queue configuration the following:
eventwhencalled=yes
Since Asterisk 13 this setting is not needed. If you use FreePBX, the queue configuration has the option to turn event when called on or off in the Admin Web GUI.
To enable popups on these events, you must edit /usr/local/fop2/fop2.cfg and set
notify_on_connect=1
The default value is zero, so if you do not set this. FOP2 won't fire connect events to connected browsers/clients.
FOP2 Client Configuration
After configuring the server, you must enable the Popup on the client side. So, log into FOP2 and open Preferences, you will notice a Popup section inside it. If you want to enable popups for your extension, then you should set Automatic Popup to "ON". You also need to fill the URL field with whatever URL you want to popup, here is an example:
Without this enabled. The extension you logged into FOP2 won't receive a popup even if its configured on the server side.
Variables
If you paid attention, you probably seen the variable in the URL address. FOP2 lets you pass variables for your phone call into the popup so you can actually perform interesting actions, like searching by callerid. The syntax for variables is #{NAME}, the built in variables in FOP2 that you can use are:
For Ringing:
#{CLIDNUM}
#{CLIDNAME}
For Connect:
#{CLIDNUM}
#{CLIDNAME}
#{UNIQUEID}
#{FROMQUEUE} #{EXTEN}
Besides the built in variables, you can get *any* Channel variable you might have in Asterisk. This is *very* powerful, but requires configuration for such variables in your own dialplan if they are not set by default by Asterisk. Also, you must configure the Asterisk Manager to broadcast the variables you are interested in by adding an entry in /etc/asterisk/manager.conf, for example:
[general]
channelvars=FROM_DID
This example will broadcast the FROM_DID variable (that is set by FreePBX based system to list the DID number that was dialed), so you can use the #{FROM_DID} variable in FOP2 Popup URLs.
Whenever you change the manager.conf file, you must reload it with the command:
asterisk -rx "manager reload"
Global Popups
Imagine that you want to enable popups for everyone, and you want to skip the hassle to log as every extension, open up preferences and setup the URL there. You can do so by modifying the following file: /var/www/html/fop2/checkdir.php
You must know a little bit of php coding to get an idea. If you are not familiar with that, then use the GUI config instead.
This file is called whenever a notification is fired from the server. If you look at the code you will see commented code to run javascript commands whenever the popup type is ringing or connect. Basically you must uncomment your action and print/output some javascript code for your actions, like the sample:
header("Content-type: text/javascript");echo "window.open('/vtigercrm/index.php?module=Home&action=UnifiedSearch&query_string=$clidnum')";
This code block will perform a search on a vtiger crm installation using the caller id number for searching.
You can also update the mini browser iframe with content, instead of opening a new tab, here is a sample code to do that inside checkdir.php:
if(\$('#browseriframe').length>0) { $('#browseriframe').attr('src','customerhistory.php?clid=$clidnum'); $('#urlbar').val('customerhistory.php?clid=$clidnum'); }
Mini Browser
Popups might be annoying, they can move focus out from your activity window. They might be blocked. Since FOP2 version 2.30 there is a free plugin that lets you open up a web site inside an iframe on the FOP2 window itself. If the mini browser plugin is installed, then popup urls will be opened inside that iframe, without moving focus out of FOP2. It is a handy way to have FOP2 and your CRM/Custom code well integrated.
Chrome Extension
If you install the FOP2 Google Chrome Extension, you can open up Options and setup the URL for popups in there, the same way and with the same format for variables that you can use on the main FOP2 GUI Preferences windows. This is also very handy as you do not even need FOP2 to be open in order to get popups.