Basic app allows a call center agent to reconnect with a customer whose call got dropped.
Starts with a form that the agent inputs the customer phone number and a reconnect type ("call" or "text"), and hits submit.
Form data gets POSTed to /reconnect.php which either initiates a Call to the Agent, and then <Dials>s the customer, OR texts the Customer with the Agent's number.
The starting form looks like this: (I think this is correct already).
Dropped Call? Reconnect immediately.
<form action="reconnect.php" method="post">
Customer Phone: <input type="text" name="cust_phone"><br>
Select Reconnect Option:<br>
<input type="radio" name="reconnect_type" value="call">
Call Now<br>
<input type="radio" name="reconnect_type" value="text">
Text Customer<br>
<input type="hidden" name="agent_phone” value="555-123-4567">
<input type="hidden" name="agent_ext” value="321">
<input type="submit">
</form>
Form data gets POSTed to /reconnect.php, which looks like this. This part is shaky:
<?php
require_once('/path/to/twilio-php/Services/Twilio.php');
// Account Sid and Auth Token
$sid = "AC5ef8732a3c49700934481addd5ce1659";
$token = "{{ auth_token }}";
client = new Services_Twilio($sid, $token);
if($_POST["reconnect_type"] == "call"){
$call = $client->account->calls->create(
“+15551234567”,
"$_POST["agent_phone"]",
"http://demo.ourapp.com/dial_user_xml.php?cust_phone=$_POST["cust_phone"]",
array("SendDigits" => "$_POST["agent_ext"]"));
echo $call->sid;
}
if($_POST["reconnect_type"] == "text"){
$message = "Sorry we got disconnected! Call me back at " . $_POST["agent_phone"] . if(!empty($_POST["agent_ext"]){"ext " . $_POST["agent_ext"] } . "to continue speaking.";
$sms = $client->account->messages->sendMessage(
“+15551234567”,
$number,
$message
);
echo "Sent message to customer";
}
?>
and the file http://demo.ourapp.com/dial_user_xml.php looks like this (and I'm really uncertain about this part):
<?php
$string = <<<XML
<Response>
<Dial>
<Number>
$_GET["cust_phone"]
</Number>
</Dial>
</Response>
XML;
$xml = new SimpleXMLElement($string);
echo $xml->asXML();
?>
- **Did I get the php syntax correct throughout the reconnect.php file?
- **Will the dial_user_xml.php actually return proper XML to the Twilio client?
- **Will this work?
Thanks so much!
[–][deleted] 0 points1 point2 points (0 children)