[Freeswitch-users] Javascript switch_ivr_originate.c:177 Invalid Application ?

Bob Smith gb10hkzo-freeswitch at yahoo.co.uk
Mon Jan 16 18:32:05 MSK 2012


Hi Avi,

The pertinent lines are :

<action application="set" data="group_confirm_key=exec"/>
<action application="set" data="group_confirm_file=/usr/local/freeswitch/scripts/confirm.js"/>

So I'm a step further now, I get:

2012-01-16 15:26:20.954602 [ERR] confirm.js:61 near  SyntaxError: invalid returnreturn true;


The same occurs if I use brackets around the "true".

I've adapted the script slightly to use a pin pulled from a database (but I'm no Javascript Guru, so I'm guessing I missed a glaring bug !).

Thanks for your help.

=============================================================
// confirm.js - Freeswitch Call PIN Check
//
//
console_log("info", "Destination: "+ session.destination + "\n");
//
if(!session.getVariable('my_legconf'))
{
  console_log("info", "No B-Leg Confirmation Requested \n");
  exit();
}
//
//
// Variables...
//
var v_continue = false;
var conf_pin = session.getVariable('my_legpin');
var attempts = 3;
var sound_file = "ivr-please_enter_pin_followed_by_pound.wav";
var pin_lastdigit="";
var pin = new Object();
pin.digits = "";

function parseInput (session,type,data,arg) {
if ( type == "dtmf" ) {
pin_lastdigit = data.digit;
pin.digits += pin_lastdigit;
console.log("info","Read digit " + pin_lastdigit + "\n");
return false;
}
}
//
//
if (session.ready()) {
session.answer();
session.flushDigits();
console.log("info","Starting PIN Collection\n");
var cnt = attempts;
while (session.ready() && ! v_continue && cnt-- > 0)
{
session.execute("sleep","200");
session.streamFile(sound_file,parseInput);
while (pin_lastdigit != "#" && sesson.ready()) {
session.collectInput(parseInput,pin,5000);
}
console.log("info","Collected PIN: " + pin.digits + "\n");
if ( pin.digits == conf_pin ) {
v_continue = true;
console.log("info","PIN OK !.\n");
} else {
pin_lastdigit = "";
pin.digits = "";
session.flushDigits();
}
}
} else {
console.log("info","Session not ready.\n");
}
//
//
if(v_continue) {
return true;
} else {
return false;
}
=============================================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20120116/9fc764e7/attachment.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list