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 and recording calls


Ok, we've set up a basic IVR. Now let's expand it a little and include the ability for our agents to accept a call or not.

We'll also set it up to record calls, which is standard for most IVR systems.

When calls come in, the agent will be prompted to press 1 to accept the call or, otherwise, any other number to disconnect the call.

Getting ready

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

How to do it…

This recipe will let us screen and record the calls we take. When a call is connected to an agent, they will receive a prompt whether they want to accept the call or not. If they want to accept it, they will hit 1 and the call will be connected. Pressing any other key will reject the call and hang it up.

  1. First, update extensions.php as follows:

    <?php
      include("config.php");
      header('Content-type: text/xml');
      echo '<?xml version="1.0" encoding="UTF-8"?>';
      echo '<Response>';
      $user_pushed = (int) $_REQUEST...