How to configure the integration with your system via Ringostat API

Ringostat API (application program interface) is a set of routines, protocols, and tools for building software applications. It is possible to use them for setting the integration of your project in Ringostat with your CRM or another system.

Using this method you can send the requests to our server for getting the required action or data from it.

To configure the integration with your system via API method you should set the request with the required parameters.

The main details for the requests:

  1. Ringostat API address - https://api.ringostat.net/
  2. Access to Ringostat API you can get with unique Auth-key.

Auth-key is an electronic key to access your project in Ringostat.

How to find Auth-key:


You may find it the integration section: Integration -> Ringostat API.


Import of statistics from Call log

Required parameters for the request:

Parameters, you can export from your project statistics.

Examples:

  1. Node.js:

const https = require('https');
const config = {
	host: 'api.ringostat.net',
	path: '/calls/list?export_type=json&from=2019-06-01%2000:00:00&to=2019-06-18%2023:59:59­&fields=calldate,caller,dst,disposition,billsec,utm_source,utm_medium,recording',
	method: 'GET',
	headers: {
		'Content-Type': 'application/json',
		'Auth-key': 'unique_auth_key_value'
	}
};
const callback = response => {
	let result = Buffer.alloc(0);
	response.on('data', chunk => {
		result = Buffer.concat([ result, chunk ]);
	});
	response.on('end', () => {
		//handle response
	})
};
const request = https.request(config, callback);
request.end();

2. Axios.js:

const axios = require('axios');
axios({
	url: 'https://api.ringostat.net/calls/list',
	method: 'GET',
	headers: {
		'Content-Type': 'application/json; charset=utf-8',
		'Auth-key': 'unique_auth_key_value'
	},
	params: JSON.stringify({
		'export_type': 'json',
		'from': '2019-06-01 00:00:00',
		'to': '2019-06-18 23:59:59',
		'fields': 'calldate,caller,dst,disposition,billsec,utm_source,utm_medium,recording'
	})
}).then(response => {
	//handle response
}).catch(error => {
	//handle error
})

3. cURL:

curl "https://api.ringostat.net/calls/list?export_type=json&from=2019-06-01 00:00:00&to=2019-06-18 23:59:59&fields=calldate,caller,dst,disposition,billsec,utm_source,utm_medium,recording" \
-H "Content-Type: application/json" \
-H "Auth-key: unique_auth_key_value"

Result:


The callback methods:

1. To set a callback to the visitor, who filled up the form on your web page you’ll need (simple method):

Required parapemeters for the request:

  • API-request address: https://api.ringostat.net/callback/outward_call
  • Method of the API request — POST;
  • Auth-key is an electronic key to access your project in Ringostat.
  • Extension - a phone number in the international format you want to make a call from.
  • Destination - a phone number (in the international format) or SIP-account you are going to call to.

Node.js request example:

const https = require('https);
const config = {
	host: 'api.ringostat.net',
	path: '/callback/outward_call',
	method: 'POST',
	headers: {
		'Content-Type': 'application/x-www-form-urlencoded',
		'Auth-key': 'unique_auth_key_string'
	}
};
const callback = response => {
	let result = Buffer.alloc(0);
	response.on('data', chunk => {
		result = Buffer.concat([ result, chunk ]);
	});
	response.on('end', () => {
		//handler response
	});
};
const request = https.request(config, callback);
const body = `extension=380441112233&destination=380671112233`;
request.write(body);
request.end();


Axios.js request example:

axios({
	url: 'https://api.ringostat.net/callback/outward_call',
	method: 'POST',
	headers: {
		'Content-Type': 'application/json; charset=utf-8',
		'Auth-key': 'unique_auth_key_string'
	},
	data: JSON.stringify({
		'extension': '380441112233',
		'destination': '380671112233'
	})
}).then(response =>  {
	//handle response
}).catch(error => {
	//handle error
})

_cURL request example:

curl "https://api.ringostat.net/callback/outward_call" \
-X POST \
-d "extension=380441112233&destination=380671112233" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Auth-key: unique_auth_key_string"

2. In case you’d like to set the same callback to your visitor but from the number, which is not connected to the project, you should use the expanded method for the callback via API.

  • API-request address: https://api.ringostat.net/a/v2
  • Method of the API request — POST;
  • Auth-key is an electronic key to access your project in Ringostat.
  • content-type: application/json
  • clientIP — you may set real or non-real IP address.
  • caller — a phone number or SIP-account you want to make a call from.
  • callee — a phone number or SIP-account, which should answer the call.
  • projectId — ID of your project in Ringostat.
Name of parameter Description
the headers of the request
content-type application/json
Auth-key "unique_auth_key_string"
body of the request
jsonrpc A protocole version.
Value: 2.0
id Any number which will be used for comparing the request and answer to it request
method Method of the request in Ringostat.
Value: Api\\V2\\Callback.external
params
callee_type Defines the direction type:
default – a phone number
scheme – call forwarding scheme
caller_type Defines the direction type:
default – a phone number
scheme – call forwarding scheme
caller A phone number or SIP-account of the caller
callee A phone number or SIP-account of the user your are calling
direction Type of the call:
in - inbound
out - outvound
(data format — string)
manager_dst The direction of the first call:
1 - agent
0 - client
clientIp IP-address of the visitor
utmSource utm-source parameter
utmMedium utm-medium parameter
utmCampaign utm-campaign parameter
utmTerm utm-term parameter
utmContent utm-comtecnt parameter
clientId Client ID Google Analytics
clientUserAgent Client's application

The call will be successful in case the title and the body of the request are correct. It also depends on the parameters caller and callee - they should be valid too.

To add the non-required parameters to the request you should eject them with your script. For example, utm-parameters can be ejected from the cookie-file rngst2, and the ClientID Google Analytics - from the cookie-file _ga.

Node.js request example:

const https = require('https');
const config = {
	host: 'api.ringostat.net',
	path: '/a/v2',
	method: 'POST',
	headers: {
		'Auth-key': 'unique_auth_key_string'
	}
};
const callback = response => {
	let result = Buffer.alloc(0);
	response.on('data', chunk => {
		result = Buffer.concat([ result, chunk ]);
	});
	response.on('end', () => {
		//handler response
	});
};
const request = https.request(config, callback);
const body = `{
	"jsonrpc": "2.0",
	"id": 777,
	"method": "Api\\V2\\Callback.external",
	"params": {
		"callee_type": "default",
		"caller_type": "default",
		"caller": "380671112233",
		"callee": "380632223344",
		"manager_dst": 1,
		"direction": "out",
		"projectId": "11111",
		"clientIp": "10.10.10.10",
		"utmSource": "ringostat",
		"utmMedium": "referral",
		"utmCampaign": "extended_callback",
		"utmTerm": "test_api_request",
		"utmContent": "content",
		"clientId": "111111111.2222222222",
		"clientUserAgent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"
	}
}`;
request.write(body);
request.end();


Axios.js request example:

axios({
	url: 'https://api.ringostat.net/a/v2',
	method: 'POST',
	headers: {
		'Content-Type': 'application/json; charset=utf-8',
		'Auth-key': 'unique_auth_key_string'
	},
	data: {
		"jsonrpc": "2.0",
		"id": 777,
		"method": "Api\\V2\\Callback.external",
		"params": {
			"callee_type": "default",
			"caller_type": "default",
			"caller": "380671112233",
			"callee": "380672223344",
			"manager_dst": 1,
			"direction": "out",
			"projectId": "11111",
			"clientIp": "10.10.10.10",
			"utmSource": "ringostat",
			"utmMedium": "referral",
			"utmCampaign": "extended_callback",
			"utmTerm": "test_api_request",
			"utmContent": "content",
			"clientId": "111111111.2222222222",
			"clientUserAgent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"
		}
	}
}).then(response =>  {
	//handle response
}).catch(error => {
	//handle error
})

_cURL request example:

curl "https://api.ringostat.net/a/v2"
-X POST \
-d "{
	\"jsonrpc\": \"2.0\",
	\"id\": 777,
	\"method\": \"Api\\V2\\Callback.external\",
	\"params\": {
		\"callee_type\": \"default\",
		\"caller_type\": \"default\",
		\"caller\": \"380671112233\",
		\"callee\": \"380672223344\",
		\"manager_dst\": 1,
		\"direction\": \"out\",
		\"projectId\": \"11111\",
		\"clientIp\": \"10.10.10.10\",
		\"utmSource\": \"ringostat\",
		\"utmMedium\": \"referral\",
		\"utmCampaign\": \"extended_callback\",
		\"utmTerm\": \"test_api_request\",
		\"utmContent\": \"content\",
		\"clientId\": \"111111111.2222222222\",
		\"clientUserAgent\": \"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36\"
	}
}" \
-H "Auth-key: unique_auth_key_string" \

The result which you’ll see in the Call log:

The errors you might have:

1. If the main parameters caller, callee, Auth-Key, clientIP were not valid and you might get the answer 403.

2. If the parameters caller or callee are not valid or empty and you might get the answer 400.

The methods which checks if the SIP-account is reachable:

This methods can be useful for monitoring quality of the agents' work and availability.

3.1. The method for monitoring the SIP-accounts which are online.

Required parameters for the request:

Node.js request example:

const https = require('https');
const config = {
	host: 'api.ringostat.net',
	path: '/sipstatus/online',
	method: 'GET',
	headers: {
		'Auth-key': 'unique_auth_key_string'
	}
};
const callback = response => {
	let result = Buffer.alloc(0);
	response.on('data', chunk => {
		result = Buffer.concat([ result, chunk ]);
	});
	response.on('end', () => {
		//handle response
	});
};
const request = https.request(config, callback);
request.end();


Axios.js request example:

axios({
	url: 'https://api.ringostat.net/sipstatus/online',
	method: 'GET',
	headers: {
		'Auth-key': 'unique_auth_key_string'
	}
}).then(response =>  {
	//handle response
}).catch(error => {
	//handle error
})

_cURL request example:

curl "https://api.ringostat.net/sipstatus/online" \
-H "Auth-key: unique_auth_key_string"

The result:

[
	"supportrngst_manager1",
	"supportrngst_manager2",
	"supportrngst_manager3",
	"supportrngst_manager4",
	"supportrngst_manager5",
	"supportrngst_manager6",
	"supportrngst_manager7"
]

3.2. The method for monitoring the SIP-account, which are participated in the call.

Required parameters for the request:

Node.js request example:

const https = require('https');
const config = {
	host: 'api.ringostat.net',
	path: '/sipstatus/speaking',
	method: 'GET',
	headers: {
		'Auth-key': 'unique_auth_key_string'
	}
};
const callback = response => {
	let result = Buffer.alloc(0);
	response.on('data', chunk => {
		result = Buffer.concat([ result, chunk ]);
	});
	response.on('end', () => {
		//handle response
	});
};
const request = https.request(config, callback);
request.end();


Axios.js request example:

axios({
	url: 'https://api.ringostat.net/sipstatus/speaking',
	method: 'GET',
	headers: {
		'Content-Type': 'application/json; charset=utf-8',
		'Auth-key': 'unique_auth_key_string'
	}
}).then(response =>  {
	//handle response
}).catch(error => {
	//handle error
})

_cURL request example:

curl "https://api.ringostat.net/sipstatus/speaking" \
-H "Auth-key: unique_auth_key_string"

The result:

[
	"supportrngst_manager2",
	"supportrngst_manager4",
	"supportrngst_manager5",
	"supportrngst_manager7"
]

In case you need any assistance feel free to contact our Support team via chat or through the email support@ringostat.com.

Is this article helpful?
0 0 0