Sample Script Pug-in
This section explains how to set up your custom script with the Script Plug-in.
1. Example of Notes Setup
We assume that we create a Note “sample1” and set a function like below,
Select the menu [Notes]. Set the following javascript-based script in the Notes.
Name | Description |
Name | sample1 |
Description | A brief description of the note |
User access level | Access level Select from “No Access”, “Read only”, “Read/Write” |
Note | Enter the script below |
sample1:
var HEADERS = ["X-SampleHeader01","X-SampleHeader02","X-SampleHeader03" ];
var JSONObject=Java.type('org.json.simple.JSONObject');
var StrEscape=Java.type('com.brekeke.str.StrEscape');
function getHeaders( param, rd, route, rule ){
var p = rd.getSIPpacket();
var jo = new JSONObject();
for( var i = 0; i < HEADERS.length; i++ ){
var h = HEADERS[i];
var v = p.header.get( h ) || "";
jo.put( h, v );
}
return StrEscape.escape(jo.toString());
}
2. Example of ARS Setup
Set ARS route. Using the default plugin “script”, The route can execute the script configured at the Note.
Matching patterns: Plugin 1 : script <- Use default plugin "script" Param 1 : sample1.getHeaders <- Specify the note name that includes a script. Format is <note name>.<function name> Return 1 : (.+)
Deploy patterns:
DNIS : 6501234567 <- Set your target DNIS on CIM
Custom : &_pbx.cti.param=&p1 <- Returned value can be referred with "&p1". Then the value would be stored into the parameter"_pbx.cti.param".
In this example, the ARS route gets the multiple SIP headers’ value with the customized script, then store the values into the “_pbx.cti.param”