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

Leaving a message


OK, instead of hanging up the call when an agent doesn't answer, let's forward them to a company voice mailbox.

Getting Ready

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

How to do it...

We're going to set this up so that, if a caller can't reach an agent, or just generally wants to leave a message, they can do so by pressing 5.

  1. Download the Twilio Helper Library from https://github.com/twilio/twilio-php/zipball/master and unzip it.

  2. Upload the Services/ folder to your website.

  3. Update config.php to your website and make sure the following variables are set:

    <?php
    $dbhost = '';//YOUR DATABASE HOST
    $dbname = '';//YOUR DATABASE NAME
    $dbuser = '';//YOUR DATABASE USER
    $dbpass = '';//YOUR DATABASE PASS
    
      $highrise_account = '';
      $highrise_apikey = '';
    
    
      $accountsid = '';//YOUR TWILIO ACCOUNT SID
      $authtoken = '';//YOUR TWILIO AUTH TOKEN
      $fromNumber = '';//	PHONE NUMBER CALLS WILL COME FROM
    
      $directory = array(
        '1'=> array(
    ...