Script code

Routing script code

A script starts with the begin keyword and ends with the end keyword.

begin
  
  # route all messages to O2 UK SMSC 2
  SMSC = smscid("O2-SMSC-2")

end

Use the # character at the start of a line to include comments within a script.

SMSC assignment (SMSC =)

Sets an SMSC to where a message should be routed.

Specify the SMSC by its short name:

SMSC = smscid("MLSMSCSimX")

Specify the SMSC by its API ID:

SMSC = smscapiid("1387e426-c962-78fd-ac30-06666d5c3860")

Select the next SMSC from a group:

SMSC = smscgroup("MLSimulators1").rr

match <field>

The match statement allows the comparison of <field> with values, where a match to a value will result in an SMSC assignment taking place.

match sm.destination_addr  
  startswith 447711 { SMSC = smscid("BTC-SMSC1A"); done; } 
  startswith 447722 { SMSC = smscid("BTC-SMSC1B"); done; } 
matchend

The done keyword can be used to stop further execution of the script when a match takes place.

Match fields

<field> may be any of the following:

FieldDescription
SMPP account
ac.system_idAccount system ID sending the messagematch system_id
abcd12340def { ... }
abcd23450def { ... }
abcd34560def { ... }
matchend
ac.system_typeAccount system type sending the message
Short message
sm.service_typeService type field in the short message
sm.source_addrSource address in the short messagematch sm.source_addr
447700123456 { ... }
447700222333 { ... }
447700444555 { ... }
matchend
sm.destination_addrDestination mobile numbermatch sm.destination_addr
447700123456 { ... }
447700222333 { ... }
447700444555 { ... }
matchend
sm.destination_addr.country/dialcodeCountry dialcodematch sm.destination_addr.country/dialcode
44 { ... }
46 { ... }
47 { ... }
matchend
👷‍♂️ sm.destination_addr.country/iso3166Country two-letter codematch sm.destination_addr.country/iso3166
GB { ... }
SE { ... }
NO { ... }
matchend
👷‍♂️ sm.destination_addr.network/mncNetwork MNCmatch sm.destination_addr.network/mnc
23415 { ... }
23433 { ... }
23450 { ... }
matchend
sm.short_messageShort message textmatch sm.short_message
contains hello { ... }
startswith abc { ... }
endswith def { ... }
matchend
👷‍♂️ sg.cost("...")/dialcodeSMSC group cost for country
👷‍♂️ sg.cost("...")/mncSMSC group for network

Data topics may also be used as fields.

Match values

The following comparison operators may be used with the value being compared:

OperatorDescription
eqEquals (may be ommited)
neqNot equal
startswithStarts withmatch sm.destination_addr
startswith 447700 { ... }
startswith 447711 { ... }
startswith 447722 { ... }
matchend

match sm.short_message
startswith Hello { ... }
startswith Hi { ... }
startswith ALARM { ... }
matchend
endswithEnds with
containsContains

if <expression> 👷‍♂️

Perform actions based on one or more criteria.

The fields used in criteria for match are supported in if statements.

if
  sm.destination_addr.country/dialcode eq 44 and
  sg.cost("O2Bulk").dialcode("44") < sg.cost("VFBulk").dialcode("44")
{ SMSC = smscid("O2SMSC-1A") }
else
{ SMSC = smscid("VFSMSC-1A") }