How do I get twilio to call the agent to connect them to callers in the queue?

时光总嘲笑我的痴心妄想 提交于 2019-12-30 09:53:09

问题


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>

回答1:


I think you should put all of your client calls to the queue (no matter first client or not). Do it using Enqueue. That is good then.

Next, you need to initiate a call to an agent. You can instruct Twilio to call agent's phone number. In that instruction define a callback url "dial_agent_callback" and a status callback url "dial_agent_status_callback". Once the "dial_agent_callback" callback occurs (indicating that agent has picked up), you instruct Twilio to dial your queue:

<Response>
   <Dial>
      <Queue url="dial_queue_callback">
         myqueue
      </Queue>
   </Dial>
<Response>

You can know when an agent has finished talking to a client in a dial_queue_status_callback (or if agent has not picked up, or if any problems occurred). The callback Status will indicate what has happened.

Finally, you need to figure out when to trigger calls to the agent. I suggest triggering an event when a client call occurs. Call your next available agent, if there is one. In case there are more clients than agents you can check the Queue Size using Twilio API. Then you can trigger a new call to an agent when a new agent joins, or when a busy agent finishes handling client call.

I hope that helps.



来源:https://stackoverflow.com/questions/18420812/how-do-i-get-twilio-to-call-the-agent-to-connect-them-to-callers-in-the-queue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!