[Freeswitch-users] Asterisk AGI.PL Total Noob HELP plz...

Diego Viola diego.viola at gmail.com
Sat May 2 06:20:45 PDT 2009


Hi Edward,

You could use perl from the dialplan or use the Event socket, or ESL,
I use the event socket with a ruby library called freeswitcher and it
works really well.

Just take a look at the wiki (http://wiki.freeswitch.org/) for more
info and/or ask us for help at #freeswitch @irc.freenode.net.

Hope that gives some idea to you.

Regards,

Diego

On Fri, May 1, 2009 at 8:26 PM, Edward Q. <q.edward at gmail.com> wrote:
> Hi guys ..
>
> I am a total noob on all this FS and asterisk thing ..
> I have a system already running on Asterisk and i want to migrate it to FS
> I have an AGI made in perl that runs everytime and i need to be at least
> pointed out on how i can approach on transferring this to FS
>
> Here is the AGI .. its simple ...
>
>
> #!/usr/bin/perl
> use Asterisk::AGI;
> use DBI;
> use strict;
>
> my $AGI = new Asterisk::AGI;
> my %input = $AGI->ReadParse();
> $input{'callerid'} =~ /(^.+<(\d+)>$)|((^\d+$))/;
> $input{'calleridani'} = $2 || $3;
> #my $userid = $input{'calleridani'};
> my $userid=$input{'extension'};
> #my $userid='1001';
> # Config options
> my %MYSQL = (
>     hostname    =>    "localhost",
>     username    =>    "callmeuser",
>     password    =>    "mycallmepass",
>     database    =>    "executives"
> );
>
> my $dbh =
> DBI->connect("dbi:mysql:$MYSQL{database}:$MYSQL{hostname}","$MYSQL{username}","$MYSQL{password}")||
> die("Couldn't connect to database!\n");
> #============
> $AGI->verbose("Connected to database.");
> $AGI->verbose("Call for : $userid");
> #======
>
>
>  print STDERR "$userid";
>  print STDERR "hello testing db connected";
> my $debug=2;
> my $phone="";
> #debug("Connect to database");
> #debug("Transferred call, using original cid: $name",5);
> my $str ="select phone from timetable where exten='$userid' and online='Y'
> ";
> $AGI->verbose("Checking if $userid is online right now and get his phone
> number from db.");
> $AGI->verbose("$str");
> print STDERR "$str";
> my $sth =$dbh->prepare($str);
> $sth->execute || die("Couldn't exec sth2!");
> #my $pin = $sth->fetchrow_hashref;
> #print STDERR "xxxx";
> #print STDERR "$pin";
>
> while (my @row = $sth->fetchrow_array)
> {
> $phone = $row[0];
> print STDERR "xxxx";
> print STDERR "$phone";
> print STDERR "vvvvx";
> $AGI->verbose("$userid is online and his phone number is $phone");
> #$AGI->exec('DIAL', "SIP/$phone");
>  }
> if  ($phone!="")
>
> {
> $AGI->verbose("Calling  $userid at $phone");
> my $dialstr="SIP/$phone"."@"."209.9.9.34";
> $AGI->set_callerid(7347777777);
>
> $AGI->exec('DIAL', $dialstr);
> my $st=$AGI->get_full_variable('status',$dialstr);
> $AGI->verbose("channel status is : $st");
> }
>
> else
>
> {
> $AGI->verbose("$userid is not online.");
> #$AGI->stream_file('custom/myrecording');
> $AGI->stream_file('followme/sorry');
> $AGI->stream_file('en/vm-nobodyavail');
> }
>
> $AGI->hangup();
>
>
> Thanks everyone for all the help.
> Ed
>
> _______________________________________________
> 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
>
>




More information about the FreeSWITCH-users mailing list