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

Screening calls


Call screening is a useful ability to have on your calling systems. For example, let's say you have three people on call in your support department and you want to call the first available agent.

This recipe will try and connect to each phone number available in a given array and check to see if a person answers or not; if a person does, it connects the call.

Getting ready

The complete source code for this recipe can be found in the Chapter2/Recipe2 folder.

How to do it...

We're going to build a call-handling system that will forward calls to our list of agents; the first agent who accepts the call by pushing a button will get the call.

  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. Upload config.php to your website and make sure the following variables are set:

    <?php
      $accountsid = '';  //  YOUR TWILIO ACCOUNT SID
      $authtoken = '';  //	YOUR TWILIO AUTH TOKEN
      $fromNumber...