Javascript, session_in_hangup_hook and api_hangup_hook

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Javascript, session_in_hangup_hook and api_hangup_hook

This post has NOT been accepted by the mailing list yet.

I have been trying to run a javascript on hangup in my dialplan, where I need access to the session in the script, but I cannot get it to work. Searching the mailing list also has not revealed anything pertinent (except that it *should* work for at least lua and javascript). My (partial) dialplan looks as follows:

<action application="set" data="session_in_hangup_hook=true"/>
<action application="set" data="api_hangup_hook=jsrun /etc/freeswitch/scripts/script.js"/>
<action application="bridge" data="..."/>

The javascript gets called reliably, however, the session object is not available. If I try to access it, I get an error:

2015-03-02 22:19:22.260371 [ERR] script.js:7 Exception: TypeError: Object #<error> has no method 'getVariable' (near: "var total_billed = session.getVariable("nibble_total_billed");")

So it seems the session object isn't actually a session, but some error? Just printing the session object to the console will output "false".

Is there something I am missing here? Has anybody managed to use the session object in a javascript script in the api hangup hook?

I am using FreeSWITCH Version 1.4.15-1~64bit (-1 64bit) (the debian packages).

Any help would be greatly appreciated.

Thanks and best regards,