[Freeswitch-users] Adding SIP Headers in Javascript

Preston Hagar prestonh at gmail.com
Fri May 18 15:54:53 UTC 2018


Quick Version:  Is there some special way to set custom SIP headers when
you are bridging a call from Javascript instead of XML?

Full Details:
We am using Voice Operator Panel (VOP) as a receptionist console.  We have
multiple external numbers that all funnel into a few receptionist desks.
If I add a SIP Diversion header, then VOP will use that to show the
receptionist which number the caller dialed to reach them, which would help
things out a lot.

If I add it in an XML dialplan and then do a direct bridge to one of the
receptionist numbers, it works great (snip of working direct dialplan):

<action application="set" data="sip_h_Diversion=<sip:${
destination_number}@pbx.example.org
>;privacy=off;reason=unconditional;counter=1;screen=no"/>
<action application="bridge" data="user/1000 at pbx.example.org"/>

The problem is I need a bit of advanced logic to figure out which
receptionist are online and then ring those, then fail over to other
numbers and ultimately IVR if no one answers, so I instead pass calls to
them off to javascript, so the bridge line above becomes something link:

<action application="javascript" data="${jslib}/frontdesk.js
${dialed_extension} ${domain_name} ${destination_number}" />

I've tried setting the SIP header in the XML above the javascript line and
then exporting it
    <action application="set" data="sip_h_Diversion=<sip:${
destination_number}@pbx.example.org>;privacy=off;reason=unconditional;counter=1;screen=no"/>


        <action application="export" data="sip_h_Diversion" />

and setting it in the Javascript:

    var diversionHeader = 'sip_h_Diversion=<sip:' + $destination_number + '@
pbx.example.org>;privacy=off;reason=unconditional;counter=1;screen=no';

    session.execute('set',diversionHeader);
    session.execute('export','sip_h_Diversion');

but in both cases (or with both in place), the SIP header is never written.

Is there some magic to setting SIP headers in Javascript?  I can't seem to
find any examples or documentation about it.

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20180518/915f09fb/attachment.html>


More information about the FreeSWITCH-users mailing list