tSIP: auto answer on idle

In this quite custom setup auto answer is activated automatically when there is no user activity (mouse, keyboard) for the specified time.

  1. install tSIP 0.1.55.1+
  2. install GetIdleTime plugin (unzip dll file into \phone subdirectory, activate in settings)
  3. set "on call state" script:
    call_state = GetCallState()
    if call_state == 1 then -- CALL_STATE_INCOMING
    	-- "InputIdleTime" variable is set by GetIdleTime plugin
    	local idleTime, idleTimeIsSet = GetVariable("InputIdleTime")
    	if idleTimeIsSet == 1 then
    		idleTime = tonumber(idleTime)
    		-- 300 seconds = 5 minutes idle time
    		if idleTime > 300 then
    			-- some delay allowing ring to be heard
    			print("Auto answer in 3 seconds...\n")
    			for i=1, 30, 1 do
    				Sleep(100)
    				call_state = GetCallState()
    				if call_state ~= 1 then
    					-- breaking on quick disconnect
    					return
    				end
    			end
    			print("Auto answer\n")
    			Answer()			
    		end
    	else
    		print(string.format("InputIdleTime variable is not set. Plugin not loaded?\n"))
    		idleTime = 0
    	end
    end 
      
  4. optionally add button (type = Lua script) that would enable/disable this function and assign script to it:
    local btnId = 36	-- id of this button
    local varName = "AutoAnswerActive"
    local autoAnswerActive = GetVariable(varName)
    if autoAnswerActive ~= "1" then
    	autoAnswerActive = "1"
    	SetButtonCaption(btnId, "AAnswer is ON")
    else
    	autoAnswerActive = "0"
    	SetButtonCaption(btnId, "AAnswer is OFF")
    end
    
    -- set variable for other script
    SetVariable(varName, autoAnswerActive)  
      
    and add in "on call state" script (at the beginning, after checking call state):
    local varName = "AutoAnswerActive"
    local autoAnswerActive = GetVariable(varName)  
    if autoAnswerActive ~= "1" then
    	print("Auto answer is not active\n")
    	return
    end  
      

This configuration is supposed to automatically answer call if user (using wireless headset) is away from computer but same plugin can be used to e.g. automatically log out inactive consultant from ring group ("on timer" script checking idle time + Call(feature_code) + Hangup()).

Back to howto list.