📜 ⬆️ ⬇️

An example of the implementation of call history for IP-PBX 3CX Phone System

We suggest you look at an example of the implementation of call history when using IP-PBX 3CX Phone System v.12, namely: the date and time of the call; duration; incoming number; outgoing number; event of forwarding to another number; event of forwarding from another number, link to audio recording file; the ability to listen to the recording. Integration is possible in any 1C configuration with minimal changes to the original configuration.
image


In version 12 SIP PBX 3CX, a new client appeared - 3CX MyPhone. The functionality of the client is impressive - the state of the phones, the phone book, view call history with the ability to listen to records and much more. However, the possibilities of integration with other systems are rather limited. The 3CX API interface, as in previous versions, works only on the same machine where the 3CX system is installed, and is rather complicated for programming. In addition to the API, 3CX Phone System has another great CallHistory interface that keeps track of your calls after death. We successfully used this interface for several years in conjunction with Manageengine ServiceDesk Plus within our company, thanks to which we were able to significantly increase the efficiency of our “outsourcing” work.

Since we have a sharp question about the internal implementation of the open source service desk system and our main business is 1C, then the products of the companies Rarus and Desnol-Soft were considered as new software. The choice fell on Itilium from Desnol-Soft.
But the introduction of Itilium without a bunch of telephony for us does not make sense. Therefore, the first stage we set ourselves the task of storing the call history in 1C, namely: the date and time of the call; duration; incoming number; outgoing number; event of forwarding to another number; event of forwarding from another number, link to audio recording file; the ability to listen to the recording.
So we have: 3CX Phone System v.12 installed and configured; installed and published on the web server Itilium DB. Let's turn to implementation.

1. Making additional 3CX CallHistory settings for our purposes. We will need the% 3CXData% \ Data \ CDRTemplates \ CDRTemplate-SocketListen.xml file (For Windows Server 2008, this is C: \ ProgramData \ 3CX \ Data \ CDRTemplates \ CDRTemplate-SocketListen.xml).
In line
CallTemplate Host = "127.0.0.1" Port = "33555" OutboundOnly = "false"
change the Host parameter to the external IP address of the machine on which the 3CX system is running, for example 192.168.11.2. Restart the 3CX CallHistory service and check the service operation by the command
telnet [ip server address 3CX] 35555
After the completion of any call, information on this call should appear in the telnet window. The data format depends on the contents of the CDRTemplate-SocketListen.xml file. In principle, you can use the default format, but given the fact that we have to parse this data, we can simplify our future life. For example, so
CDRTemplate-SocketListen.xml
Such a message format will further greatly simplify the work.
Do not forget after editing the CDRTemplate-SocketListen.xml restart the 3CXCallHistory service. And another very important note - keep a copy of this file in a different place or rename it and set in 3CX the value of the CALLHISTTEMPLSOCKLISTEN parameter equal to the name of your file (Settings - Advanced settings - User parameters tab), since when installing service packs for 3CX, files in the CDRTemplates directory are overwritten with default files. So, on the 3CX side, for now, everything ...
2. In the 1C system, create a data register TF_Zvonkov History:
_
Then we create the CallHistory web service. In it we create the SaveHistory (Record) method which will receive a line from item 1 at the input, parse it and create entries in the information register TF_History of Calls. We avoid the names of services, methods and parameters of Russian names.
Web- CallHistory
3. Draw the implementation of the SaveHistory method (hi-res: habr.habrastorage.org/post_images/d4a/f4c/d4f/d4af4cd4f675daf692c5160fb396ef6b.png )
')
SaveHistory

As you can see, the correction of the message format makes it possible to simplify parsing. Additional functions are needed, since the 1C and C # date and time formats are different:

The main function converts a string of the form [key] = [value]; [key] = [value] into the appropriate structure:

Another note on the storage of audio recordings. They can be stored in the database, but the size of the base grows by leaps and bounds. Therefore, it is better to store files as links to a network resource. Forming the correct links performs a very simple function (in the comments only the appearance of the record):

With the web service for now. Now let's tie it all together. For bundles use C # Visual Studio 2012, although you can use any other tool that you own.
Our C # program should connect to the port of the 3CXCallHistory service and transfer everything that was received to the 1C service. The whole binding is aimed at automatically restarting if the connection is broken or the Web service is unavailable. The program (in the near future we will publish it) can be launched from the command line, then it will issue diagnostics to the console. You can install it as a service, and if you call the service 3CX_CDRClient1C, then it will be visible in the 3CX Phone System management console.
Now the nuances.
1. Authorization.
The first option is no users in the database. Web service is available. But we are not looking for easy ways, especially since a combat base without users is nonsense.
The second option is to launch a web server from an IUSR_IIS7 OS user, for example, plus setting up IUSR_IIS7 in 1C with OS authorization and ROLY rights to launch a web service. At first glance, it works, but ... When you start a web client, we get not a joint, but a CANT !!! The screenshot was not taken, but the laziness is to return the settings, so who cares - check who is lazy - believe me.

So, when you start the web client, the 1C authorization window does not appear, and the user IUSR_IIS7 writes in the red box in the screenshot. In addition, in the Session Options. Current User is empty and this results in the error "Attempt to access an uninitialized session parameter". So by no means authorization.
The third option is http://www.forum.mista.ru/topic.php?id=661110 (for which a huge “Thank you”!). Using 3 options led to additional lines in the C # app.config project.

If anyone knows how to read - we will be happy to receive information.
The result is this:
CX + 1C  1
3CX + 1C result 2
The file name is a link. When pressed, the player opens:
3CX + 1C result 3
Integration is possible in any 1C configuration with minimal changes to the original configuration.

Source: infostart.ru/public/237772

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


All Articles