Book Image

Elastix Unified Communications Server Cookbook

Book Image

Elastix Unified Communications Server Cookbook

Overview of this book

Table of Contents (24 chapters)
Elastix Unified Communications Server Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Description and Use of the Most Well-known FreePBX Modules
Addon Market Module
Asterisk Essential Commands
Asterisk Gateway Interface Programming
Helpful Linux Commands
Index

Creating an advanced IVR using Asterisk AGI and Asterisk's Dialplan


This recipe will allow us to create an IVR that will store the code or digits entered by the user in a database. Then, the program will display these digits. For the purposes of this section, we will use SQLite3 as the database engine.

How to do it…

  1. Create a database using the following commands in the Linux console:

    cd /var/www/db
    sqlite3 ivr.db
    
  2. Create a table while in the SQLite3 console with the following command:

    CREATE TABLE ivr-data (callerid INT NOT NULL, data INT NOT NULL);
    
  3. To quit the console, type .quit.

  4. Set the proper execution rights and ownership to the database with the following commands: chown asterisk:asterisk ivr.db.

  5. Add the proper recordings using the Recordings module.

  6. Create the ivr.php file in the /var/lib/asterisk/agi-bin/ folder with the following content:

    #!/usr/bin/php -q
    <?php
    
    set_time_limit(60);
    ob_implicit_flush(false);
    error_reporting(0);
    $stdin = fopen( 'php://stdin', 'r' );
    $stdout = fopen(...