Since it is a callback mechanism. Before passing to the 4449 extension, the user simply dials a fixed mobile number, the extension '1234' passes it to python script incoming_call_handler.py as follows:
1234 extension in public domain
<extension name="public_did">
<condition field="destination_number" expression="^(1234)$">
<action application="python" data="python.incoming_call_handler"/>
</condition>
</extension>
After the incoming_call_handler.py hangs it up and initiate a thread to callback
def handler(session, args):
callerid = session.getVariable('caller_id_number')
number = (callerid[len(callerid)-10:])
freeswitch.consoleLog('INFO','Called by %s\n' % number )
session.hangup()
new_api_obj = API()
new_api_obj.executeString("pyrun python.callback " + callerid)
Callback.py:
It originates the call by transferring to extension 4449
def runtime(arg1):
phone_number = arg1[len(arg1)-10:]
new_api_obj = API()
command_string = "originate sofia/gateway/MySIP/91" + phone_number + " 4449"
result = new_api_obj.executeString("reloadxml")
return_val = new_api_obj.executeString(command_string)
4449
4449 calls Sangoshthi_IVR_handler to play IVR menu on call answer
<extension name="record_topic">
<condition field="destination_number" expression="^4449">
<action application="set" data="execute_on_answer=python python.sangoshthi_IVR_handler/>
<action application="sleep" data="30000"/>
</condition>
</extension>
Yes, the python script is running successfully the only thing is when caller drops the call the hang u callback registered using hangup_hook does not called.
Regards,
Deepika