Sample Preliminary and Postliminary Scripts Call Server Configuration
Polycom, Inc. 237
Transformation scripts output some modification of the DIAL_STRING
variable (which is initially set to the dial string being evaluated).
Filtering scripts may pass the dial string on to the dial rule’s action (if the filter
criteria aren’t met) or return one of the following:
• NEXT_RULE: Skips the rule being processed and passes the dial string to
the next rule.
• BLOCK: Rejects the call.
The following sample scripts address many of the scenarios for which you
might need a preliminary or postliminary script. You can use them as
templates or starting points for your scripts.
///////////////////////////////
// STRIP PREFIX
// If the dial string has prefix 99, remove it
// 991234 --> 1234
DIAL_STRING = DIAL_STRING.replace(/^99/,"");
///////////////////////////////
// ADD PREFIX
// Add prefix 99 to the dial string
// 1234 --> 991234
DIAL_STRING = "99" + DIAL_STRING;
///////////////////////////////
// STRIP PREFIX (SIP)
// If the dial string is a SIP URI with prefix 99 in the user part, remove it
// SIP:991234@abc.com --> sip:1234@abc.com
DIAL_STRING = DIAL_STRING.replace(/^sip:99([^@]*@)/i,"sip:$1");
///////////////////////////////
// ADD PREFIX (SIP)
// If the dial string is a SIP URI, add prefix 99 to the user part
// SIP:1234@abc.com --> sip:991234@abc.com
DIAL_STRING = DIAL_STRING.replace(/^sip:([^@]*@)/i,"sip:99$1");
///////////////////////////////
// SUBSTITUTE DOMAIN (SIP)
// If the dial string is a SIP URI, change the domain part to "example.com"
// SIP:1234@abc.com --> sip:1234@example.com
DIAL_STRING = DIAL_STRING.replace(/^sip:([^@]*)@(.*)/i,"sip:$1@example.com");
///////////////////////////////
// FILTER