[Freeswitch-users] Call Intercept
Lloyd Aloysius
lloyd.aloysius at sunteltech.ca
Sun Aug 4 20:00:30 MSD 2013
scripting language is not an issue.
Change the following
<action application="set" data="intercept_unbridged_only=false"/>***
*
to
<action application="set" data="intercept_unbridged_only=true"/>
comment the following
<action application="set" data="intercept_unanswered_only=false"/>
You can pickup a ringing phone.
*
*
* *
On Sun, Aug 4, 2013 at 11:42 AM, Frank Busalacchi Jr <
frankjr at mcpeekdodge.com> wrote:
> Thanks for the replies.****
>
> ** **
>
> First off, I got my scripting languages confused. My intercept script is
> actually done in perl, not lua (See below).****
>
> ** **
>
> Also,****
>
> ** **
>
> Loyd said: “I use this way and it always
> works session:execute("set","intercept_unbridged_only=true")”****
>
> ** **
>
> I’m trying to make my intercept script be able to intercept any call that
> is either ringing, or on hold. I don’t want to be able to intercept a live
> call. If I set “intercept_unbridged_only” it seems to me that I will be
> unable to pick up a ringing call? Worth a try though…****
>
> ** **
>
> Chris said: That channel variable was fetched in the routing state
> before the lua application was executed. You can either transfer to a new
> extension to execute the intercept or execute the intercept in the lua
> script. ****
>
> ** **
>
> If I am understanding you correctly, you are referring to the
> “intercept-uuid” variable I am setting in the perl script. I agree with
> you regarding the routing state vs. the execute state, but In the pastebin
> that I posted, line 259 shows that the perl script has made its choice of
> what UUID to “intercept”, and in line 299, the XML dialplan actually calls
> intercept with the UUID the script suggested. Also, I originally was
> calling intercept in the perl script, but when I couldn’t get it to work, I
> switched to the combo method below in a desperate attempt for success. Am
> I misinterpreting this somehow?****
>
> ** **
>
> ***** XML Dialplan Portion of intercept.... *********
>
> ** **
>
> <include>****
>
> ** **
>
> <extension name="intercept-ext">****
>
> <condition field="destination_number" expression="^\*\*(\d{4})$">***
> *
>
> <action application="set" data="intercept_unbridged_only=false"/>*
> ***
>
> <action application="set" data="intercept_unanswered_only=false"/>
> ****
>
> <action application="perl" data="${base_dir}/scripts/
> myintercept2.pl $1"/>****
>
> <action application="answer"/>****
>
> <action application="intercept" data="${intercept-uuid}"/>****
>
> <action application="sleep" data="2000"/>****
>
> </condition>****
>
> </extension>****
>
> ** **
>
> </include>****
>
> ** **
>
> **** Perl Script to find UUID of extension to intercept *********
>
> ** **
>
> use strict;****
>
> use Switch;****
>
> use Data::Dumper;****
>
> use XML::Simple;****
>
> use POSIX qw(strftime);****
>
> our $session;****
>
> ** **
>
> {****
>
> my $debug = "true";****
>
> ** **
>
> my $dest_target = $ARGV[0];****
>
> my $api = new freeswitch::API();****
>
> ** **
>
> my $uuid = $session->getVariable('uuid');****
>
> ** **
>
> my $detailed_calls = $api->executeString("show detailed_calls as xml");
> ****
>
> my $xml = new XML::Simple;****
>
> my $chan_xml = $xml->XMLin($detailed_calls,KeyAttr => 'row',
> ForceArray => ['row']);****
>
> ** **
>
> my %candidates;****
>
> my $reTarget = "sofia\/internal\/(sip:)*" . $dest_target . ".*";****
>
> my $result;****
>
> ** **
>
> ** **
>
> #--------------------------------------****
>
> if ($debug eq "true") {****
>
> freeswitch::consoleLog("INFO","\n----------intercept debug
> info-------------\n");****
>
> freeswitch::consoleLog("INFO",$detailed_calls);****
>
> freeswitch::consoleLog("INFO","\n----------end intercept debug
> info-------------\n");****
>
> }****
>
> ** **
>
> #-- Loop through all the rows from show detailed_calls and put em in a
> hash...****
>
> #-- Ringing lines are our first choice so make sure their hash key is
> "sortably" lower than a held call****
>
> #-- Since we will sort the hash, and take the first sorted entry as
> the uuid to snag...****
>
> ** **
>
> foreach my $row (@{$chan_xml->{row}}) {****
>
> ** **
>
> if ($row->{callstate} eq "RINGING" && $row->{name} =~ $reTarget ) {
> ****
>
> $candidates{ $row->{created_epoch} - 1000 } = $row->{uuid};**
> **
>
> ** **
>
> if($debug eq "true") {****
>
> freeswitch::consoleLog("INFO","Found intercept
> candidate.\nRINGING line for target:" . $dest_target .****
>
> " uuid:" . $row->{uuid} . "
> call-uuid:" . $row->{call_uuid} . "\n");****
>
> }****
>
> }****
>
> ** **
>
> elsif ($row->{callstate} eq "HELD" && $row->{name} =~ $reTarget ) {
> ****
>
> $candidates{ $row->{b_created_epoch} } = $row->{b_uuid};****
>
> ** **
>
> if($debug eq "true") {****
>
> freeswitch::consoleLog("INFO","Found intercept
> candidate.\nHELD line for target:" . $dest_target .****
>
> " b_uuid:" . $row->{b_uuid} . "
> b_call-uuid:" . $row->{b_call_uuid} . "\n");****
>
> }****
>
> }****
>
> ** **
>
> elsif ($row->{b_callstate} eq "HELD" && $row->{b_name} =~
> $reTarget ) {****
>
> $candidates{ $row->{created_epoch} } = $row->{uuid};****
>
> if($debug eq "true") {****
>
> freeswitch::consoleLog("INFO","Found intercept
> candidate.\n HELD line for target:" . $dest_target .****
>
> " uuid:" . $row->{uuid} . "
> call-uuid:" . $row->{call_uuid} . "\n");****
>
> }****
>
> }****
>
> }****
>
> ** **
>
> if( keys( %candidates ) == 0) {****
>
> $result = "[Intercept] No suitable channel to intercept on
> extension $dest_target.";****
>
> freeswitch::consoleLog("INFO","$result\n");****
>
> }****
>
> else {****
>
> my $user = $session->getVariable('caller_id_name');****
>
> my $cid_num = $session->getVariable('caller_id_number');****
>
> my $winner_uuid;****
>
> ** **
>
> for my $winner ( sort keys %candidates ) {****
>
> $winner_uuid = $candidates{$winner};****
>
> last;****
>
> }****
>
> ** **
>
> $session->setAutoHangup(0);****
>
> freeswitch::consoleLog("INFO","INTERCEPT called by Ext:"
> .$cid_num. " INTERCEPTING Ext:" .$dest_target. " uuid:".$winner_uuid .
> "\n");****
>
> $session->setVariable("intercept-uuid",$winner_uuid);****
>
> }****
>
> return 1;****
>
> }****
>
> ** **
>
> -F****
>
> ** **
>
> *From:* cmrienzo at gmail.com [mailto:cmrienzo at gmail.com]
> *Sent:* Sunday, August 04, 2013 3:50 AM
> *To:* FreeSWITCH Users Help
> *Subject:* Re: [Freeswitch-users] Call Intercept****
>
> ** **
>
> That channel variable was fetched in the routing state before the lua
> application was executed. You can either transfer to a new extension to
> execute the intercept or execute the intercept in the lua script. ****
>
> ** **
>
> Chris****
>
> ** **
>
>
> On Aug 3, 2013, at 11:51 PM, Frank Busalacchi Jr <frankjr at mcpeekdodge.com>
> wrote:****
>
> Hi everyone! First and foremost, thanks for a great piece of software,
> and all the time you guys still put into this program day in and day out.
> Thank you!****
>
> ****
>
> I'm having difficulty implementing an "intercept" system, and I'm thinking
> that I have to be "conceptually" misunderstanding something. Towards those
> ends, I'm hoping someone can get me back on track, I’m sick of banging my
> head on the wall to try to make this work.****
>
> ****
>
> So here is my scenario:****
>
> ****
>
> 1. A call (Call A) comes into the server from my voip provider on a DID.**
> **
>
> ****
>
> 2. My XML dialplan transfers the call to an extension in the XML dialplan
> of 1111.****
>
> ****
>
> 3. My XML dialplan recognizes 1111 as a local extension, and executes a
> LUA script to handle the actual bridging of Call A to the appropriate
> devices. I use the LUA script because I do some logic to decide whether to
> ring just the user's SIP phone, the user's cell phone, or a combination of
> both simultaneously. Bottom line is that the LUA script does something
> like this after building the originate string in dialString:****
>
> ****
>
> session2 = freeswitch.Session(dialString);****
>
> ****
>
> if session2:answered() == true then****
>
> freeswitch.bridge(session,session2);****
>
> return true;****
>
> else****
>
> return false;****
>
> end****
>
> ****
>
> ---All of the above works as expected ---****
>
> ****
>
> My issue is that when the LUA script starts ringing the sip phone
> registered as 1111, I want to 'intercept' that call from a different
> extension. So here is what I do:****
>
> ****
>
> 1. Extension 1112 hears that his co-worker's extension 1111 is ringing,
> and wants to answer it. He dials **1111****
>
> ****
>
> 2. My XML dialplan recognizes the request to pickup/intercept the call
> ringing at 1111, and calls a LUA script to figure out the uuid of the
> ringing phone.****
>
> ****
>
> 3. The LUA script sets a channel variable with the UUID it choose as the
> appropriate candidate to intercept, and exits.****
>
> ****
>
> 4. The XML dialplan resumes control, and does a <action
> application="intercept" data="${intercept-uuid}"/> .****
>
> ****
>
> 5. The calls aren't intercepted/bridged.****
>
> ****
>
> A pastebin of the log is here: http://pastebin.freeswitch.org/21267 ****
>
> ****
>
> What am I missing conceptually here?****
>
> ****
>
> ****
>
> Thanks,****
>
> Frank****
>
> ****
>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
>
>
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://wiki.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20130804/82fe9bfb/attachment-0001.html
Join us at ClueCon 2013 Aug 6-8, 2013
More information about the FreeSWITCH-users
mailing list