Virtual PBX of Rostelecom: what and how can be done through the API

Virtual PBX of Rostelecom: what and how can be done through the API

Modern business perceives city phones as an outdated technology: cellular communication provides mobility and constant availability of employees, social networks and instant messengers are an easier and faster communication channel. In order to keep up with their competitors, office PBXs are becoming more and more like them: they are moving to the clouds, managed via a web interface and integrated with other systems via API. In this post, we will tell you what functions the Rostelecom Virtual PBX API has and how to work with the main functions of the virtual PBX through it.

The main task of the Rostelecom virtual PBX API is to interact with CRM or company websites. For example, the API implements "callback" and "call from the site" widgets for the main management systems: WordPress, Bitrix, OpenCart. The API allows:

  • Receive information, notify status and make calls on request from an external system;
  • Get a temporary link to the recording of the conversation;
  • Manage and receive restrictions settings from users;
  • Get information about the user of the virtual PBX;
  • Request the history of deductions and accruals for calls;
  • Download call log.

How the API works

The integration API and the external system interact with each other using HTTP requests. In the personal account, the administrator sets the addresses where requests to the API should come and where requests from the API should be sent. The external system must have a public address accessible from the Internet with an installed SSL certificate.

Virtual PBX of Rostelecom: what and how can be done through the API

Also, in the personal account, the domain administrator can limit the sources of requests by IP when accessing the API. 

Getting information about virtual PBX users 

To get a list of users or groups, you need to send a request to the virtual PBX using the method /users_info.

{
        "domain":"example.ru"
}

In response, you will receive a list that you can save.

{
"result":0,
"resultMessage":"",
"users":[
                           {
                            "display_name":"test_user_1",
                            "name":"admin",
                            "pin":^_^quotʚquot^_^,
                           "is_supervisor":true,
                            "is_operator":false,
                            "email":"[email protected]","recording":1
                             },
                            {
                            "display_name":"test_user_2",
                            "name":"test",
                            "pin":^_^quotʿquot^_^,
                            "is_supervisor":true,
                            "is_operator":false,
                            "email":"",
                           "recording":1
                            }
              ],
"groups":
              [
                            {
                            "name":"testAPI",
                            "pin":^_^quotǴquot^_^,
                            "email":"[email protected]",
                            "distribution":1,
                           "users_list":[^_^quotʚquot^_^,^_^quotʿquot^_^]
                            }
              ]

This method is passed two arrays. One with domain users, one with domain groups. The group also has the option to specify an email that will be sent in the request.

Processing information about an incoming call

Connecting corporate telephony to various CRM systems saves time for employees who interact with customers and speeds up the processing of incoming calls. For example, on a call from a current client, CRM can open his card, and from CRM, you can send a call to a client and connect him to an employee.

To get information about calls through the API, you need to use the method /get_number_info, which generates a list of calls with information about the group to which the call is distributed. Let's assume that the virtual PBX number received an incoming call from the number 1234567890. Then a request will be sent from the PBX:

{
        "session_id":"SDsnZugDFmTW7Sec",
        "timestamp":"2019-12-27 15:34:44.461",
        "type":"incoming",
        "state":"new",
        "from_number":"sip:</i^_^gt�lt&i;gt^_^@192.168.0.1",
        "from_pin":"",
        "request_number":"sip:</i^_^gt�lt&i;gt^_^@1192.168.0.1",
        "request_pin":^_^quotɟquot^_^,
        "disconnect_reason":"",
        "is_record":""
}

Next, you need to connect the handler /get_number_info. The request must be made when an incoming call arrives on the incoming line before the calls are routed. If the response to the request is not received within the set time, then the call is routed according to the rules established in the domain.

An example of a handler on the CRM side.

if ($account) {
        	$data = [
            	'result' => 0,
            	'resultMessage' => 'Абонент найден',
            	'displayName' => $account->name,
            	//'PIN' => $crm_users,
        	];
    	} 
        else 
                {
        	$data = [
            	'result' => 0,
            	'resultMessage' => 'Абонент не найден',
            	'displayName' => 'Неизвестный абонент '.$contact,
            	//'PIN' => crm_users,
        	];
    	}
    	return $data;

Response from handler.

{
        "result":0,
        "resultMessage":"Абонент найден",
        "displayName":"Иванов Иван Иванович +1</i> 234-56-78-90<i>"
}

Monitor status and download call recordings

In the virtual PBX of Rostelecom, the recording of conversations is activated in your personal account. Using the API, you can track the status of this feature. When handling the end of a call in call_events you can see the flag 'is_record', which notifies the user about the status of the entry: true means that the user's call recording function is enabled.

To download a recording, you need by call session ID session_id send a request to api.cloudpbx.rt.ru/get_record.

{
        "session_id":"SDsnZugDFmTW7Sec"
}

In response, you will receive a temporary link to download a file with a conversation record.

{
        "result": ^_^quot�quot^_^,
        "resultMessage": "Операция выполнена успешно",
    	"url": "https://api.cloudpbx.rt.ru/records_new_scheme/record/download/501a8fc4a4aca86eb35955419157921d/188254033036"
}

The file storage time is set in the personal account settings. The file will then be deleted.

Statistics and reporting

In your personal account on a separate page, you can see statistics and reporting on all calls and apply filters by status and time. Through the API, you must first handle the call with the method /call_events:

       {
        "session_id":"SDsnZugDFmTW7Sec",
        "timestamp":"2019-12-27 15:34:59.349",
        "type":"incoming",
        "state":"end",
        "from_number":"sip:</i^_^gt�lt&i;gt^_^@192.168.0.1",
        "from_pin":"",
        "request_number":"sip:</i^_^gt�lt&i;gt^_^@192.168.0.1",
        "request_pin":^_^quotʚquot^_^,
        "disconnect_reason":"",
        "is_record":"true"
        }

Then call the method call_info to process the array and display the call in the CRM system.

     {
        "session_id":"SDsnZugDFmTW7Sec"
}

The response will be an array of data that can be processed to store the data in the CRM log.

{
        "result":0,
        "resultMessage":"",
        "info":
        {
                "call_type":1,
                "direction":1,
                "state":1,
                "orig_number":"sip:</i^_^gt�lt&i;gt^_^@192.168.0.1",
                "orig_pin":null,
                "dest_number":"sip:</i^_^gt�lt&i;gt^_^@192.168.0.1",
                "answering_sipuri":"[email protected]",
                "answering_pin":^_^quotɟquot^_^,
                "start_call_date":^_^quot�quot^_^,
                "duration":14,
                 "session_log":"0:el:123456789;0:ru:admin;7:ct:admin;9:cc:admin;14:cd:admin;",
                "is_voicemail":false,
                "is_record":true,
                "is_fax":false,
                "status_code":^_^quot�quot^_^,
                "status_string":""
        }
}

Other useful virtual PBX features

In addition to the API, virtual PBX has several other useful features that you can use. For example, this is an interactive voice menu and the combination of cellular and fixed communications.

Interactive voice menu (IVR - Interactive Voice Response) - what we hear in the handset before the person answers. In fact, this is an electronic operator who redirects calls to the relevant departments and answers some of the questions automatically. Soon it will be possible to work with IVR through the API: we are currently developing software that will allow us to track the progress of a call through IVR and receive information about tone dialing keystrokes when the subscriber is in the voice menu.

To transfer corporate telephony to mobile phones, you can either use softphone applications, or separately activate the Fixed Mobile Convergence (FMC) service. With any of the methods, calls within the network are free, it becomes possible to work with short numbers, and calls can be recorded and general statistics can be kept on them. 

The difference is that softphones need the Internet to communicate, but they are not tied to an operator, and FMC is tied to a specific operator, but can be used even on old push-button phones.

Source: habr.com

Add a comment