I have put together a dialer (of sorts) that is failing a fraction of the time. First, I instantiate a call leg from FreeSwitch to an agent (an employee in my facility with a softclient registered to FreeSwitch). Upon answering this call I have FreeSwitch bridge this leg to an outbound leg destined to a customer (via our carrier). The agent listens as this external number is dialed then is prepared to speak with that person. So all is well except a fraction of these calls fail at the step where FreeSwitch calls the agent. There seems to be a 'hangup' event received from the client at the moment this leg is answered. This happens maybe 1/3 of the time.
here's my steps
1. call a Lua script via ESL
2. Lua script generates a call leg to agent:
local session = freeswitch.Session("user/" .. agentExt .. "@
stuff.com")
session:sleep(1000)
if session:ready() then
session:execute("pre_answer")
session:execute("ring_ready")
session:execute("sleep", "1000")
session:setVariable("outbound_callee_number", outboundCalleeNumber)
session:setVariable("outbound_caller_number", outboundCallerNumber)
session:setVariable("outbound_caller_name", outboundCallerName)
session:transfer("sales_outbound", "XML", "telifi")
******** fails here ~30% of the time - phone rings on the agent's desk, she answers and the call immediately ends ********
3. this leg is transferred to an XML dialplan that handles bridging to a customer's phone number:
<extension name="sales_outbound">
<condition field="destination_number" expression="^sales_outbound$">
<action application="log" data="INFO connected to agent, now dialing out..."/>
<action application="sleep" data="1000"/>
<action application="playback" data="ivr/8000/ivr-call_being_transferred.wav"/>-->
<action application="set" data="continue_on_fail=true"/>
<action application="set" data="hangup_after_bridge=true"/>
<action application="set" data="ringback=${us-ring}"/>
<action application="set" data="call_timeout=30"/>
<action application="set" data="effective_caller_id_number=${outbound_caller_number}"/>
<action application="set" data="effective_caller_id_name=${outbound_caller_name}"/>
<action application="sleep" data="1000"/>
<action application="bridge" data="sofia/gateway/mycarrier/${outbound_callee_number}"/>
</condition>
</extension>
I appreciate any insight or suggestions you could provide.