tSIP softphone: auto answer at scheduled hours

This script - assigned to "on call state" event - would automatically answer incoming calls at scheduled hours, playing announcement from wave file. Outside of specified time span softphone would work normally.

local timeVal = os.date("*t")
print("currentTime: " .. timeVal.hour .. ":" .. timeVal.min .. ":" .. timeVal.sec .. "\n")
local milTime = (timeVal.hour * 100) + timeVal.min
-- "military" time format: script active from 18:00 to 9:00
if milTime >= 1800 or milTime < 900 then
-- if milTime >= 1040 and milTime < 1400 then
	local callState = GetCallState()
	print(string.format("Current call state = %d\n", callState))
	if callState == 1 then
		print("INCOMING\n")
		Answer()
	elseif callState == 6 then
		print("ESTABLISHED\n")
		SwitchAudioSource("aufile", "voicemail_annoucement.wav")
	end
end
  

voicemail_annoucement.wav (example file from voice mail application, required wav mono S16LE format) has to be placed in application directory.

This script can be combined with call recording for voice mail functionality.
If using on PC without audio input device - switch (default) audio input module type to "Null".

Back to howto list