From the twilio documentation and tutorial an agent would have no idea that someone was in the queue, so this only works if there is always someone in the queue and agents just sit there and field calls all day.
Objective:
When someone calls I would like to connect the call to the agent. If the agent isn't available, add the caller to a queue. If a second or third person calls, keep adding them to the queue. When the agent finishes their first call and hangs up, let the next in line call and actually ring the agent's phone to speak with the agent.
I'm really new to twilio so this twiml is bad and I already know this doesn't work, but here's what I'm trying so far:
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Enqueue waitUrl="contactagent.php">myqueue</Enqueue>
</Response>
contactagent.php:
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('../callapp/Services/Twilio.php'); // Loads the library
$sid = "(MYID)";
$token = "(MyToken)";
$client = new Services_Twilio($sid, $token);
$call = $client->account->calls->create($_REQUEST['the caller that's in the queue'], "(the agent's phone number)", "connectagent.xml", array());
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<Response>
<Say>Your are number ".$_REQUEST['QueuePosition']." in line for a representative.</Say>
<Play>http://com.twilio.sounds.music.s3.amazonaws.com/MARKOVICHAMP-Borghestral.mp3</Play>
</Response>"
?>
connectAgent.xml
<?xml version='1.0' encoding='utf-8' ?>
<Response>
<Dial>myqueue</Dial>
</Response>