But now I have another problem, when I answer the call I receive a hangup before transfer to my callcenter.
Look the code
local clock = os.clock
function sleep(n) -- seconds
local t0 = clock()
while clock() - t0 <= n do end
end
telefone = argv[1]
gateway = argv[2]
contexto = argv[3]
fila = argv[4]
freeswitch.consoleLog("info","INICIANDO CALLBACK\n")
freeswitch.consoleLog("info","NUMERO ALVO DO CALLBACK: " ..telefone.. ".\n")
freeswitch.consoleLog("info","GATEWAY DE LIGAÇÃO: " ..gateway.. ".\n")
freeswitch.consoleLog("info","CONTEXTO: " ..contexto.. " FILA: " ..fila.. ".\n")
--Ligando para o numero respectivo
sleep(3)
freeswitch.consoleLog("info","TENTANDO CALLBACK\n")
session = freeswitch.Session(gateway..telefone)
if session:answered() then
session:transfer(fila, "XML", contexto)
else
freeswitch.consoleLog("info","TELEFONE INDISPONIVEL\n")
end