Dave Wilson
2003-Aug-13 03:27 UTC
[Asterisk-Users] How do i configure so an incoming call triggers an http request?
Hi all, I'm about to start setting up my first asterisk/cti system in our test lab. I've read through all the documentation I can find and relevant posts in the list archives but can't seem to find anything explaining how to go about initiating an http request upon an incoming call. I basically want asterisk to request an uri on our intranet, which will pass call details to our application and consequently store call details in a MS SQL Server database. Of course, if there are tools available for directly interacting with the database via odbc, then that would be excellent, however we still want to be able to trigger http requests for various other features. Any pointers welcome. Dave
Alastair Maw
2003-Aug-13 03:48 UTC
[Asterisk-Users] How do i configure so an incoming call triggers an http request?
Dave Wilson wrote:> I basically want asterisk to request an uri on our intranet, which will pass > call details to our application and consequently store call details in a MS > SQL Server database. Of course, if there are tools available for directly > interacting with the database via odbc, then that would be excellent, > however we still want to be able to trigger http requests for various other > features.It's not terribly efficient (starts up a Perl interpreter for every incoming call), but you can do this with AGI, something like: extensions.conf --------------- [default] s,1,AGI(log-call.pl) log-call.pl ----------- #!/usr/bin/perl use DBI; use Asterisk::AGI; my $agi = new Asterisk::AGI; my $dbh = DBI->connect('DBI:mssql:database:hostname', 'user', 'pass') or die %DBI::errstr; my $clid = $agi->get_variable('CALLERID'); my $dnid = $agi->get_variable('DNID'); my $add_date = time(); $sql = "INSERT INTO call (call_from, call_to, add_date) values ('$myclid', '$mydnid', FROM_UNIXTIME($add_date));"; $sth = $dbh->prepare($sql) or die $sth->errstr(); $sth->execute() or die $sth->errstr(); $dbh->disconnect(); Sort of thing. Obviously you could use LWP or similar in Perl to do HTTP GETs, or just write a bash script which used wget to do an HTTP GET, which would be much more efficient. -- Alastair Maw <al.maw@mxtelecom.com> MX Telecom - Systems Analyst http://www.mxtelecom.com