Book Image

Twilio Cookbook: Second Edition

By : Roger Stringer
Book Image

Twilio Cookbook: Second Edition

By: Roger Stringer

Overview of this book

Table of Contents (20 chapters)
Twilio Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Logging and reporting calls


Another important aspect of IVRs is the ability to log calls. This helps us to go back and see how many calls have come in and when.

When a call comes in, we will store the phone number and the date and time of the call.

We'll also build a basic monitor to view call logs.

Getting ready

The complete source code for this recipe can be found in the Chapter8/Recipe3/ folder.

How to do it…

Let's set up a simple call logging system that lets us track calls. When a caller calls in, we'll update our database with a log of the call. Then, we'll be able to open a page and view all the calls.

  1. Open sql.sql and load the schema into your database.

  2. Update config.php to your website and make sure your phone tree variables are set:

    <?php
      $dbhost = '';	//	YOUR DATABASE HOST
      $dbname = '';	//	YOUR DATABASE NAME
      $dbuser = '';	//	YOUR DATABASE USER
    $dbpass = '';	//	YOUR DATABASE PASS
    
      $directory = array(
        '1'=> array(
          'phone'=>'415-555-2222',
          'firstname' =&gt...