curl --request PUT \
--url https://api.messaging.phonovation.com/ccaas/1/routing \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
[
[
{
"priority": "URGENT",
"queueId": "448bf76d-0047-49a3-93a4-ea8722d6aeaa",
"enabled": true,
"name": "First Rule",
"routeOnlyDuringWorkingHours": true,
"expression": {
"$or": [
{
"$eq": {
"message.channel": "WHATSAPP"
}
},
{
"$eq": {
"message.channel": "LIVE_CHAT"
}
}
]
}
},
{
"priority": "HIGH",
"queueId": "448bf76d-0047-49a3-93a4-ea8722d7aeab",
"enabled": true,
"name": "Second Rule",
"routeOnlyDuringWorkingHours": false,
"expression": {
"$and": [
{
"$eq": {
"message.channel": "TELEGRAM"
}
},
{
"$eq": {
"customer.country": "Croatia"
}
}
]
}
},
{
"priority": "NORMAL",
"queueId": "39b52b7f-db13-4c47-9b6e-de2ba91df62g",
"queueName": "Third Queue",
"enabled": true,
"name": "Third Rule",
"routeOnlyDuringWorkingHours": false,
"expression": {
"$eq": {
"message.channel": "VIBER"
}
}
}
]
]
'import requests
url = "https://api.messaging.phonovation.com/ccaas/1/routing"
payload = [[
{
"priority": "URGENT",
"queueId": "448bf76d-0047-49a3-93a4-ea8722d6aeaa",
"enabled": True,
"name": "First Rule",
"routeOnlyDuringWorkingHours": True,
"expression": { "$or": [{ "$eq": { "message.channel": "WHATSAPP" } }, { "$eq": { "message.channel": "LIVE_CHAT" } }] }
},
{
"priority": "HIGH",
"queueId": "448bf76d-0047-49a3-93a4-ea8722d7aeab",
"enabled": True,
"name": "Second Rule",
"routeOnlyDuringWorkingHours": False,
"expression": { "$and": [{ "$eq": { "message.channel": "TELEGRAM" } }, { "$eq": { "customer.country": "Croatia" } }] }
},
{
"priority": "NORMAL",
"queueId": "39b52b7f-db13-4c47-9b6e-de2ba91df62g",
"queueName": "Third Queue",
"enabled": True,
"name": "Third Rule",
"routeOnlyDuringWorkingHours": False,
"expression": { "$eq": { "message.channel": "VIBER" } }
}
]]
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)using RestSharp;
var options = new RestClientOptions("https://api.messaging.phonovation.com/ccaas/1/routing");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "<api-key>");
request.AddJsonBody("[\n [\n {\n \"priority\": \"URGENT\",\n \"queueId\": \"448bf76d-0047-49a3-93a4-ea8722d6aeaa\",\n \"enabled\": true,\n \"name\": \"First Rule\",\n \"routeOnlyDuringWorkingHours\": true,\n \"expression\": {\n \"$or\": [\n {\n \"$eq\": {\n \"message.channel\": \"WHATSAPP\"\n }\n },\n {\n \"$eq\": {\n \"message.channel\": \"LIVE_CHAT\"\n }\n }\n ]\n }\n },\n {\n \"priority\": \"HIGH\",\n \"queueId\": \"448bf76d-0047-49a3-93a4-ea8722d7aeab\",\n \"enabled\": true,\n \"name\": \"Second Rule\",\n \"routeOnlyDuringWorkingHours\": false,\n \"expression\": {\n \"$and\": [\n {\n \"$eq\": {\n \"message.channel\": \"TELEGRAM\"\n }\n },\n {\n \"$eq\": {\n \"customer.country\": \"Croatia\"\n }\n }\n ]\n }\n },\n {\n \"priority\": \"NORMAL\",\n \"queueId\": \"39b52b7f-db13-4c47-9b6e-de2ba91df62g\",\n \"queueName\": \"Third Queue\",\n \"enabled\": true,\n \"name\": \"Third Rule\",\n \"routeOnlyDuringWorkingHours\": false,\n \"expression\": {\n \"$eq\": {\n \"message.channel\": \"VIBER\"\n }\n }\n }\n ]\n]", false);
var response = await client.PutAsync(request);
Console.WriteLine("{0}", response.Content);
HttpResponse<String> response = Unirest.put("https://api.messaging.phonovation.com/ccaas/1/routing")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("[\n [\n {\n \"priority\": \"URGENT\",\n \"queueId\": \"448bf76d-0047-49a3-93a4-ea8722d6aeaa\",\n \"enabled\": true,\n \"name\": \"First Rule\",\n \"routeOnlyDuringWorkingHours\": true,\n \"expression\": {\n \"$or\": [\n {\n \"$eq\": {\n \"message.channel\": \"WHATSAPP\"\n }\n },\n {\n \"$eq\": {\n \"message.channel\": \"LIVE_CHAT\"\n }\n }\n ]\n }\n },\n {\n \"priority\": \"HIGH\",\n \"queueId\": \"448bf76d-0047-49a3-93a4-ea8722d7aeab\",\n \"enabled\": true,\n \"name\": \"Second Rule\",\n \"routeOnlyDuringWorkingHours\": false,\n \"expression\": {\n \"$and\": [\n {\n \"$eq\": {\n \"message.channel\": \"TELEGRAM\"\n }\n },\n {\n \"$eq\": {\n \"customer.country\": \"Croatia\"\n }\n }\n ]\n }\n },\n {\n \"priority\": \"NORMAL\",\n \"queueId\": \"39b52b7f-db13-4c47-9b6e-de2ba91df62g\",\n \"queueName\": \"Third Queue\",\n \"enabled\": true,\n \"name\": \"Third Rule\",\n \"routeOnlyDuringWorkingHours\": false,\n \"expression\": {\n \"$eq\": {\n \"message.channel\": \"VIBER\"\n }\n }\n }\n ]\n]")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.messaging.phonovation.com/ccaas/1/routing",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
[
[
'priority' => 'URGENT',
'queueId' => '448bf76d-0047-49a3-93a4-ea8722d6aeaa',
'enabled' => true,
'name' => 'First Rule',
'routeOnlyDuringWorkingHours' => true,
'expression' => [
'$or' => [
[
'$eq' => [
'message.channel' => 'WHATSAPP'
]
],
[
'$eq' => [
'message.channel' => 'LIVE_CHAT'
]
]
]
]
],
[
'priority' => 'HIGH',
'queueId' => '448bf76d-0047-49a3-93a4-ea8722d7aeab',
'enabled' => true,
'name' => 'Second Rule',
'routeOnlyDuringWorkingHours' => false,
'expression' => [
'$and' => [
[
'$eq' => [
'message.channel' => 'TELEGRAM'
]
],
[
'$eq' => [
'customer.country' => 'Croatia'
]
]
]
]
],
[
'priority' => 'NORMAL',
'queueId' => '39b52b7f-db13-4c47-9b6e-de2ba91df62g',
'queueName' => 'Third Queue',
'enabled' => true,
'name' => 'Third Rule',
'routeOnlyDuringWorkingHours' => false,
'expression' => [
'$eq' => [
'message.channel' => 'VIBER'
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}const options = {
method: 'PUT',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify([
[
{
priority: 'URGENT',
queueId: '448bf76d-0047-49a3-93a4-ea8722d6aeaa',
enabled: true,
name: 'First Rule',
routeOnlyDuringWorkingHours: true,
expression: {
$or: [
{$eq: {'message.channel': 'WHATSAPP'}},
{$eq: {'message.channel': 'LIVE_CHAT'}}
]
}
},
{
priority: 'HIGH',
queueId: '448bf76d-0047-49a3-93a4-ea8722d7aeab',
enabled: true,
name: 'Second Rule',
routeOnlyDuringWorkingHours: false,
expression: {
$and: [{$eq: {'message.channel': 'TELEGRAM'}}, {$eq: {'customer.country': 'Croatia'}}]
}
},
{
priority: 'NORMAL',
queueId: '39b52b7f-db13-4c47-9b6e-de2ba91df62g',
queueName: 'Third Queue',
enabled: true,
name: 'Third Rule',
routeOnlyDuringWorkingHours: false,
expression: {$eq: {'message.channel': 'VIBER'}}
}
]
])
};
fetch('https://api.messaging.phonovation.com/ccaas/1/routing', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"statusCode": "SUCCESS",
"message": "Routing added successfully."
}{
"requestError": {
"serviceException": {
"messageId": "BAD_REQUEST",
"text": "Invalid request body."
}
}
}{
"requestError": {
"serviceException": {
"messageId": "UNAUTHORIZED",
"text": "Unauthorized"
}
}
}{
"requestError": {
"serviceException": {
"messageId": "FORBIDDEN",
"text": "Forbidden"
}
}
}{
"requestError": {
"serviceException": {
"messageId": "GENERAL_ERROR",
"text": "Something went wrong. Please contact support."
}
}
}Create routing
Create routing method creates a new routing setup if it does not exist or replaces the existing setup. As rules inside routing are stored, executed, and retrieved in the provided order with this method, that order cannot be changed. Every expression within routing can be constructed with at least one or more available operators. The result of the expression will be a success (TRUE) only if all results of operations are TRUE. The query will be executed, one expression after another, in the order they are submitted until new a inbound message first matches the expression. Then the message will be assigned to the matched queue.
The order of rules inside routing is essential for proper routing, as rules match in the provided order. The first rule matching the message will be used. More info
Required scope: Enable one of: conversations:manage.
curl --request PUT \
--url https://api.messaging.phonovation.com/ccaas/1/routing \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
[
[
{
"priority": "URGENT",
"queueId": "448bf76d-0047-49a3-93a4-ea8722d6aeaa",
"enabled": true,
"name": "First Rule",
"routeOnlyDuringWorkingHours": true,
"expression": {
"$or": [
{
"$eq": {
"message.channel": "WHATSAPP"
}
},
{
"$eq": {
"message.channel": "LIVE_CHAT"
}
}
]
}
},
{
"priority": "HIGH",
"queueId": "448bf76d-0047-49a3-93a4-ea8722d7aeab",
"enabled": true,
"name": "Second Rule",
"routeOnlyDuringWorkingHours": false,
"expression": {
"$and": [
{
"$eq": {
"message.channel": "TELEGRAM"
}
},
{
"$eq": {
"customer.country": "Croatia"
}
}
]
}
},
{
"priority": "NORMAL",
"queueId": "39b52b7f-db13-4c47-9b6e-de2ba91df62g",
"queueName": "Third Queue",
"enabled": true,
"name": "Third Rule",
"routeOnlyDuringWorkingHours": false,
"expression": {
"$eq": {
"message.channel": "VIBER"
}
}
}
]
]
'import requests
url = "https://api.messaging.phonovation.com/ccaas/1/routing"
payload = [[
{
"priority": "URGENT",
"queueId": "448bf76d-0047-49a3-93a4-ea8722d6aeaa",
"enabled": True,
"name": "First Rule",
"routeOnlyDuringWorkingHours": True,
"expression": { "$or": [{ "$eq": { "message.channel": "WHATSAPP" } }, { "$eq": { "message.channel": "LIVE_CHAT" } }] }
},
{
"priority": "HIGH",
"queueId": "448bf76d-0047-49a3-93a4-ea8722d7aeab",
"enabled": True,
"name": "Second Rule",
"routeOnlyDuringWorkingHours": False,
"expression": { "$and": [{ "$eq": { "message.channel": "TELEGRAM" } }, { "$eq": { "customer.country": "Croatia" } }] }
},
{
"priority": "NORMAL",
"queueId": "39b52b7f-db13-4c47-9b6e-de2ba91df62g",
"queueName": "Third Queue",
"enabled": True,
"name": "Third Rule",
"routeOnlyDuringWorkingHours": False,
"expression": { "$eq": { "message.channel": "VIBER" } }
}
]]
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)using RestSharp;
var options = new RestClientOptions("https://api.messaging.phonovation.com/ccaas/1/routing");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "<api-key>");
request.AddJsonBody("[\n [\n {\n \"priority\": \"URGENT\",\n \"queueId\": \"448bf76d-0047-49a3-93a4-ea8722d6aeaa\",\n \"enabled\": true,\n \"name\": \"First Rule\",\n \"routeOnlyDuringWorkingHours\": true,\n \"expression\": {\n \"$or\": [\n {\n \"$eq\": {\n \"message.channel\": \"WHATSAPP\"\n }\n },\n {\n \"$eq\": {\n \"message.channel\": \"LIVE_CHAT\"\n }\n }\n ]\n }\n },\n {\n \"priority\": \"HIGH\",\n \"queueId\": \"448bf76d-0047-49a3-93a4-ea8722d7aeab\",\n \"enabled\": true,\n \"name\": \"Second Rule\",\n \"routeOnlyDuringWorkingHours\": false,\n \"expression\": {\n \"$and\": [\n {\n \"$eq\": {\n \"message.channel\": \"TELEGRAM\"\n }\n },\n {\n \"$eq\": {\n \"customer.country\": \"Croatia\"\n }\n }\n ]\n }\n },\n {\n \"priority\": \"NORMAL\",\n \"queueId\": \"39b52b7f-db13-4c47-9b6e-de2ba91df62g\",\n \"queueName\": \"Third Queue\",\n \"enabled\": true,\n \"name\": \"Third Rule\",\n \"routeOnlyDuringWorkingHours\": false,\n \"expression\": {\n \"$eq\": {\n \"message.channel\": \"VIBER\"\n }\n }\n }\n ]\n]", false);
var response = await client.PutAsync(request);
Console.WriteLine("{0}", response.Content);
HttpResponse<String> response = Unirest.put("https://api.messaging.phonovation.com/ccaas/1/routing")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("[\n [\n {\n \"priority\": \"URGENT\",\n \"queueId\": \"448bf76d-0047-49a3-93a4-ea8722d6aeaa\",\n \"enabled\": true,\n \"name\": \"First Rule\",\n \"routeOnlyDuringWorkingHours\": true,\n \"expression\": {\n \"$or\": [\n {\n \"$eq\": {\n \"message.channel\": \"WHATSAPP\"\n }\n },\n {\n \"$eq\": {\n \"message.channel\": \"LIVE_CHAT\"\n }\n }\n ]\n }\n },\n {\n \"priority\": \"HIGH\",\n \"queueId\": \"448bf76d-0047-49a3-93a4-ea8722d7aeab\",\n \"enabled\": true,\n \"name\": \"Second Rule\",\n \"routeOnlyDuringWorkingHours\": false,\n \"expression\": {\n \"$and\": [\n {\n \"$eq\": {\n \"message.channel\": \"TELEGRAM\"\n }\n },\n {\n \"$eq\": {\n \"customer.country\": \"Croatia\"\n }\n }\n ]\n }\n },\n {\n \"priority\": \"NORMAL\",\n \"queueId\": \"39b52b7f-db13-4c47-9b6e-de2ba91df62g\",\n \"queueName\": \"Third Queue\",\n \"enabled\": true,\n \"name\": \"Third Rule\",\n \"routeOnlyDuringWorkingHours\": false,\n \"expression\": {\n \"$eq\": {\n \"message.channel\": \"VIBER\"\n }\n }\n }\n ]\n]")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.messaging.phonovation.com/ccaas/1/routing",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
[
[
'priority' => 'URGENT',
'queueId' => '448bf76d-0047-49a3-93a4-ea8722d6aeaa',
'enabled' => true,
'name' => 'First Rule',
'routeOnlyDuringWorkingHours' => true,
'expression' => [
'$or' => [
[
'$eq' => [
'message.channel' => 'WHATSAPP'
]
],
[
'$eq' => [
'message.channel' => 'LIVE_CHAT'
]
]
]
]
],
[
'priority' => 'HIGH',
'queueId' => '448bf76d-0047-49a3-93a4-ea8722d7aeab',
'enabled' => true,
'name' => 'Second Rule',
'routeOnlyDuringWorkingHours' => false,
'expression' => [
'$and' => [
[
'$eq' => [
'message.channel' => 'TELEGRAM'
]
],
[
'$eq' => [
'customer.country' => 'Croatia'
]
]
]
]
],
[
'priority' => 'NORMAL',
'queueId' => '39b52b7f-db13-4c47-9b6e-de2ba91df62g',
'queueName' => 'Third Queue',
'enabled' => true,
'name' => 'Third Rule',
'routeOnlyDuringWorkingHours' => false,
'expression' => [
'$eq' => [
'message.channel' => 'VIBER'
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}const options = {
method: 'PUT',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify([
[
{
priority: 'URGENT',
queueId: '448bf76d-0047-49a3-93a4-ea8722d6aeaa',
enabled: true,
name: 'First Rule',
routeOnlyDuringWorkingHours: true,
expression: {
$or: [
{$eq: {'message.channel': 'WHATSAPP'}},
{$eq: {'message.channel': 'LIVE_CHAT'}}
]
}
},
{
priority: 'HIGH',
queueId: '448bf76d-0047-49a3-93a4-ea8722d7aeab',
enabled: true,
name: 'Second Rule',
routeOnlyDuringWorkingHours: false,
expression: {
$and: [{$eq: {'message.channel': 'TELEGRAM'}}, {$eq: {'customer.country': 'Croatia'}}]
}
},
{
priority: 'NORMAL',
queueId: '39b52b7f-db13-4c47-9b6e-de2ba91df62g',
queueName: 'Third Queue',
enabled: true,
name: 'Third Rule',
routeOnlyDuringWorkingHours: false,
expression: {$eq: {'message.channel': 'VIBER'}}
}
]
])
};
fetch('https://api.messaging.phonovation.com/ccaas/1/routing', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"statusCode": "SUCCESS",
"message": "Routing added successfully."
}{
"requestError": {
"serviceException": {
"messageId": "BAD_REQUEST",
"text": "Invalid request body."
}
}
}{
"requestError": {
"serviceException": {
"messageId": "UNAUTHORIZED",
"text": "Unauthorized"
}
}
}{
"requestError": {
"serviceException": {
"messageId": "FORBIDDEN",
"text": "Forbidden"
}
}
}{
"requestError": {
"serviceException": {
"messageId": "GENERAL_ERROR",
"text": "Something went wrong. Please contact support."
}
}
}Authorizations
This is the most secure authorization type and the one with the most flexibility.
API keys can be generated by calling the dedicated API method. Furthermore, API keys can have a limited scope and cover only some API methods. Lastly, they can be revoked at any time. This range of possibilities makes API keys well suited for separating the API access rights across multiple applications or use cases. Finally, the loss of an API key is easily manageable.
You can manage your API keys from GUI, or programmatically with dedicated API.
API key Authorization header example:
Authorization: App 003026bbc133714df1834b8638bb496e-8f4b3d9a-e931-478d-a994-28a725159ab9
Body
Queue Id is a destination queue where the new message will be assigned to.
255Conversation priority.
URGENT, HIGH, NORMAL, LOW Enabled is a boolean value (TRUE, FALSE), so the rule is engaged or avoided in the routing process. If not provided will be set to default.
Rule name, light description of expression logic.
255When set to true, it indicates that the route should only be processed during designated working hours. Set up working hours