ACR Schema¶
ACR (Advanced Call Routing) JSON Schema - routes call that match configured rules. ACR Schemes are separated in two different route for different kinds of calls:
Default Route handles calls originating from internal extensions.
Public Route handles calls originating from the public phone network (PSTN).
Default Route¶
{
"destination_number": "^\\+?3?8?(044\\d{7})$",
"order": 1,
"name": "Kyiv",
"domain": "webitel.ua",
"fs_timezone" : "Europe/Kiev",
"callflow": [
{
"setVar": [
"effective_callee_id_number=380442228392",
]
},
{
"recordSession": "start"
},
{
"bridge": {
"endpoints": [
{
"type": "sipGateway",
"name": "kyiv",
"dialString": "$1"
}
]
}
}
]
}
Public Route¶
{
"destination_number": [
"442228392",
"74997045627"
],
"domain": "webitel.ua",
"fs_timezone" : "Europe/Kiev",
"callflow": [
{
"httpRequest": {
"url": "https://sales.it-sfera.com/0/ServiceModel/GetCallerOwnerService.svc/GetCallerOwner"
}
},
{
"if": {
"expression": "${owner_caller_id_number}",
"then": [
{
"answer": "183"
},
{
"recordSession": "start"
},
{
"bridge": {
"endpoints": [
{
"name": "${owner_caller_id_number}",
"type": "user",
"parameters": [
"leg_timeout=10"
]
}
]
}
}
]
}
},
{
"goto": "default:100"
}
]
}
Time of Day Routing¶
Time of day routing allows calls to be executed different applications based upon the time of day, day of week. You can use it in the different Conditional Statements.
By default, time-based routing uses the UTC timezone. See: The Timezone Table.
- &minute_of_day(minutes)¶
- Arguments
minutes (string) – Minute of the day, (1-1440) (midnight = 1, 1am = 60, noon = 720, etc.).
- Returns
true, false or the minute of the day if there are no parameters
- &time_of_day(08:00-17:00)¶
- Arguments
time (string) – Time range formatted: hh:mm[:ss]-hh:mm[:ss] (seconds optional).
- Returns
true, false or the time of the day if there are no parameters
- &minute(minutes)¶
- Arguments
minutes (string) – Minute (of the hour), 0-59.
- Returns
true, false or the minutes of the hour if there are no parameters
- &hour(houres)¶
- Arguments
houres (string) – Hour, 0-23.
- Returns
true, false or the hour of the day if there are no parameters
- &wday(wdays)¶
- Arguments
wdays (string) – Day of week, 1-7 (Sun = 1, Mon = 2, etc.) or “sun”, “mon”, “tue”, etc.
- Returns
true, false or the day of the week if there are no parameters
- &mweek(mweeks)¶
- Arguments
mweeks (string) – Week of month, 1-6.
- Returns
true, false or the week of the month if there are no parameters
- &week(weeks)¶
- Arguments
weeks (string) – Week of year, 1-53.
- Returns
true, false or the week of the year if there are no parameters
- &mday(mdays)¶
- Arguments
mdays (string) – Day of month, 1-31.
- Returns
true, false or the day of the month if there are no parameters
- &mon(m)¶
- Arguments
m (string) – Month, 1-12 (Jan = 1, etc.).
- Returns
true, false or the month if there are no parameters
- &yday(d)¶
- Arguments
d (string) – Day of year, 1-366.
- Returns
true, false or the day of the year if there are no parameters
- &year(y)¶
- Arguments
y (string) – Calendar year, 0-9999.
- Returns
true, false or the year if there are no parameters
Example code:
{
"if": {
"expression": "&hour(18-20) && &wday(2-6)",
"then": [
{
"setVar": "time_now=&time_of_day()"
}
]
}
}
Conditional Statements¶
In the ACR Schema we have the following conditional statements:
Use if … then to specify a block of code to be executed, if a specified condition is true
Use else to specify a block of code to be executed, if the same condition is false
Use switch to specify many alternative blocks of code to be executed
Use exists to determine whether the given resource exists or not
You may use any variable setted by setVar
application, Time of Day Routing or build-in Channel variables.
if¶
{
"if": {
"expression": "${myVar} != ''",
"then": [],
"else": []
}
}
expression
- The condition of if statements should always result in either true or false.then
- If the result is true, immediate then block would be executed.else
- If the result is false, immediate else block would be executed.
switch¶
[
{
"switch": {
"variable": "${IVR}",
"case": {
"1": [],
"2": [],
"3": [],
"default": []
}
}
}
]
variable
- Variable for cases.case
- The value of the variable is compared with the values of each case.default
- The block of the applications that would be executed if the given value is not matched with any of the pre-defined values.
exists¶
- &exists(resource, name)¶
- Arguments
resource (string) – media, account, queue or dialer
name (string) – the resource name
- Returns
true, false
For parameter descriptions see exists
application.
{
"if": {
"expression": "&exists(account, 1000)",
"then": [
{
"bridge": {
"endpoints": [
{
"name": "1000",
"type": "user"
}
]
}
}
]
}
}
For more information go to the Callflow Applications page.