Open URL on call completed elsewhere

This is a script for unusual use case: tSIP being used to open CRM webpage while actual calls are handled by desk phone. tSIP and desk phone belong to the same call group, so tSIP receives BYE with "Call completed elsewhere" reason when call is answered on the desk phone.

Lua GetCallReason() function was added in tSIP 0.3.08.1.

Alternative way for similar function might be using BLF with remote identity.

Following script should be assigned to "on call state" event; modify URL to required by CRM or other application.

local callState = GetCallState()
if callState == 0 and IsCallIncoming() == 1 then
	print("Call CLOSED\n")
	local reason = GetCallReason()
	local peer = GetCallPeer()
	print(string.format("Lua: call from [%s] disconnect, reason = [%s]\n", peer, reason))
	if (string.upper(reason) == "CALL COMPLETED ELSEWHERE") then
		print("CALL COMPLETED ELSEWHERE\n")
		local url = "https://www.google.com/search?q=" .. peer
		ShellExecute("open", url, nil, "", 1)
	end
end

Back to howto list