Hi - I'm starting to use Freeswitch to receive inbound faxes - which works brilliantly - but I am trying to get my head around how to launch some .js code after hangup, i.e. to deal with the fax file itself.

Specifically, I'm expecting that I'm able to access session data in the script by setting session_in_hangup_hook=true, as below.

Now, invoking .js files seems to work fine - either in the dialpan itself, or via the hangup hook. But what I can't seem to understand is how the session data is accessible in the invoked javascript. I'm getting the following error on the FS console from hangup.js:

Exception: ReferenceError: request is not defined (near: "var env = request.dumpENV("text");")


XML Dialplan and hangup.js code fragments below. Any clues as to what I'm doing wrong?

(Environment is a current 1.6, Debian 8, installed via FS packages - not from source. mod_v8 is loaded - the scripts are executing, apparently - but I'm stuck trying to find the example code to access the session variables).

Any help appreciated,

Mark

-----

Dialplan XML:

<extension name="fax_receive">

  <condition field="destination_number" expression="^5551212$">

    <action application="set" data="session_in_hangup_hook=true"/>

    <action application="set" data="api_hangup_hook=jsrun /home/mark/hangup.js"/>

    <action application="answer" />

    <action application="javascript" data="/home/mark/postfax.js"/>

    <action application="playback" data="silence_stream://2000"/>

    <action application="set" data="fax_enable_t38_request=true"/>

    <action application="set" data="fax_enable_t38=true"/>

    <action application="rxfax" data="/tmp/FAX-${uuid}.tif"/>

    <action application="hangup"/>

  </condition>

</extension>




// hangup.js code fragment

console_log("notice","Inside the hangup.js script");  // This executes, I get the console message post-hangup


// Get and log all available session variables.

var env;

env = request.dumpENV("text");


console_log(env);