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

    We suggest you take a look at an example of the implementation of call history when using the IP-PBX 3CX Phone System v.12, namely: 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 the 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 of the SIP PBX 3CX, a new client appeared - 3CX MyPhone. The functionality of the client is impressive - the state of the phones, the phone book, viewing call history with the ability to listen to recordings and much more. However, integration with other systems is quite limited. The 3CX API, as in previous versions, works only on the same machine where the 3CX system is installed, and is quite difficult to program. In addition to the API, the 3CX Phone System also has a wonderful CallHistory interface, which keeps “posthumous” call records. We successfully used this interface for several years in conjunction with Manageengine ServiceDesk Plus inside our company, due to which we were able to significantly increase the efficiency of our “outsourcing” work.

    Because we had a sharp question about the internal implementation of the open source service desk system and the main area of ​​activity is still 1C, then the products of Rarus and Desnol-Soft companies were considered as new software. The choice fell on Itilium from Desnol-Soft.
    But the introduction of Itilium without a connection with telephony does not make sense to us. Therefore, the first step we set ourselves the task of storing call history in 1C, namely: 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 the audio recording file; the ability to listen to the recording.
    So we have: installed and configured 3CX Phone System v.12; Itilium database installed and published on the web server. Let's move on to implementation.

    1. We make additional settings 3CX CallHistory for our purposes. We need the file% 3CXData% \ Data \ CDRTemplates \ CDRTemplate-SocketListen.xml (For Windows Server 2008, this is C: \ ProgramData \ 3CX \ Data \ CDRTemplates \ CDRTemplate-SocketListen.xml).
    In the line
    CallTemplate Host = “127.0.0.1” Port = “33555” OutboundOnly = “false”
    we change the Host parameter to the external IP address of the machine running the 3CX system, for example 192.168.11.2. Restart the 3CX CallHistory service and check the service operation with the
    telnet command [3CX server ip address] 35555
    After completing 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 that we have to parse this data, we can simplify our future life. For example,
    CDRTemplate-SocketListen.xml 
    such a message format will greatly simplify the work in the future.
    Do not forget to edit the 3CXCallHistory service after editing CDRTemplate-SocketListen.xml. And another very important note - keep a copy of this file in another place or rename it and set the value of the CALLHISTTEMPLSOCKLISTEN parameter to 3CX equal to the name of your file (Settings - Advanced Settings - User Settings Tab), because when installing service packs for 3CX, files in the CDRTemplates directory are overwritten with default files. So, on the 3CX side so far, everything ...
    2. In the 1C system, create the information register TF_Call History:
    Information register TF_Call History 
    Then create the CallHistory Web service. In it, we create the SaveHistory (Record) method which will receive the line from item 1 at the input, parse it and create entries in the TF_History of Calls information register. Avoid the names of services, methods and parameters of Russian names.
    CallHistory Web Service 
    3. We draw the implementation of the SaveHistory method (hi-res: habr.habrastorage.org/post_images/d4a/f4c/d4f/d4af4cd4f675daf692c5160fb396ef6b.png )

    SaveHistory Method
     
    As you can see, the correction of the message format makes it possible to simplify parsing. Additional functions are needed, because the 1C and C # date and time formats are different:
    Additional functions
    The main function converts a string of the form [key] = [value]; [key] = [value] into the corresponding structure:
    Main function
    Another note on storing 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. The formation of the correct links performs a very simple function (in the comments only the type of record):
    Storing audio recordings
    That's all with the web service. Now tie it all together. We use C # Visual Studio 2012 for the bundle, although you can use any other tool that you own.
    Our C # program should connect to the 3CXCallHistory port of the service and transfer everything received to the 1C service. The whole binding has as its goal the automatic restart in case of disconnection or inaccessibility of the Web service. 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 3CX_CDRClient1C service, 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 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 starting an IUSR_IIS7 user in 1C with OS authorization and ROLI rights to start a web service. At first glance it works, but ... When you start the web client, we get not a jamb, but a JAM !!! We didn’t take a screenshot, but it’s too lazy to return the settings, so whoever is not too lazy - check who is too lazy - believe me.
    Login
    So, when starting 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, the Session Parameters. Current User is empty and this leads to the error "Attempting to access an uninitialized session parameter". So past authorization in any way.
    The third option is http://www.forum.mista.ru/topic.php?id=661110 (for which many "Thank you"!). Using 3 options led to extra lines in the C # app.config project.
    Thanks to a famous resource 
    If anyone knows how to read, we will be glad to receive information.
    The result is this:
    ЗCX + 1C result 1
    3CX + 1C result 2
    File name - link. When pressed, the player opens:
    3CX + 1C result 3
    Integration is possible in any 1C configuration with minimal changes to the original configuration.

    A source:infostart.ru/public/237772

    Also popular now: