External Actions
External Actions Configuration
At the beginning of each IWF state, network sessions may require external actions to occur.
External processing rules can therefore be defined that allow other N2SVCD applications and features to be called as part of each pre-state handling. Rules are applied in the order listed and any match made is processed accordingly before proceeding with the remainder of the rule checking (if applicable). All external action rules will be checked for each session, regardless of any matches made.
If a rule does not specify any matching criteria, it will always match. Depending on the action called, this may impact performance of the system.
External processing rules are defined in the EXTERNAL_ACTIONS LogicApp service
global variable. Each of these rules must also refer to an external action type, defined in the EXTERNAL_ACTION_TYPES
LogicApp service global variable.
External Action Rules
The rules that determine which external action are triggered are defined in the EXTERNAL ACTIONS
global variable.
An example configuration might be:
<global name="EXTERNAL_ACTIONS" type="array">
<rule var="vlr" value="" external="ati_msisdn" mandatory="1" service.at_rating="1"/>
<rule normalised_calling_party_prefix="642" external="cug"/>
</global>
In addition to both the
standard rules engine
and N2IWF selector rule extensions, each rule in the
EXTERNAL ACTIONS global variable supports the following attributes:
| Attribute | Type | Description |
|---|---|---|
external |
String | [Required] The external action type to invoke when this rule is matched. |
mandatory |
Boolean | Whether this external action must complete successfully for the session to continue. If false, the session will be allowed to continue regardless of the external processing outcome. If true, error handling rules will be used to determine the session handling.(Default = false, continue on failure) |
Note that if none of the state selector rule extensions
service.at_setup, service.at_pre, service.at_rating, or service.at_post are specified, it is assumed that
the external action rule applies only at the pre-rating state, i.e. as if
service.at_pre were set to a truthy value.
External action rules do not have any default rules. If no rules apply, no external actions will be triggered.
External Action Types
The available external action types that can be applied by external action rules are defined in the
EXTERNAL_ACTION_TYPES global variable. An example external rule type configuration might be:
<global name="EXTERNAL_ACTION_TYPES" type="array">
<external name="cug" action="n2cug_lookup">
<user_number from_var="logical"/>
<match_number type="array">
<rule originating="1" source="normalised_called_party"/>
<rule source="normalised_calling_party"/>
</match_number>
<allow_match_sc type="array">
<rule originating="1" literal="1"/>
<rule literal="0"/>
</allow_match_sc>
<allow_sc_user type="array">
<rule originating="1" literal="0"/>
<rule literal="1"/>
</allow_sc_user>
<terminating type="array">
<rule originating="1" literal="0"/>
<rule literal="1"/>
</terminating>
<suppress_edr literal="0"/>
</external>
<external name="ati_msisdn" action="map_ati">
<gsm_scf_digits literal="6412345"/>
<hlr_gt_digits literal="642000001"/>
<hlr_ssn literal="6"/>
<hlr_timer_secs literal="1"/>
<msisdn_source from_var="logical"/>
<store_vlr literal="vlr"/>
</external>
</global>
Each external action type must specify the following parameters:
| Attribute | Type | Description |
|---|---|---|
name |
String | [Required] The name of the external action type, as referred to by external action rules. |
action |
String | [Required] The external action to apply. One of n2cug_lookup for performing an N2CUG lookup or map_ati/map_srism to send a MAP Message |
MAP Messages
Specifying the external action types map_ati or map_srism causes a MAP Any Time Interrogation or
Send Routing Information for Short Message operation, respectively, to be sent to an HLR in the network.
Such messages will return information about the subscriber’s mobile details and current location.
Both messages use MAP v3.
Using these external action requires N2SVCD MAP integration.
Parameters for MAP messages are listed below, as:
- Common parameters for all MAP message types.
- ATI parameters for MAP ATI messages only.
- SRI-SM parameters for MAP SRI-SM messages only.
Note that each parameter listed (except required) is an
N2SVCD rule engine ruleset
and that the N2IWF selector rule extensions apply.
If a successful response is received, the subscriber’s applicable details will be populated into the specified
variable(s) and/or
EXTERNAL EDR tag(s).
Common MAP Parameters
The following additional external action type parameters are available when specifying any MAP external action:
| Parameter | Type | Description |
|---|---|---|
hlr_sigtran_route |
String | The TCAP agent route to use when sending the MAP message. If not specified, the default route will be used. |
hlr_timer_secs |
Integer | The number of seconds to wait for a response from the HLR when sending MAP. (Default = 3.0). |
hlr_ri |
Integer | The Routing Indicator for routing the MAP message to the HLR. Possible values are:
0, route on Global Title). |
hlr_gt_digits |
Hex String | [Conditional] The destination SCCP Global Title for routing the MAP message to the HLR. Must be provided if hlr_ri is 0. |
hlr_gt_noa |
Integer | The destination SCCP Global Title Nature of Address for routing the MAP message to the HLR. Only applicable when hlr_ri is 0. Possible values are: <ul class="tablelist"> <li>0 - Unknown</li><li>1 - Subscriber Number</li><li>2 - Reserved (National)</li><li>3 - National Significant</li><li>4- International</li></ul>_(Default =4`, International)_. |
hlr_gt_np |
Integer | The destination SCCP Global Title Numbering Plan for routing the MAP message to the HLR. Only applicable when hlr_ri is 0. Possible values are:
1, ISDN/telephony). |
hlr_pc |
Integer | [Conditional] The destination SCCP Point Code for routing the MAP message to the HLR. Must be provided if hlr_ri is 1. |
hlr_gt_tt |
Integer | The destination SCCP Global Title Translation Type for routing the MAP message to the HLR. Only applicable when hlr_ri is 0. Refer to Q.713 for applicable values.(Default = 0). |
hlr_ssn |
Integer | The destination SCCP SubSystem Number for routing the MAP message to the HLR. Only applicable when hlr_ri is 1. Refer to Q.713 for applicable values.(Default = 7). |
source_noa |
Integer | The Nature of Address to set for the source MSISDN when sending requests to the HLR. Possible values are:
(Default = 1, International). |
source_npi |
Integer | The Number Plan Indicator to set for the source MSISDN when sending requests to the HLR. Possible values are:
(Default = 1, ISDN/telephony). |
optional |
Array of >String |
Which suffixes (e.g. vlr or sgsn) of the store_* fields are not required to be populated in order for the action to be considered successful. If empty or not specified, all fields are required to be populated in the response.(Default: empty, all store locations are required to be populated) |
MAP ATI Parameters
MAP ATI messages may be sent as external actions by specifying the external action typ map_ati.
An example MAP ATI external action configuration might be:
<global name="EXTERNAL_ACTION_TYPES" type="array">
<external name="ati_msisdn" action="map_ati">
<gsm_scf_digits literal="6412345"/>
<hlr_gt_digits literal="642000001"/>
<hlr_ssn literal="6"/>
<hlr_timer_secs literal="1"/>
<msisdn_source from_var="logical"/>
<store_vlr literal="vlr"/>
</external>
</global>
The following additional external action type parameters are available when sending an ATI:
| Parameter | Type | Description |
|---|---|---|
gsm_scf_digits |
Hex String | [Required] The GSM SCF ID digits of the N2IWF node (normally its SCCP Global Title). |
gsm_scf_noa |
Integer | The GSM SCF ID Nature of Address to use for the N2IWF for the gsm_scf_digits. Possible values are:
1, International). |
gsm_scf_npi |
Integer | The GSM SCF ID Number Plan Indicator to use for the N2IWF for the gsm_scf_digits. Possible values are:
1, ISDN/telephony). |
store_vlr |
String | [Conditional] The variable to store the received VLR in. At least one of store_vlr, store_mcc, or store_mnc must be specified. |
store_mcc |
String | [Conditional] The variable to store the received MCC in. At least one of store_vlr, store_mcc, or store_mnc must be specified. |
store_mnc |
String | [Conditional] The variable to store the received MNC in. At least one of store_vlr, store_mcc, or store_mnc must be specified. |
edr_vlr |
String | The EDR tag to write the stored VLR value to. No EDR update will occur unless both a VLR value is found and an EDR tag is defined. |
edr_mcc |
String | As for edr_vlr, but for the received MCC. |
edr_mnc |
String | As for edr_vlr, but for the received MNC. |
msisdn_source |
String | [Conditional] The selector rule field or variable to read the subscriber MSISDN to query from. One and only one of msisdn_source and imsi_source must be provided. |
imsi_source |
String | [Conditional] The selector rule field or variable to read the subscriber IMSI to query from. One and only one of msisdn_source and imsi_source must be provided. |
MAP SRI-SM Parameters
MAP SRI-SM messages may be sent as external actions by specifying the external action typ map_srism.
An example MAP SRI-SM external action configuration might be:
<global name="EXTERNAL_ACTION_TYPES" type="array">
<external name="sri_sm_imsi" action="map_srism">
<sca_digits literal="6412345"/>
<hlr_gt_digits literal="642000001"/>
<hlr_ssn literal="6"/>
<hlr_timer_secs literal="1"/>
<msisdn_source from_var="logical"/>
<store_imsi literal="sri_sm_imsi"/>
<edr_imsi literal="sri_sm_imsi"/>
<store_sgsn literal="sri_sm_sgsn"/>
<edr_sgsn literal="sri_sm_sgsn"/>
<optional>sgsn</optional>
</external>
</global>
The following additional external action type parameters are available when sending an SRI-SM:
| Parameter | Type | Description |
|---|---|---|
sca_digits |
Hex String | [Required] The Service Centre Address digits of the N2IWF node (normally its SCCP Global Title). |
sca_noa |
Integer | The Service Centre Address Nature of Address to use for the N2IWF for the sca_digits. Possible values and default are as for the MAP ATI parameter gsm_scf_noa. |
sca_npi |
Integer | The Service Centre Address Number Plan Indicator to use for the N2IWF for the sca_digits. Possible values and default are as for the MAP ATI parameter gsm_scf_npi. |
store_imsi |
String | [Conditional] The variable to store the received IMSI in. Note that this will also be stored as the subscriber’s IMSI if the lookup is successful. At least one of store_imsi, store_sgsn, or store_msc is required. |
store_sgsn |
String | [Conditional] The variable to store the received SGSN number in. At least one of store_imsi, store_sgsn, or store_msc is required. |
store_msc |
String | [Conditional] The variable to store the received MSC address in. At least one of store_imsi, store_sgsn, or store_msc is required. |
edr_imsi |
String | The EDR tag to write the stored IMSI value to. No EDR update will occur unless both an IMSI is found and an EDR tag is defined. |
edr_sgsn |
String | As for edr_imsi, but for the received SGSN number. |
edr_msc |
String | As for edr_imsi, but for the received MSC address. |
priority |
Boolean | The priority flag for the message. (Default = true, message has priority). |
N2CUG Lookup
Specifying the external processing action type n2cug_lookup causes a lookup to be done using the
N-Squared Closer User Groups library
framework.
Using this external action requires N2SVCD N2CUG integration.
An example N2CUG external action configuration might be:
<global name="EXTERNAL_ACTION_TYPES" type="array">
<external name="cug" action="n2cug_lookup">
<user_number from_var="logical"/>
<match_number type="array">
<rule originating="1" source="normalised_called_party"/>
<rule source="normalised_calling_party"/>
</match_number>
<allow_match_sc type="array">
<rule originating="1" literal="1"/>
<rule literal="0"/>
</allow_match_sc>
<allow_sc_user type="array">
<rule originating="1" literal="0"/>
<rule literal="1"/>
</allow_sc_user>
<terminating type="array">
<rule originating="1" literal="0"/>
<rule literal="1"/>
</terminating>
<suppress_edr literal="0"/>
</external>
</global>
The following additional external action type parameters are available when specifying an N2CUG lookup:
| Parameter | Type | Description |
|---|---|---|
user_number |
Hex String | [Required] The user number to use in the CUG lookup. |
match_number |
Hex String | [Required] The match number to use in the CUG lookup. |
allow_match_sc |
Boolean | Whether to allow the match number to be applied against short codes. (Default: true) |
allow_sc_user |
Boolean | Whether to allow the user number to be applied against short codes. (Default: false) |
terminating |
Boolean | Whether the session is considered to be a terminating leg or not. Note that this is used solely for statistics purposes and does not affect the lookup. (Default: false) |
suppress_edr |
Boolean | Whether to suppress N2CUG lookup EDRs. (Default: false) |
Note that each parameter is an N2SVCD rule engine ruleset and that the N2IWF selector rule extensions apply.
If a successful response is received, the lookup details will be populated into the field
service.cug as per a normal
N2CUG lookup.
Refer to the N2CUG lookup function documentation for further details.
REST Messages
Specifying the external action type rest causes an HTTP(S) REST message to be sent. Responses from the message may
be mapped to arbitrary variables.
An example REST external action configuration might be:
<global name="EXTERNAL_ACTION_TYPES" type="array">
<external name="rest_xml" action="rest">
<path>/subscriber/$logical$/check</path>
<query>location=$vlr$</query>
<method>GET</method>
<content_patterns type="array">
<pattern var="rest_l" pattern="http_headers[name=Location].value"/>
<pattern var="rest_t" edr="rest_t" pattern="content.data.thing"/>
<pattern edr="rest_h" pattern="http_headers[2].value"/>
</content_patterns>
<store_code>rest_code</store_code>
<edr_code>rest_c</edr_code>
</external>
</global>
The following additional external action type parameters are available when specifying a REST external action:
| Parameter | Type | Description |
|---|---|---|
content |
String | As per the rest.content parameter in the N2SVCD REST-C-REQUEST message |
content_type |
String | As per the rest.content_type parameter in the N2SVCD REST-C-REQUEST message |
fragment |
String | As per the rest.fragment parameter in the N2SVCD REST-C-REQUEST message |
host |
String | As per the rest.host parameter in the N2SVCD REST-C-REQUEST message |
http_headers |
Array | As per the rest.http_headers parameter in the N2SVCD REST-C-REQUEST message |
method |
String | As per the rest.method parameter in the N2SVCD REST-C-REQUEST message |
password |
String | As per the rest.password parameter in the N2SVCD REST-C-REQUEST message |
path |
String | As per the rest.path parameter in the N2SVCD REST-C-REQUEST message |
port |
Integer | As per the rest.port parameter in the N2SVCD REST-C-REQUEST message |
query |
String | As per the rest.query parameter in the N2SVCD REST-C-REQUEST message |
security |
String | As per the rest.security parameter in the N2SVCD REST-C-REQUEST message |
username |
String | As per the rest.username parameter in the N2SVCD REST-C-REQUEST message |
route |
String | The N2SVCD Lua agent route to use to send the message. (Default: nil, use default N2SVCD Lua agent application route) |
store_code |
String | The variable to store the received HTTP status code in, if any. (Default: not used, response value will not be stored) |
edr_code |
String | The EDR tag to write the received HTTP status code to, if any. No EDR update will occur unless both a code is returned and an EDR tag is defined. (Default: not used, no code EDR tag will be written for this operation) |
store_content |
String | The variable to store the entire received response content in.(Default: not used, response value will not be stored) |
edr_content |
String | The EDR tag to write the received content to, if any. No EDR update will occur unless both content is returned and an EDR tag is defined.(Default: not used, no content EDR tag will be written for this operation) |
content_patterns |
Array of Object | An array of response path parsing elements for extracting values from the received message content. Note that this is only possible when the received content body is JSON. |
The path, query, fragment, username, password, and content parameters may contain dynamic text definitions.
A REST response is considered successful if the HTTP response status code is in the range 200-299.
If a successful response is received, the applicable details will be populated into the specified variable(s) and/or variable EDR tag(s).
An unsuccessful response will populate only the HTTP status code (if configured to do so). The error encountered will be
raised as a warning and stored in the ERROR external action EDR field.
SOAP Messages
Specifying the external action type soap causes an HTTP(S) SOAP message to be sent. Responses from the message may
be mapped to arbitrary variables.
An example SOAP external action configuration might be:
<global name="EXTERNAL_ACTION_TYPES" type="array">
<external name="soap1" action="soap">
<path>/subscriber/$logical$/check</path>
<query>location=$vlr$</query>
<soap_message_name>check</soap_message_name>
<soap_action>action1</soap_action>
<args>
<foo>bar</foo>
</args>
<args_patterns type="array">
<pattern var="soap_l" pattern="http_headers[name=Location].value"/>
<pattern var="soap_t" edr="soap_t" pattern="args.thing"/>
<pattern edr="soap_h" pattern="http_headers[2].value"/>
</args_patterns>
<store_code>soap_code</store_code>
<edr_code>soap_c</edr_code>
</external>
</global>
The following additional external action type parameters are available when specifying a SOAP external action:
| Parameter | Type | Description |
|---|---|---|
message_name |
String | [Required] As per the soap.message_name parameter in the N2SVCD SOAP-C-REQUEST message |
soap_action |
String | [Required] As per the soap.action parameter in the N2SVCD SOAP-C-REQUEST message |
args |
String | As per the soap.args parameter in the N2SVCD SOAP-C-REQUEST message. Note that this must be native (not CDATA) XML. |
fragment |
String | As per the soap.fragment parameter in the N2SVCD SOAP-C-REQUEST message |
http_headers |
Array | As per the soap.http_headers parameter in the N2SVCD SOAP-C-REQUEST message |
msg_ns_uri |
Integer | As per the soap.message_namepspace.uri parameter in the N2SVCD SOAP-C-REQUEST message |
msg_ns_alias |
Integer | As per the soap.message_namepspace.alias parameter in the N2SVCD SOAP-C-REQUEST message |
msg_ns_location |
Integer | As per the soap.message_namepspace.location parameter in the N2SVCD SOAP-C-REQUEST message |
path |
String | As per the soap.path parameter in the N2SVCD SOAP-C-REQUEST message |
query |
String | As per the soap.query parameter in the N2SVCD SOAP-C-REQUEST message |
route |
String | The N2SVCD Lua agent route to use to send the message. (Default: nil, use default N2SVCD Lua agent application route) |
store_code |
String | The variable to store the received HTTP status code in, if any. (Default: not used, response value will not be stored) |
edr_code |
String | The EDR tag to write the received HTTP status code to, if any. No EDR update will occur unless both a code is returned and an EDR tag is defined. (Default: not used, no code EDR tag will be written for this operation) |
args_patterns |
Array of Object | An array of response path parsing elements for extracting values from the received message args. |
The path, query, fragment, and args parameters may contain dynamic text definitions.
As noted above, the args parameter (if supplied)) must be native (not CDATA escaped) XML representing the content of
the SOAP Body tag.. This will be transcoded to the appropriate SOAP XML internally according to the client configuration.
A SOAP response is considered successful if the HTTP response status code is in the range 200-299 and no SOAP Fault is returned.
If a successful response is received, the applicable details will be populated into the specified variable(s) and/or variable EDR tag(s).
An unsuccessful response will populate only the HTTP status code (if configured to do so). The error encountered will be
raised as a warning and stored in the ERROR external action EDR field.
Diameter Messages
Specifying the external action type diameter causes a Diameter event (CC-Request-Type = 4) message to be sent.
An example Diameter external action configuration might be:
<global name="EXTERNAL_ACTION_TYPES" type="array">
<external name="diam1" action="diameter">
<edr_dsid>ext_dsid</edr_dsid>
<edr_rc>ext_rc</edr_rc>
<send_avps type="array">
<avp name="Action-Name" literal="diam1" />
<avp name="Multiple-Services-Credit-Control">
<value type="array">
<avp name="Extension-1" edr="e1" >
<value type="array">
<rule from_var="logical" />
</value>
</avp>
</value>
</avp>
<avp name="Extension-3" literal="3" />
</send_avps>
<read_avps type="array">
<avp name="Remaining-Balance">
<value type="array">
<avp name="Unit-Value">
<value type="array">
<avp name="Value-Digits" to_bal_units="remaining" to_var="bal_value" edr="bal_value" />
<avp name="Exponent" to_bal_exponent="remaining" to_var="bal_exp" edr="bal_exp" />
</value>
</avp>
<avp name="Currency-Code" to_bal_currency="remaining" to_var="currency" edr="currency" />
</value>
</avp>
<avp name="Extension-2" to_var="ext2" edr="e2" mandatory="1" />
<avp name="Extension-3" to_var="ext3" edr="e3" />
</read_avps>
</external>
</global>
The following additional external action type parameters are available when specifying a Diameter external action:
| Parameter | Type | Description |
|---|---|---|
send_avps |
Array of Object | [Required] An array of additional AVPs to send in the Diameter request, specified in the same way as Diameter request additional AVPs. Note that the attribute type must be set to array in the same fashion. |
read_avps |
Array of Object | An array of AVPs to read from any Diameter response, specified in the same way as Diameter response read AVPs. Note that the attribute type must be set to array in the same fashion.(Default: do not read any response AVPs) |
clear_balances |
Boolean | If truthy, will clear balance information before sending the request in order to allow new information to be populated if received. Otherwise, balance information will be left as-is and potentially updated by the response. (Default: false) |
scid |
String | If set, will be used as the Diameter Service-Context-Id. Otherwise, the network session Service-Context-Id will be used. (Default: use derived Service-Context-Id) |
edr_dsid |
String | The EDR field to write the external action Diameter Session-Id to. (Default: do not write Session-Id to EDR) |
edr_rc |
String | The EDR field to write the effective external action Diameter Result-Code to. If Multiple-Services-Credit-Control is in use in the request and a Result-Code is returned at that level in the response, it will be used. Otherwise, the root Result-Code is used. (Default: do not write Session-Id to EDR) |
route |
String | The N2SVCD Lua agent route to use to send the message. (Default: nil, use default N2SVCD Lua agent application route) |
The following AVPs (in order) are added to all Diameter external actions automatically:
Session-Idas per Diameter parameters.Auth-Application-Id, always set to4.Service-Context-Id, fromscidparameter or as per Diameter requests. Note that, as per the N2IWF state model, the Service-Context-Id is only determined during the setup state. Any Diameter external action that is sent at the start of the setup state will therefore have to have a staticscidparameter defined. If no value is available to populate Service-Context-Id, the external action will fail.CC-Request-Type, always set to4(EVENT_REQUEST).CC-Request-Number, always set to1.Event-Timestamp, set to the current time.Subscription-Idand/orSubscription-Id-Extensionas per Diameter parameters.
By default, no AVP values for either request or response are written to EDR, but this can be achieved as required
using the edr_dsid action parameter or the per-AVP edr parameter.
A Diameter external action response is considered successful if the Result-Code AVP has a value in the range
2000-2999 and all read AVPs marked as mandatory have values.
If a data hook is used to provide details for a Diameter external action, the array(s)
for send_avps and read_avps are expected to be populated with the value parameter already present. The
automatically-added AVPs listed above should not be specified.
Response Path Parsing
Some external actions support specifying individual response fields that should be copied to variables or written to EDRs.
Such configuration is defined within an array consisting of zero or more parsing definitions. The possible values for each definition are:
| Parameter | Type | Description |
|---|---|---|
pattern |
String | [Required] The pattern to match against the applicable received response message. |
var |
String | [Conditional] The variable to store the first matching instance of pattern in. At least one of var and edr must be specified. |
edr |
String | [Conditional] The EDR tag to store the first matching instance of pattern in. At least one of var and edr must be specified. |
Patterns
Each pattern consists of a series of strings, separated either by a period (for hash objects) or square brackets (for array objects).
Array object patterns may be specified by:
- positive index (starting from
1) for the nth array member from the array start. - negative index (starting from
-1) for the nth array member from the array end. - by key/value (e.g.
key=value), for the first matching case where an array member has thekeyset tovalue.
Note that the name of each of the parsing definitions is freeform and not used.
Example
As a worked example, consider the following configuration for a REST action:
<content_patterns type="array">
<pattern var="rest1" pattern="http_headers[1].value"/>
<pattern var="rest2" edr="r2" pattern="http_headers[name=Location].value"/>
<pattern edr="r3" pattern="content.user.id"/>
</content_patterns>
If a response was received such as:
HTTP/1.1 201 Created
Content-Type: application/json
Location: http://example.com/users/123
{
"message": "New user created",
"user": {
"id": 123,
"firstName": "Example",
"lastName": "Person",
"email": "bsmth@example.com"
}
}
… this would be received for parsing as a REST-C-RESPONSE:
{
code = 201,
http_headers = {
{ name = 'Content-Type', value = 'application/json' },
{ name = 'Location', value = 'http://example.com/users/123' }
},
content_type = 'application/json',
content = '{
"message": "New user created",
"user": {
"id": 123,
"firstName": "Example",
"lastName": "Person",
"email": "bsmth@example.com"
}
}'
}
… and the variables would be populated as:
rest1(http_headers[1].value) =application/jsonrest2(http_headers[name=Location].value) =http://example.com/users/123
… and EDR tags written as:
R2=http://example.com/users/123R3=123