Flow Operations
Introduction
Flow operation data structures are the key containers for flow representation. Flows are stored as JSON within the N2ACD PostgreSQL database.
Example Flow
An example JSON representation of a flow and its operations could be as follows:
{
"operations": {
"5": {
"id": 5,
"type": "Start",
"exits": [ 4 ]
},
"4": {
"id": 4,
"type": "LocationRouting",
"exits": [ 1, 2 ],
"config": {
"source_buffer": "Calling Party Number",
"geography_set": "Telephone Numbers",
"geography_set_customer_name": "Main Customer",
"default_exit_idx": 0,
"rules": [
{
"geography_entry": "Auckland 2",
"exit_idx": 1
},
{
"geography_entry": "Gisborne 6",
"exit_idx": 1
}
]
}
},
"2": {
"id": 2,
"type": "AttemptTerminate",
"exits": [ null ],
"config": {
"destinations": [ { "number": "032420002" } ]
}
},
"1": {
"id": 1,
"type": "AttemptTerminate",
"exits": [ null ],
"config": {
"destinations": [ { "number": "032420003" } ]
}
}
}
}
This represents a flow which performs geographic routing, and terminates to 032420002
for callers from Auckland or Gisborne, and 032420003 otherwise.
Operation Attributes
The operations object is a Hash of Operation Objects, keyed by the operation id.
All Operation Objects have the following parameters.
| Parameter | Type | Description |
|---|---|---|
id
|
Integer |
[Required] The numeric operation ID. This must match the Object's key in the operations hash.
|
type
|
String |
[Required] Name of the operation type, e.g. Start, Menu, etc.
|
exits
|
Array of Integer |
[Required] Array of all of the "next operation" IDs to which this operation is connected.
Indexes into this array should be zero-based. The Array element may also be null, which indicates that this exit leads to the
end of all processing. If the caller is still connected when this exit is taken,
the call will be disconnected.
|
config
|
Object |
Most Operation Objects will have a config object describing the particular configuration of
the operation instance. The structure of this object depends on the operation type.
|
Announcement Attributes
Several operations have announcements as part of their config structure. All announcement configuration
Objects have the following parameters:
| Parameter | Type | Description |
|---|---|---|
customer_name
|
String | [Required] Name of the customer that owns the announcement. |
entry
|
String | [Required] Name of the announcement, which must be an announcement configured for the specified customer. |
Pattern Matching
Several operations support pattern matching for validation of caller input. In all cases these patterns require Lua Pattern syntax.
The following character patterns are most often used in Lua pattern matching within N2ACD:
| Pattern | Contents |
|---|---|
%a |
Letters |
%l |
Lower case letters |
%u |
Upper case letters |
%d |
Digits |
%w |
Alphanumeric characters |
%x |
Hexadecimal digits |
%p |
Punctuation characters |
%s |
Space characters |
Some characters have special meanings in a pattern:
| Character | Contents |
|---|---|
( and ) |
Specify the start and stop of a capture group. |
. |
Matches any single character. |
+ |
Matches one or more occurrences of the previous pattern. |
* |
Matches zero or more occurrencs of the previous pattern. |
- |
As for *, but matches the shortest match possible. |
? |
Matches zero or one occurrences of the previous pattern. |
[ |
Specifies the start of a custom character class, and is terminated with ]. This class matches any of the characters in it as a pattern. |
^ |
Either used within a customer character class to invert the class, or used within a pattern to match the start of the string. |
$ |
Matches the end of the string. |
% |
Escape character for other special characters. |
Some examples of pattern matches are:
| Pattern | Description | Example Matches |
|---|---|---|
021 |
Match 021 exactly. |
021 |
0212* |
Match 021 followed by zero or more 2 digits. |
021021202122 |
(021)* |
Match zero or more of the entire group 021. |
<empty>021021021 |
[AB1-5]* |
Match zero or more A or B characters or digits within the range 1 to 5. |
<empty>53B212``B1234A543` |
[^AB1-5]* |
Match zero or more characters that are not A or B characters or digits within the range 1 to 5. |
<empty>F89768879D |
.* |
Match zero or more of any digit or character. | <empty>02123B022335 |
.*021 |
Match any number which ends in 012. | 02154321021 |
For further details, refer to the official Lua pattern matching documentation.