Asterisk AGI

From Osnow

Jump to: navigation, search

Contents

PDF Companion piece

media:How_to_Write_a_Perl_AGI_Application.pdf

Getting to it

In extensions_custom.conf, add this text:

[custom-kiosk]
exten => s,1,AGI(kiosk.agi|${CALLERIDNUM})
exten => s,2,Playback(lots-o-monkeys) 
exten => s,3,Hangup

To dial it from inside, as *66 add this above it:

exten => *66,1,Answer
exten => *66,2,Goto(custom-kiosk,s,1)
exten => *66,3,Hangup

To dial as extension 1097 add this somewhere above the custom tag:

exten => 1097,1,Goto(custom-kiosk,s,1)

Inbound route in FreePBX

Get into FreePBX->Setup->Inbound Routes->DID page
Under Set Destination choose: Custom App and enter:

custom-kiosk,s,1

The App

#!/usr/bin/perl -w  
 
use Asterisk::AGI;
use DBI;

# Config options
#%MYSQL = (
#	hostname	=>	"localhost:3306",
#	username	=>	"asdf",
#	password	=>	"asdf",
#	database	=>	"asteriskdb"
#);

#$dbh = DBI->connect("dbi:mysql:$MYSQL{database}:$MYSQL{hostname}","$MYSQL{username}","$MYSQL{password}")
#	|| die("Couldn't connect to database!\n"); 

#
# We should throw an error down the channel and take care of it gracefully
#

my $AGI = new Asterisk::AGI;
#my %input = $AGI->ReadParse();

my $target	= 0;
my $try		= 0;

$AGI->exec('AGI',"festival-weather-script.pl|\"Thanks for calling the Real Estate EXPO Property Line. Enter your four digit property code, at any time.\"");

$AGI->exec('background', 'now');

exit;

Resources

http://trixbox.org
http://search.cpan.org/~jamesgol/asterisk-perl-0.09/lib/Asterisk/AGI.pm
http://asterisk.gnuinter.net/

Personal tools