Get Started

IVR: Call Screening and Recording

Building off the basic IVR we created in the last sections, we can easily add features commonly found in sophisticated IVRs, such as call screening (often referred to as "whisper") and recording.

Prior Sections

This is part three of a five part series on building IVRs using Twilio's API. If you're just joining us, you can find links to the prior sections below:

Usage

When a customer dials into our IVR and decides to speak to an agent, the call is forwarded to the agent's desk phone. Before the calls are connected, the caller is informed that the call will be recorded, and the agent is given the option to accept or reject the call.

Fun fact: this method of speaking or prompting one caller without the other hearing is called "whispering".

Concepts

This demo shows how to implement call screening and recording using Twilio's <Dial> and <Number> verbs.

Download

IVR.zip

Implementation

  • 1

    • Our Twilio number's Voice URL is set to handle-incoming-call.xml. When someone calls the number, Twilio will request this page with the standard TwiML request parameters.
    • howtos/ivr/code/ivrs-call-screening-and-recording/handle-incoming-call.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <Response>
      	<Gather action="handle-user-input.php" numDigits="1">
      		<Say>Welcome to TPS.</Say>
      		<Say>For store hours, press 1.</Say>
      		<Say>To speak to an agent, press 2.</Say>
      		<Say>To check your package status, press 3.</Say>
      	</Gather>
      	<!-- If customer doesn't input anything, prompt and try again. -->
      	<Say>Sorry, I didn't get your response.</Say>
      	<Redirect>handle-incoming-call.xml</Redirect>
      </Response>
          
  • 2

    • The application responds in TwiML to Twilio's request using the Say and Gather verbs. This instructs Twilio to prompt the customer and gather their input.
    • howtos/ivr/code/ivrs-call-screening-and-recording/handle-user-input.php
      	else if ($user_pushed == 2)
      	{
      		echo '<Gather action="handle-extension.php" numDigits="1">';
      		echo "<Say>Please enter your party's extension.</Say>";
      		echo '<Say>Press 0 to return to the main menu</Say>';
      		echo '</Gather>';
      		echo "<Say>Sorry, I didn't get your response.</Say>";
      		echo '<Redirect method="GET">handle-user-input.php?Digits=2</Redirect>';
      	}
          
  • 3

    • Twilio prompts the user and gathers their input. This input is then sent back to your application as an HTTP request.
  • 4

    • Your server processes the customer input and connects the caller to an agent. Before both parties are connected, the caller is informed that the call will be recorded and the agent is asked accept or reject the call.
    • howtos/ivr/code/ivrs-call-screening-and-recording/screen-caller.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <Response>
      	<Gather action="handle-screen-input.php" numDigits="1">
      		<Say>You have an incoming call.</Say>
      		<Say>To accept the call, press 1.</Say>
      		<Say>To reject the call, press any other key.</Say>
      	</Gather>
      	<!-- If customer doesn't input anything, prompt and try again. -->
      	<Say>Sorry, I didn't get your response.</Say>
      	<Redirect>screen-caller.xml</Redirect>
      </Response>
          

This is part three of a five part series on building IVRs using Twilio's API. When you're ready continue on to the next section: