How to accept calls only during a specific block of time
Posted: Fri Oct 09, 2009 12:52 pm
Code: Select all
// LANGUAGE=DWS
// 20090914 - bwm Time of Day call handler. When this action is assigned to a contact
// it will play a message and then hangup if the call is outside of the prescribed time window
// (single block of days, single block of time), otherwise it will let the call ring through.
//
// One use is to tell telemarketers to call back during a time when you aren't home so they
// have to leave a message on an answering machine. If they call outside of the time/day time block
// when you are home, your phone only rings once. Some telemarketer dialers can tell if an answering
// machine picks up, so I precede my message with a "Hello? ........ Hello?....." sound file to
// get the call transfered to an agent before the message to call back later is played.
//
// (requires hardware ability to play sound file over phone with phonesound() and a sound file of
// the message you want to play).
var CallDate: DateTime;
var CallTime: DateTime;
var TODStart: DateTime;
var TODStop: DateTime;
var DOWStart: Integer;
var DOWStop: Integer;
var AnnounceInWindow: String;
var AnnounceOutWindow: String;
// Set your time windows (inclusive; listed days will accept calls)
// DOW: 1=Sun, 2=Mon, 3=Tue, 4=Wed, 5=Thu, 6=Fri, 7=Sat
// TOD: HH:MM:SS xx format (xx is am or pm)
DOWStart := 2;
DOWStop := 5;
TODStart := StrToTime('9 am');
TODStop := StrToTime('4 pm');
AnnounceInWindow := '';
AnnounceOutWindow := 'CallBackM-R_9am-4pm_HangupsWillBePermanentlyBlocked.wav';
// Begin processing call
CallDate := Date;
CallTime := Time;
if (DayOfWeek(CallDate) >= DOWStart) and (DayOfWeek(CallDate) <= DOWStop) and (CallTime >= TODStart) and (CallTime < TODStop) then
begin
// Actions to occur within DOW, TOD window, if you want any
// phonesound(AnnounceInWindow);
// hangup;
end
else
begin
// Actions to occur outside of DOW, TOD window
// Say 'Hello? ..." twice to get agent on the line
phonesound('HelloX2.wav');
// Play the callback message twice
phonesound(AnnounceOutWindow);
phonesound(AnnounceOutWindow);
hangup;
end;