On Sunday, June 24, 2012 at 10:54 PM, Anthony Minessale wrote:
Thanks for the positive comment. =DBTW, that reminds me. I added a new pickup endpoint that you mightwant to have a look at as well.It lets you add a special pickup endpoint to a forked dial so say youare calling ext 1000, you can do<action application="bridge" data="user/1000,pickup/1000"/>Then from another call you can execute:<action application="pickup" data="1000"/>And your channel will be returned to that unanswered originate.We should probably get it documented.On Sat, Jun 23, 2012 at 9:29 AM, Frank Busalacchi Jr<frankjr@mcpeekdodge.com> wrote:Over the last 6 months, I have received all kinds of support and help fromthe freeswitch community (both IRC and this list) in learning to controlthis incredible piece of software. Im truly grateful, thanks everyone.I run freeswitch at my car dealership. We have approximately 40 sipextensions, an ATT voip connection, and 6 analog outbound fax lines providedby freetdm. Prior to freeswitch, I was running an old Lucent/Avaya Merlin"key" system. One of the features of the Merlin was that it was pretty easyto do "directed callpick". In essence, you would dial *7 + extension youwanted to pickup. Provided the call was either on hold or ringing at thatextension, you would pick it up. When I first started using Freeswitch, Iwas very disappointed in the directed callpick. Before I realized that thecall pickup that was built into the sample dialplan was really just anexample to show a simple possibility for using intercept. I was convincedthat it was a totally useful feature. I couldn't believe that was as goodas it got... My problem with the directed pickup that is in the sampledialplan is that it can steal a live call right from another extension, aswell as it really only works with the most recent call on that extension.Then I woke up, and rolled my own 8-) . In an effort to provide justanother example, I wanted to share the piece of code I've developed. I willwarn that this was the first perl script I have ever written, and probablyis pretty ugly, but it seems to work perfectly in our environment. Bottomline, do what you want with it...I'm just trying to help other beginner'slike myself:To all beginners: You will need to build and enable mod_perl for this towork...First, we need an entry in your XML dialplan to see the user's request tointerecept a "held" or "ringing" extension. The only 4 digit extensions atmy company are internal ones so I match on ** + 4-digit-extension.In the xML dialplan:<extension name="intercept-ext"><condition field="destination_number" expression="^\*\*(\d{4})$"><action application="answer"/><action application="perl"data="/usr/local/freeswitch/scripts/myintercept.pl $1"/><action application="sleep" data="2000"/></condition></extension>Then, we need the actual perl script:/usr/local/freeswitch/scripts/myintercept.pl:# This is code to allow us to use intercept to grab only calls that are onhold or ringing.## by Frank Busalacchi 2012-06-13use strict;use Switch;use Data::Dumper;use XML::Simple;use POSIX qw(strftime);our $session;{my $dest_target = $ARGV[0];my $api = new freeswitch::API();my $xml = new XML::Simple;my $chan_xml = $xml->XMLin($api->executeString("show detailed_calls asxml"),KeyAttr => 'row', ForceArray => ['row']);my %candidates;my $result;foreach my $row (@{$chan_xml->{row}}) {if ($row->{callstate} eq "RINGING" && $row->{dest} eq $dest_target){$candidates{ $row->{created_epoch} - 1000 } =$row->{call_uuid}; #In the case of a tie, we want to pickup ringingcalls before held calls...next;}elsif ($row->{callstate} eq "HELD" && $row->{b_sent_callee_num} eq$dest_target ) {$candidates{ $row->{created_epoch} } = $row->{b_uuid};next;}elsif ($row->{b_callstate} eq "HELD" && $row->{b_callee_num} eq$dest_target ) {$candidates{ $row->{b_created_epoch} } = $row->{uuid};next;}}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');for my $winner ( sort keys %candidates ) {my $uuid= $candidates{$winner};$result = "[Intercept]User:$user" . "[" . "$cid_num" . "]intercepting Extension:$dest_target" . ". UUID:" . "$uuid" . "\n";freeswitch::consoleLog("INFO","$result\n");$session->execute("intercept",$uuid);last;}}1;}Enjoy!-Frank_________________________________________________________________________Professional FreeSWITCH Consulting Services:FreeSWITCH-powered IP PBX: The CudaTel Communication ServerOfficial FreeSWITCH SitesJoin Us At ClueCon - Aug 7-9, 2012FreeSWITCH-users mailing list--Anthony Minessale IIFreeSWITCH http://www.freeswitch.org/ClueCon http://www.cluecon.com/Twitter: http://twitter.com/FreeSWITCH_wireAIM: anthmGTALK/JABBER/PAYPAL:anthony.minessale@gmail.comIRC: irc.freenode.net #freeswitchFreeSWITCH Developer Conferencegoogletalk:conf+888@conference.freeswitch.orgpstn:+19193869900_________________________________________________________________________Professional FreeSWITCH Consulting Services:FreeSWITCH-powered IP PBX: The CudaTel Communication ServerOfficial FreeSWITCH SitesJoin Us At ClueCon - Aug 7-9, 2012FreeSWITCH-users mailing list