0

I am using the Twilio php library to implement the calling .. I am running through an issue .. the issue is that .. I am using the following code to redirect the call to a particular url

require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

$sid = "ACXXXXX"; 
$token = "YYYYY"; 
$client = new Services_Twilio($sid, $token);

$call = $client->account->calls->get("CAe1644a7eed5088b159577c5802d8be38");
$call->update(array(
    "Url" => "example.php",
    "Method" => "POST"
)); 

and after redirecting, I am telling the machine to speak particular text using the following code

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Say>Hello</Say>
</Response>

but the problem is that after saying the text.. the call gets disconnected because after the <Say> keyword there is no more TwiML to get executed ..I want the call to return to its previous state after this but I am not able to find out how to implement this .. Please help me with this..

dinotom
  • 4,990
  • 16
  • 71
  • 139
Vivek Bhardwaj
  • 530
  • 5
  • 16

1 Answers1

1

What is happening is that after the <Say> verb Twilio sees no more actions and it ends the call. If you want to to something after you could <Redirect> the call to a new url and execute other comands, or if you just want to keep the caller on hold consider dialing into a conference room:

<Response>
  <Dial>
    <Conference>Room 1234</Conference>
  </Dial>
</Response>

Using the redirect will look something like this:

<Response>
    <Say>Hello</Say>
    <Redirect>http://www.your-url.com</Redirect>
</Response>

Inside http://www.your-url.com you should have the next command to execute. For example if you wanted to sit the caller in a conference room while you fetch another caller to join, you could use the <Conference> verb:

<Response>
  <Dial>
    <Conference>Friendly_Conference_Room_Name</Conference>
  </Dial>
</Response>

If you wanted to play a sound file for the caller then http://www.your-url.com would look something like this:

<Response>
    <Play loop="10">https://api.twilio.com/cowbell.mp3</Play>
</Response>
ecorvo
  • 3,559
  • 4
  • 24
  • 35
  • i am aware about the code that you have used over here .. i am confused regarding the "http://www.your-url.com" .. which url should i have to put over here .. can you please help me with this – Vivek Bhardwaj May 03 '16 at 07:32
  • the URL should be where you want to take the call next. You can think of the lifecycle of a twilio call as either one URL or a series of URLs that each executes one or more commands. See my edit, I showed examples of what could go inside "your-url.com" – ecorvo May 05 '16 at 16:32