📜 ⬆️ ⬇️

Programming for 3CX in C #: use the 3CX Call Control API in the Call Flow Designer development environment

Introduction


Writing programs for the 3CX system in C # can be a somewhat unusual exercise for an aspiring IT professional or someone who has not previously experienced writing code. However, this skill will be very useful and in demand, if you are faced with the task of creating truly complex, functional or custom voice applications.

There are a number of powerful rapid development environments, but they all require professional pre-tune-ups and occupy a fair amount of disk space. Therefore, I tried to limit myself to a compact solution, but with support for the IntelliSense function. Microsoft IntelliSense well highlights errors in the code and automatically complements expressions. Of course, if you are already a C # guru, this article may not be so interesting. A notebook is enough for a professional!

Preparing a C # Development Environment Based on Visual Studio Code


1. Install .NET via the Turn Windows features on or off Applet or Windows Update.
')
2. Install 3CX Call Flow Designer .

3. Download the 3CX API Documentation Package . You will need the 3CXObjectModel.2.0.0.0_v15.chm file from the archive, which contains the description of the classes, methods and properties of 3CX objects.

4. Download Visual Studio Code . This is a small, intelligent code editor. During installation, you can set checked options to simplify further work.



5. Install .NET Core SDK and .NET 4.6.1 SDK

6. Download ZIP archive with C # demo script via this link . The archive contains the project file Project1.csproj, which is basically similar to the OMSamples.csproj file from the previously downloaded 3CX API documentation archive. Unzip and click on the file Project1.csproj, which opens in the VS Code application.

7. In the VS Code environment, install the extension for C #. To do this, click Show Recommendation.



Then install all the recommended extensions. After installation, do not forget to click the blue Reload button.



8. In the last step, you need to install some C # dependencies. Go to Explorer> Libraries> Project1.cs, and they will install automatically.



And now you can start programming. During the creation of the application, the development environment will automatically correct your mistakes, supplement operators, etc.



If you have never done programming, and, in particular, in C #, I can recommend this tutorial .

The demo application Project1 performs custom settings for the Call Queue parameters. Function

public void SetQueueParams(string strQueueNumber, bool bPosAnnounce, ushort usTimeout) 

uses three parameters

strQueueNumber is the extension number of the Call Queue, with the parameters of which we work.
bPosAnnounce - enable or disable the message to subscribers about their place in the Queue.
usTimeout - waiting timeout in the queue.

Classes are described in the 3CX Call Control API documentation that we downloaded earlier. The program performs the following actions with the parameters of the Queue (extension 801):


If nothing is highlighted in red in the VS Code editor, there are no formal errors, and the program can be used in the 3CX Call Flow Designer.

Using C # Script in 3CX Call Flow Designer


General information about using 3CX Call Flow Designed is contained in the user manual and article on this blog .

1. Make a copy of the DateTimeRouting CFD demo project folder, which is located in the Documents \ 3CX Call Flow Designer Demos folder, to experiment on a copy of the original application that comes with the distribution.

2. Copy the C # script (in our case Project1.cs) into the project's Libraries CFD folder and give it a recognizable name, for example, QueueAdjust.cs.

3. Modify the original project, leaving two branches and adding the LaunchExternalScript component to each of them.

4. In the first component of LaunchExternalScript1, set the properties according to our task and the semantics of the C # script.



5. In the second component, LaunchExternalScript2, also set the properties for the second branch (time range).



6. Compile and place the application in the service Call Queue, as described in the last section of the previous article .

Conclusion


3CX Call Control API, which is being developed for, is a powerful tool for managing calls in the PBX, and the PBX itself. For example, the API allows you to programmatically manage current calls (make, disconnect, transfer, record, etc.), create and modify users (extensions), manage forwarding rules and user statuses, create conferences, administer IP phones and much more. Read more about it here . However, please note that a separate server REST API is currently used to integrate 3CX V15.5 with the CRM system. For example, here is an example of server CRM integration with Bitrix24.

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


All Articles