Routing - Early Access
With Routing you can define business rules according to which incoming customer requests will be assigned to queues and agents for most effective resolution.
The rules are customizable and can refer to:
- message attributes such as channel, sender, receiver or message content
- customer attributes that you specified through Target module (e.g. – name, city, purchase power…)
- conversation tags assigned manually or through the automated Flow
Routing is a process of finding the right queue for new messages from where they can be further processed.
The new message is compared by each rule (expression) in routing and when the first rule match, the message is added to the matched queue. If no rule is matched, the message is not added to any queue.
Order of rules inside routing is important because the new message is compared to rule in a given order in routing to find the first match.
Based on logical operators, every expression can be constructed with at least one or more available operators in combination. Result of 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 inbound message first matches expression. Then the message will be assigned to the matched queue. Because processing order is crucial, only one opration (SET Routing) can set rules in appropriate order. To manage Routing setup over API the following methods are available:
Operators
Operators compare value and return the result of the operation (TRUE or FALSE) except AND and OR operator witch compare the result of other operation (TRUE or FALSE)
| Operator | Variable | Description |
|---|---|---|
| EQUALS | $eq | Compare two values, the searched value must be exact as a given value to return TRUE |
| NOT_EQUALS | $neq | Compare two values, the searched value must be different than the given value to return TRUE |
| LESS_THAN | $lt | Compare two values, the searched value must be less than the given value to return TRUE |
| LESS_THAN_EQUALS | $lte | Compare two values, the searched value must be less or equal given value to return TRUE |
| GREATER_THAN | $gt | Compare two values, the searched value must be greater than the given value to return TRUE |
| GREATER_THAN_EQUALS | $gte | Compare two values, the searched value must be greater or equal given value to return TRUE |
| AND | $and | Compare result of two operations, both must be TRUE to return TRUE |
| OR | $or | Compare result of two operations, one or both must be TRUE to return TRUE |
| IN | $in | Find given value within the searched value, if found, the result is TRUE |
| NIN | $nin | Return TRUE if provided value not found in searched value |
| ALLIN | $allin | Return TRUE if all array values are found ([1,2,3] $allin [1,2] would return true, [1,2,3] $allin [3,4] would return false) |
| ANYIN | $anyin | Return TRUE if any array value is found ([1,2,3] $anyin [1,20] would return true, [1,2,3] $anyin [4,7] would return false) |
| STARTS_WITH | $starts_with | Find given value in beginning searched value, if found, the result is TRUE |
Operands
| Message data | Type | Description |
|---|---|---|
| from | string | Represents sender ID and it can be alphanumeric or numeric. Alphanumeric sender ID length should be between 3 and 11 characters (example: CompanyName). Numeric sender ID length should be between 3 and 14 characters. |
| to | string | Message destination addresses. Destination addresses must be in international format (example: 41793026727) or FacebookId. |
| content | string | Text of the inbound message. Content limits are channel dependent. See length info for SMS. 1000 characters max. |
| channel | string | Available channels are: SMS, VIBER, FACEBOOK_MESSENGER, WHATSAPP. |
Customer data is optional data but relevant only if you are using People service. More information about customer data that can be used as operands can be found here under Body parameters section.
Query
Expression can be single compare operation or complex compare operations.
Single Query
A single query is a simple expression containing only one compare operator.
Next example target is to route all messages start with the key word.
"name": "Keyword STOP",
"queueId": "1E54701F74BD86A070B43DB49478D82C",
"priority": "NORMAL",
"enabled": true,
"expression": {
"$starts_with": {
"message.content": "STOP"
}
}
If message content is "STOP BOTHERING ME", the result is TRUE (operator $start_with) because message content starts with word "STOP" and message will be routed to queue name: "Keyword STOP".
"name": "Keyword STOP",
"queueId": "1E54701F74BD86A070B43DB49478D82C",
"priority": "NORMAL",
"enabled": true,
"expression": {
"$in": {
"message.content": "STOP"
}
}
The equal result can be achieved with this expression (operator $in). Word "STOP" is contained in the message content. Different than previous, this will also return TRUE if message content is "PLEASE STOP BOTHERING ME".
Complex Query
For more complex query, AND and OR operator can be used to combine multiple compare operation results. Next example target is to route messages with the phone number from the Croatian network operator and received on any channel except Facebook Messenger.
"name": "Croatian Support",
"queueId": "04FAFF86C252478D324CF3F980799C9E",
"priority": "NORMAL",
"enabled": true,
"expression": {
"$and": [
{
"$starts_with": {
"message.customerNumber": "385"
}
},
{
"$neq": {
"message.channel": "FACEBOOK_MESSENGER"
}
}
]
}
Here operator $and require to both conditions must be TRUE. The first condition is $start_with customer number must start with 385 what means that is Croatian operator network number. The second operator is $neq require message channel is not FACEBOOK_MESSENGER. So, every message from Croatian operator and send from any channel different than Facebook Messenger, the message will be routed to the queue name: "Croatian Support".