[Freeswitch-users] hunt group - play music when trying external numbers
William Traenkle
will.traenkle at yahoo.com
Mon Mar 8 14:31:50 PST 2010
I am sending this again as I did not see it go through the first time ...
FS Community,
I am new to freeSWITCH and this mailing list and I appreciate your support in advance.
My Goal: To create a hunt group x7000 that sequentially dials an internal extension, i.e. x1000, and then a cell phone number, i.e. 6194548924, while playing music the entire time when each number is being tried.
The Issue: This was working great a few months back, but now music plays when only when x1000 is tried but NOT when the cell phone is tried.
Ideas? Please advise.
My hunt group code is below:
session.answer();
var domain_name = session.getVariable("domain_name");
var extension = '7000';
var result;
var timeoutpin = 7500;
var objdate = new Date();
var adjusthours = 0; //Adjust Server time that is set to GMT 7 hours
var adjustoperator = "-"; //+ or -
if (adjustoperator == "-") {
var objdate2 = new Date(objdate.getFullYear(),objdate.getMonth(),objdate.getDate(),(objdate.getHours() - adjusthours),objdate.getMinutes(),objdate.getSeconds());
}
if (adjustoperator == "+") {
var objdate2 = new Date(objdate.getFullYear(),objdate.getMonth(),objdate.getDate(),(objdate.getHours() + adjusthours),objdate.getMinutes(),objdate.getSeconds());
}
var Hours = objdate2.getHours();
var Mins = objdate2.getMinutes();
var Seconds = objdate2.getSeconds();
var Month = objdate2.getMonth() + 1;
var Date = objdate2.getDate();
var Year = objdate2.getYear()
var Day = objdate2.getDay()+1;
var exit = false;
function get_sofia_contact(extension,domain_name, profile){
if (profile == "auto") {
profile = "internal";
session.execute("set", "sofia_contact_"+extension+"=${sofia_contact("+profile+"/"+extension+"@"+domain_name+")}");
sofia_contact = session.getVariable("sofia_contact_"+extension);
if (sofia_contact == "error/user_not_registered") {
profile = "external";
session.execute("set", "sofia_contact_"+extension+"=${sofia_contact("+profile+"/"+extension+"@"+domain_name+")}");
sofia_contact = session.getVariable("sofia_contact_"+extension);
}
}
else {
session.execute("set", "sofia_contact_"+extension+"=${sofia_contact("+profile+"/"+extension+"@"+domain_name+")}");
sofia_contact = session.getVariable("sofia_contact_"+extension);
}
console_log( "info", "sofia_contact "+profile+": "+sofia_contact+".\n" );
return sofia_contact;
}
function mycb( session, type, obj, arg ) {
try {
if ( type == "dtmf" ) {
console_log( "info", "digit: "+obj.digit+"\n" );
if ( obj.digit == "#" ) {
//console_log( "info", "detected pound sign.\n" );
exit = true;
return( false );
}
dtmf.digits += obj.digit;
if ( dtmf.digits.length >= digitmaxlength ) {
exit = true;
return( false );
}
}
} catch (e) {
console_log( "err", e+"\n" );
}
return( true );
} //end function mycb
dialed_extension = session.getVariable("dialed_extension");
domain_name = session.getVariable("domain_name");
domain = session.getVariable("domain");
us_ring = session.getVariable("us-ring");
caller_id_name = session.getVariable("caller_id_name");
caller_id_number = session.getVariable("caller_id_number");
effective_caller_id_name = session.getVariable("effective_caller_id_name");
effective_caller_id_number = session.getVariable("effective_caller_id_number");
outbound_caller_id_name = session.getVariable("outbound_caller_id_name");
outbound_caller_id_number = session.getVariable("outbound_caller_id_number");
session.execute("set", "ringback=${hold_music}"); //set to ringtone
session.execute("set", "transfer_ringback=${hold_music}"); //set to ringtone
session.execute("set", "call_timeout=30");
session.execute("export", "call_timeout=30");
session.execute("set", "continue_on_fail=true");
session.execute("set", "hangup_after_bridge=true");
//console_log( "info", "dialed extension:"+dialed_extension+".\n" );
//console_log( "info", "domain: "+domain+".\n" );
//console_log( "info", "us_ring: "+us_ring+".\n" );
//console_log( "info", "domain: "+domain+".\n" );
//console_log( "info", "domain_name: "+domain_name+".\n" );
//console_log( "info", "action call now don't wait for dtmf\n" );
if ( session.ready() ) {
session.answer();
sofia_contact_1000 = get_sofia_contact("1000",domain_name, "auto");
session.execute("bridge", sofia_contact_1000);
session.execute("bridge", "sofia/gateway/flowroute.com/16194548924");
//timeout
if (session.getVariable("originate_disposition")!="SUCCESS" && session.getVariable("originate_disposition")!="ORIGINATOR_CANCEL"){
session.execute("info", "");
session.execute("transfer", "*991000");
}
//clear variables
dialed_extension = "";
new_extension = "";
domain_name = "";
domain = "";
} //end if session.ready
Thanks.
-Will
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20100308/9c050611/attachment-0002.html
More information about the FreeSWITCH-users
mailing list