From the twilio documentation and the tutorial, the agent would not know that someone is in the queue, so this only works if there is always someone in the queue and the agents just sit there and field calls all day.
Goal:
When someone calls, I would like to connect the call to the agent. If the agent is unavailable, add the caller to the queue. If a second or third person calls, keep adding them to the queue. When the agent ends his first call and hangs up, let the next one on the call line and actually call the agent phone to talk to the agent.
I am really new to twilio, so this twiml is bad, and I already know that this does not work, but here is what I am trying to do 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 in the queue'], "(the agent 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>
source share