JavaScript Example - cnam
About
This CNAM java script is a wrapper script for the ULTIMATE CNAM perl script here
Place this .js file in your FS_ROOT/scripts directory along with the cnam.pl file.
Add a line to your dialplan prior to answering the call:
<action application="javascript" data="cnam.js"/>
cnam.js
cnam.js
/*
* Author cjt
* This CNAM java script is a wrapper script for the ULTIMATE CNAM perl script (cnam.pl)
* Place this .js file in your FS_ROOT/scripts directory along with the cnam.pl.
* Add a line to your dialplan like the following:
* <action application="javascript" data="cnam.js"/>
*/
var fd;
var buff;
function logger(logstuff, loglevel) {
console_log(loglevel, logstuff + "\n");
}
fd = new File("|/usr/local/freeswitch/scripts/cnam.pl --number=" + session.caller_id_number)
logger("caller id is " + session.caller_id_number, "info");
fd.open("read");
buff = fd.readAll();
if(buff.length == 3 && buff[2]) {
logger("cnam.js caller_id_name is " + buff[2], "info");
session.setVariable("effective_caller_id_name", buff[2]);
}