<div dir="ltr"><div><br></div>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:<div><br></div><div><b>1234 extension in public domain</b></div><div><br></div><div><extension name="public_did"><br></div><div><div> <condition field="destination_number" expression="^(1234)$"><br></div><div> <action application="python" data="python.incoming_call_<wbr>handler"/></div><div> </condition></div><div> </extension><br></div></div><div><br></div><div>After the<b> incoming_call_handler.py</b> hangs it up and initiate a thread to callback</div><div><br></div><div>def handler(session, args):<br></div><div><div> callerid = session.getVariable('caller_id_number')</div><div> number = (callerid[len(callerid)-10:])</div><div> freeswitch.consoleLog('INFO','Called by %s\n' % number )</div><div> session.hangup()<br></div><div> new_api_obj = API()<br></div><div> new_api_obj.executeString("pyrun python.callback " + callerid)<br></div></div><div><br></div><div><br></div><div><b>Callback.py:</b></div><div>It originates the call by transferring to extension 4449</div><div><br></div><div><div>def runtime(arg1):</div><div><br></div><div> phone_number = arg1[len(arg1)-10:]</div><div> new_api_obj = API()</div><div> command_string = "originate sofia/gateway/MySIP/91" + phone_number + " 4449"</div><div> result = new_api_obj.executeString("reloadxml")</div><div> return_val = new_api_obj.executeString(command_string)</div><div><br></div><div><b>4449</b></div><div>4449 calls Sangoshthi_IVR_handler to play IVR menu on call answer</div><div><br></div><div><extension name="record_topic"></div><div><condition field="destination_number" expression="^4449"></div><div><action application="set" data="execute_on_answer=python <b>python.sangoshthi_IVR_handler/></b></div><div><action application="sleep" data="30000"/></div><div></condition></div><div></extension></div><div><br></div><div>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.</div></div><div><br></div><div>Regards,</div><div>Deepika</div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 14, 2017 at 9:16 PM, Michael Jerris <span dir="ltr"><<a href="mailto:mike@jerris.com" target="_blank">mike@jerris.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class=""><blockquote type="cite"><div>On Sep 14, 2017, at 6:01 AM, Deepika Yadav <<a href="mailto:deepikay@iiitd.ac.in" target="_blank">deepikay@iiitd.ac.in</a>> wrote:</div><br class="m_1109480290467398498Apple-interchange-newline"><div><div dir="ltr">Hi,<div><br></div><div>I have implemented a functionality where when a person with his mobile phone number calls a specific number (that of SIM inserted in our GOIP hardware), the incoming is hanged and that person is called back.</div><div><br></div><div>After the IVR menu starts playing and if in between caller hangs up, hangup_event is not detected and the registered hangup_hook does not get called.</div><div><br></div><div>Code is as follows;</div><div><b><br></b></div><div><b>XML file that starts python script when the person answers the cal</b>l:</div><div><div><br></div><div><extension name="record_topic"></div><div> <condition field="destination_number" expression="^4449"> </div><div> <action application="set" data="execute_on_answer=python <b>python.sangoshthi_IVR_handler</b>"<wbr>/></div><div><br></div><div> <action application="sleep" data="30000"/></div><div> </condition></div><div></extension></div></div><div><br></div></div></div></blockquote><div><br></div></span><div>This part is really strange. If you want to execute that python script when the call answers after originating to the endpoint, just make the python the only thing in dial plan, and use ignore_early_media on the originate. It won’t hit the dial plan until answer. As for the rest of your question, it seems like you are saying you don’t get the hanguphook when the python script isn’t running?</div><br><blockquote type="cite"><div><span class=""><div dir="ltr"><div><b>Python Script handler:</b></div><div><br></div><div><div>def handler(session, args):</div><div> </div><div> session.setHangupHook(hangup_<wbr>hook)</div><div> session.setInputCallback(<wbr>input_callback)</div><div><br></div><div> print('session object value is ', str(session))</div><div><br></div></div><div><div> callerid = session.getVariable('caller_<wbr>id_number')</div><div> call_uuid = session.getVariable('uuid')</div><div><br></div><div> phone_number = callerid[len(callerid)-10:]</div><div><br></div><div> initial_greeting(session, phone_number, call_uuid)</div></div><div><br></div><div><br></div><div><div>def hangup_hook(session, what, args=''):<br></div></div><div><div> """</div><div> Must be explicitly set up with session.setHangupHook(hangup_<wbr>hook).</div><div><br></div><div> `session` is a session object.</div><div> `what` is "hangup" or "transfer".</div><div> `args` is populated if you pass extra args to session.setInputCallback().</div><div><br></div><div> """</div><div> print('PERSON HANGED UPPPPP...........')</div><div> freeswitch.consoleLog("INFO", "hangup hook for '%s'\n" % what)</div><div><br></div></div><div>-- <br><div class="m_1109480290467398498gmail_signature"><div dir="ltr">Regards,<div>Deepika</div><div><a href="https://deepikay.wixsite.com/deepika" target="_blank">https://deepikay.wixsite.com/<wbr>deepika</a><br></div></div></div>
</div></div></span>
______________________________<wbr>______________________________<wbr>_____________<br>Professional FreeSWITCH Consulting Services:<br><a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a><br><a href="http://www.freeswitchsolutions.com" target="_blank">http://www.<wbr>freeswitchsolutions.com</a><br><br>Official FreeSWITCH Sites<br><a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br><a href="http://confluence.freeswitch.org" target="_blank">http://confluence.freeswitch.<wbr>org</a><br><a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br><br>FreeSWITCH-users mailing list<br><a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.<wbr>freeswitch.org</a><br><a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/<wbr>mailman/listinfo/freeswitch-<wbr>users</a><br>UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.<wbr>freeswitch.org/mailman/<wbr>options/freeswitch-users</a><br><a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a></div></blockquote></div><br></div><br>______________________________<wbr>______________________________<wbr>_____________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" rel="noreferrer" target="_blank">http://www.<wbr>freeswitchsolutions.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://confluence.freeswitch.org" rel="noreferrer" target="_blank">http://confluence.freeswitch.<wbr>org</a><br>
<a href="http://www.cluecon.com" rel="noreferrer" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.<wbr>freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/<wbr>mailman/listinfo/freeswitch-<wbr>users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.<wbr>freeswitch.org/mailman/<wbr>options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" rel="noreferrer" target="_blank">http://www.freeswitch.org</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Regards,<div>Deepika</div><div><a href="https://deepikay.wixsite.com/deepika" target="_blank">https://deepikay.wixsite.com/deepika</a><br></div></div></div>
</div>