The CLI rules can change call detail records. Each part of a call detail record is called a field. There are many fields (e.g. extension, number, username, trunk, etc.) in a record. Only some of them can be changed.
CLI rules consist of the following parts:
- Field to check
- Type of match
- Value1 to look for
- Action
- Value2
- Stop
- Direction
- Field to check - the field to be matched, a rule can only have one field. Values are:
EXTENSION - match on extension
NUMBER - match on number
TRUNK - match on trunk - Type of match - how the rule will find the records to change
STARTS WITH - match if the field starts with value1
ENDS WITH - match if the field ends with value1
CONTAINS - match if the field contains value1
DOES NOT CONTAIN - match if the field does not contain value1
ALWAYS MATCH - rules with this type of match execute for every record
LENGTH GREATER THAN - if the field length is greater than value1 - value1 is a number in the range 0 to 255
LGT - short for LENGTH GREATER THAN
LENGTH LESS THAN - if the field length is less than value1 - value1 is a number in the range 0 to 255
LLT – short for LENGTH LESS THAN - Value1 to look for - what is matched or not matched or the length, depending on the type of match
- Action what to do when the Value1 Matches
IGNORE - makes no modifications - you can use ignore with action "STOP" set to "TRUE" to do nothing and stop other rules from processing.
REPLACE WITH - replaces the matched value with value2.
REPLACEWITH - same as "REPLACE WITH"
REPLACEALL - replaces all occurrences of value1 with value2, usually used with match "CONTAINS" or "ALWAYS MATCH"
REPLACEFIELD - replaces the entire field with value2.
DELETE - removes the matched value (value2 is not used).
DELETECOUNT - deletes x number of characters starting at the matched position. value2 is the number x.
DELETEALL - clears the entire field (value2 is not used) - same as REPLACEFIELD with nothing in value2.
DELETEBEFORE - deletes x characters before the match. Value2 is the number x. x can be larger than the number of characters before the match. For example, a rule to delete 8 characters before the hash from "01234#0215924033" would delete only the first 5 before the hash. Note that the # would be left in the field. DELETECOUNT is the corresponding DELETEAFTER action – use “DELETECOUNT” and not “DELETEAFTER”.
ADD TO START - adds value2 in front of the field. Note that the matched position does not matter.
ADD TO END - adds value2 after the field. Note that the matched position does not matter.
DELETERECORD - instructs the software to delete this record. Usually the software will log this.
REJECT - instructs the software to reject this record. Usually the software will log this.
PREFIX - same as ADD TO START, but the value prefixed can be from a lookup table if value2 = "<lookup>". Value1 will be used as the key to the lookup, and the result from the lookup will be prefixed to the field. - Value2 - what to use as replacement / add / count / prefix / suffix.
- Stop - if TRUE, when this rule matches, the rules after this will not process. Values can be:
TRUE
FALSE - Direction - will only match records that have the matching direction. Values can be:
INCOMING
OUTGOING
ANY
Examples
0=EXTENSION|STARTS WITH|27319293700|REPLACE WITH|0319293700|TRUE|ANY|
1=EXTENSION|STARTS WITH|319293700|REPLACE WITH|0319293700|TRUE|ANY|
2=Number|starts with|00|REPLACE|0|False|OUTGOING|
3=Extension|length less than|3|reject||False|ANY|
4=Extension|length greater than|5|reject||False|ANY|
5=Extension|starts with|*|reject||False|ANY|
6=Extension|starts with|0|reject||False|ANY|