Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Warning

THIS GUIDE ASSUMES YOU ARE INSTALLING ON A FRESH CentOS 5.5 x86_64 SERVER WITHOUT sipXecs ON IT AND THAT YOU'VE ALREADY BUILT FreeSWITCH FROM SOURCE

Note

WAV files used in this example are attached

To start fs_ivrd you'll need to use this init script. Place it in /etc/init.d and mark it executable.

...

Now restart postgresql

FreeSWITCH

Note

Be sure to create a gateway pointing to you FreeSWITCH server in sipXecs and point the appropriate numbers to it

Add the following to your FreeSWITCH dialpan (change expressions to meet your needs):

...

Create a new conference profile called intercom in 8/usr/local/freeswitch/conference.conf.xml* and set it to the following:

Code Block
    <profile name="intercom">
      <condition<param fieldname="destination_numberdomain" expressionvalue="^(3402)$"$${domain}"/>
      <action<param applicationname="luarate" datavalue="/usr/local/freeswitch/scripts/page_outcall.lua $1"16000"/>
      <param name="interval" value="20"/>
      <action<param applicationname="setenergy-level" datavalue="ivr_path=/usr/local/freeswitch/scripts/page_int.php300"/>
      <action<param applicationname="socketsound-prefix" data="127.0.0.1:9090 async fullvalue="$${sounds_dir}/en/us/callie"/>
     </condition>
   </extension> <param name="muted-sound" value="conference/conf-muted.wav"/>
      <extension<param name="outbound-socket"unmuted-sound" value="conference/conf-unmuted.wav"/>
      <condition<param fieldname="destination_numberalone-sound" expressionvalue="^(3403)$"conference/conf-alone.wav"/>
      <action<param applicationname="luamoh-sound" datavalue="/usr/local/freeswitch/scripts/page_time_set.lua"/>
    </condition>
   </extension>

now reload FreeSWITCH

Add the following scripts to your /usr/local/freeswitch/scripts folder:

Code Block
titlepage_int.php
#!/usr/bin/php -q

<?php

// set a couple of things so we dont kill the system
ob_implicit_flush(true);
set_time_limit(30);

// Open stdin so we can read the data in
$in = fopen("php://stdin", "r");

// Connect to conference

echo "sendmsg\n";
echo "call-command: execute\n";
echo "execute-app-name: set\n";
echo "execute-app-arg: conference_auto_outcall_flags=mute\n\n";

echo "sendmsg\n";
echo "call-command: execute\n";
echo "execute-app-name: set\n";
echo "execute-app-arg: api_hangup_hook=conference $1 kick all\n\n";

echo "sendmsg\n";
echo "call-command: execute\n";
echo "execute-app-name: conference\n";
echo "execute-app-arg: $1@default\n\n";

echo "sendmsg\n";
echo "call-command: execute\n";
echo "execute-app-name: sleep\n";
echo "execute-app-arg: 350\n";
echo "event-lock:true\n\n";

// Play a prompt at the beginning of the page/conference
echo "sendmsg\n";
echo "call-command: execute\n";
echo "execute-app-name: set\n";
echo "execute-app-arg: tmp=\${conference $1 play /usr/local/freeswitch/sounds/tones/norstar.wav}\n\n";

fclose($in);

?>
Code Block
titlepage_outcall.lua
require "luasql.postgres"

-- Exit if no argument
if argv[1] == nil then
	print ("One argument is required")
	os.exit(0)
end

-- Get current epoch
today = os.time()
-- Connect to DB, get page info
env = assert (luasql.postgres())
con = assert (env:connect("conftest","conftest","password123","localhost"))
cur = assert (con:execute("SELECT entry_id, page_group, sip_uri, extract(epoch FROM page_timeout) FROM page_data WHERE page_group = " .. argv[1]))
row = cur:fetch ({}, "a")
page_table = {}
i = 1

-- iterate through list of extensions to be paged and discard those on timeout
while row do
	if tonumber(row.date_part) > today then
		$${hold_music}"/>
      <param name="enter-sound" value=""/>
      <param name="exit-sound" value=""/>
      <param name="kicked-sound" value=""/>
      <param name="locked-sound" value="conference/conf-locked.wav"/>
      <param name="is-locked-sound" value="conference/conf-is-locked.wav"/>
      <param name="is-unlocked-sound" value="conference/conf-is-unlocked.wav"/>
      <param name="pin-sound" value="conference/conf-pin.wav"/>
      <param name="bad-pin-sound" value="conference/conf-bad-pin.wav"/>
      <param name="caller-id-name" value="$${outbound_caller_name}"/>
      <param name="caller-id-number" value="$${outbound_caller_id}"/>
      <param name="comfort-noise" value="true"/>
    </profile>
Note

Be sure to create a gateway pointing to you FreeSWITCH server in sipXecs and point the appropriate numbers to it

Add the following to your FreeSWITCH dialpan (change expressions to meet your needs):

Code Block
   <extension name="Page Test">
     <condition field="destination_number" expression="^(3402)$">
      <action application="lua" data="/usr/local/freeswitch/scripts/page_outcall.lua $1"/>
      <action application="set" data="ivr_path=/usr/local/freeswitch/scripts/page_int.php"/>
      <action application="socket" data="127.0.0.1:9090 async full"/>
     </condition>
   </extension>

   <extension name="outbound-socket">
      <condition field="destination_number" expression="^(3403)$">
      <action application="lua" data="/usr/local/freeswitch/scripts/page_time_set.lua"/>
    </condition>
   </extension>

now reload FreeSWITCH

Add the following scripts to your /usr/local/freeswitch/scripts folder:

Code Block
titlepage_int.php
#!/usr/bin/php -q

<?php

// set a couple of things so we dont kill the system
ob_implicit_flush(true);
set_time_limit(30);

// Open stdin so we can read the data in
$in = fopen("php://stdin", "r");

// Connect to conference

echo "sendmsg\n";
echo "call-command: execute\n";
echo "execute-app-name: set\n";
echo "execute-app-arg: conference_auto_outcall_flags=mute\n\n";

echo "sendmsg\n";
echo "call-command: execute\n";
echo "execute-app-name: set\n";
echo "execute-app-arg: api_hangup_hook=conference $1 kick all\n\n";

echo "sendmsg\n";
echo "call-command: execute\n";
echo "execute-app-name: conference\n";
echo "execute-app-arg: $1@intercom\n\n";

echo "sendmsg\n";
echo "call-command: execute\n";
echo "execute-app-name: sleep\n";
echo "execute-app-arg: 350\n";
echo "event-lock:true\n\n";

// Play a prompt at the beginning of the page/conference
echo "sendmsg\n";
echo "call-command: execute\n";
echo "execute-app-name: set\n";
echo "execute-app-arg: tmp=\${conference $1 play /usr/local/freeswitch/sounds/tones/norstar.wav}\n\n";

fclose($in);

?>
Code Block
titlepage_outcall.lua
require "luasql.postgres"

-- Exit if no argument
if argv[1] == nil then
	print ("One argument is required")
	os.exit(0)
end

-- Get current epoch
today = os.time()
-- Connect to DB, get page info
env = assert (luasql.postgres())
con = assert (env:connect("conftest","conftest","password123","localhost"))
cur = assert (con:execute("SELECT entry_id, page_group, sip_uri, extract(epoch FROM page_timeout) FROM page_data WHERE page_group = " .. argv[1]))
row = cur:fetch ({}, "a")
page_table = {}
i = 1

-- iterate through list of extensions to be paged and discard those on timeout
while row do
	if tonumber(row.date_part) > today then
		print ("Skipping")
        -- keeps system from paging the pager :-P
        elseif row.sip_uri == sipuri then
                print ("Skipping")
	else
		page_table[i] = row.sip_uri
	end
	row = cur:fetch(row, "a")
	i = i + 1
end

-- Close DB connection as we won't be needing it anymore
cur:close()
con:close()
env:close()

session:answer()
cidname = session:getVariable("caller_id_name")
session:execute("export", "sip_invite_params=intercom=true")
session:execute("export", "sip_auto_answer=true")
session:execute("set", "conference_auto_outcall_caller_id_name=Page From " .. cidname)
session:execute("set", "conference_auto_outcall_caller_id_number=" .. argv[1])
session:execute("set", "conference_auto_outcall_timeout=60")

-- Make the calls
for i,v in pairs (page_table) do
	session:execute("conference_set_auto_outcall", "{alert_info=sipXpage}sofia/custom_dialplan/" .. v .. ";sipx-noroute=VoiceMail;sipx-userforward=false+flags")
end

...