The following example is an AGI script that asks for a code when the user dials in. This code is used to query a database called balance. After the user enters the code, the balance is reproduced. If the user wants to send this data to a call center to get registered for special offers for instance, he/she will be asked to enter the phone number for calling back when any special offer becomes available. When this information is entered, an e-mail will be dispatched to the call center supervisor in order to book a call to the user whenever a special offer may apply.
The first step to take is to create a database and a table with the following structure in MySQL Database Engine:
CREATE TABLE balance( name VARCHAR NOT NULL, code INT NOT NULL, balance INT NOT NULL );
Add the following code in the
/var/lib/asterisk/agi-bin/
folder. In the previous sections, we described the process for using AGI-based programs to interact with our PBX. This is...