[Freeswitch-users] Hangup_hook is not getting called in mod_python script

Deepika Yadav deepikay at iiitd.ac.in
Thu Sep 14 10:01:28 UTC 2017


Hi,

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.

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.

Code is as follows;

*XML file that starts python script when the person answers the cal*l:

<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>

*Python Script handler:*

def handler(session, args):

    session.setHangupHook(hangup_hook)
    session.setInputCallback(input_callback)

    print('session object value is ', str(session))

    callerid =  session.getVariable('caller_id_number')
    call_uuid = session.getVariable('uuid')

    phone_number = callerid[len(callerid)-10:]

     initial_greeting(session, phone_number, call_uuid)


def hangup_hook(session, what, args=''):
    """
    Must be explicitly set up with session.setHangupHook(hangup_hook).

    `session` is a session object.
    `what` is "hangup" or "transfer".
    `args` is populated if you pass extra args to
session.setInputCallback().

    """
    print('PERSON HANGED UPPPPP...........')
    freeswitch.consoleLog("INFO", "hangup hook for '%s'\n" % what)

-- 
Regards,
Deepika
https://deepikay.wixsite.com/deepika
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20170914/c8795251/attachment.html>


More information about the FreeSWITCH-users mailing list