📜 ⬆️ ⬇️

Experience of integrating IP-telephony with the helpdesk system through a gadget for Windows 7

Task


So, we wanted a strange one: here an employee is sitting on support, if he received a call, then we should automatically open a window with the existing helpdesk system, to which the phone number from which they are calling will be transmitted. For convenience - the call came, the specialist immediately sees what the computer is, what its network name, username, what hardware / software / services ... The database of employees and everything else with their phones is already there, now how to connect it on the machine?

Proposed Solution


I’ll say right away that we have implemented IP telephony on FreeSWITCH and the solution will be sharpened for it.
To communicate with helpdesk, we just need to call the browser window with a specific address line to which the caller’s phone number should be added. Something of type, for example: myserver.org/helpdesk/requests.php?command=new&phonenum=1072
In FreeSWITCH there is a wonderful module mod_event_socket, which allows you to communicate with FreeSWITCH via sockets. I wrote a PHP script that sits on a web server (it doesn’t have to be on the same machine as FreeSWITCH), connects to FreeSWITCH and subscribes to receive call events.
Next, we have client HTML + Javascript + jQuery file that runs on the client on the machine and accesses this script (AJAX). After receiving a call event, another browser window is launched with a specific address to which the caller's number is also transmitted.
And another small point: every time I don’t want to run this file, it’s necessary to sit somewhere not very noticeable. We need to do it, but this is done by creating a gadget for Windows 7 / Vista. Well, it happened so - we don’t have workstations with Linux. In principle, one could, of course, write a special program that would sit in the tray and do everything, but, but, I cannot give a logical explanation for why I did not.
Everything turned out quite small, I called this beast FreeSWITCH call popup (fscp).

Server part


The server part is executed with one simple PHP's script: fscp.php
It can be hosted on any web server that has access to FreeSWITCH.
Access is via mod_event_socket.
At the very beginning of the file, variables are defined, the values ​​of which must be filled from the file autoload_configs / event_socket.conf.xml:
$FreeSWITCHserver = '127.0.0.1'; //  listen-ip $FreeSWITCHport = 8021; //  listen-port $FreeSWITCHpassword = 'ClueCon'; //  password 
Of course, do not forget to enable mod_event_socket in autoload_configs / modules.conf.xml
 <load module="mod_event_socket" /> 
To connect to FreeSWITCH use inbound socket.
Connect and subscribe to receive events:
event plain ALL
We put two filters:
filter Event-Name HEARTBEAT
filter Caller-Destination-Number account
The heartbeat event in FreeSWITCH is generated every 20 seconds. We use it to ensure that in the wait loop events from FreeSWITCH do not exceed the maximum PHP script execution time (max_execution_time) and exit the loop correctly.
Further in the cycle we expect the arrival of an event from FreeSWITCH. If the event CHANNEL_CREATE comes to us, then we wrap it in a JSON response and send it to the client.
Everything, the script is quite simple.

Client part


Since we are applying for data to another site, the client part receives data from the server via JSONP. The client executes an AJAX request, waits until the desired event arrives, if a heartbeat event arrives, it is simply ignored and the request is run again. If the necessary event arrives, then further actions are performed depending on the settings, but in any case, the call is recorded on the screen of the gadget.
The following settings are made:
Server address - the URL on which our fscp.php script is installed (specify the entire line, including http: // and the name of the script). For example: myserver.com/special/fscp.php
Account - the phone number (account) in FreeSWITCH, the events from which we track.
Action - action when calling this number:
no action - do nothing, the call will simply be displayed in the gadget window
show alert window - show call alert window
call address - call the browser with the specified address
show prompt then call address - show call alert window and only from it, when the user clicks a button, call the browser with the specified address. This is done because there can be a lot of calls, but not everyone needs to take action, for example, make an entry in the helpdesk.
The last two options include calling a site. In this case, you must specify the call string completely, including http: //
As a parameter, the system can transmit the phone number from which the call came. This parameter:% CALLERID% (case sensitive). For example:
myserver.com/helpdesk/add_call.php?number=%CALLERID%
')

Conclusion


Well, actually, the original problem was solved. In this solution, I see two flaws:
  1. There is no authorization, i.e. I can, in principle, specify any phone number in the settings and see who is calling it. Is it bad - I can not say for sure. For example, I don't care who and when calls the CEO :-).
  2. The called window does not open on top of other windows, it must be “lifted” by itself. If someone offers a solution to this problem - I will be very grateful!


Files can be downloaded from here .

Source: https://habr.com/ru/post/142145/


All Articles