How do I get twilio to call an agent to connect to callers in a queue?

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> 
+4
source share
1 answer

I think you should queue all your client calls (regardless of the first client or not). Do this with Enqueue. Then it’s good.

Then you need to initiate an agent call. You can instruct Twilio to call the agent number. In this instruction, define the dial_agent_callback callback URL and the dial_agent_status_callback status callback URL. When the dial_agent_callback callback occurs (indicating that the agent has raised), you instruct Twilio to dial your queue:

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

You can find out when the agent ended the conversation with the client at dial_queue_status_callback (or if the agent did not raise it or there were any problems). The callback status will show what happened.

Finally, you need to figure out when to call agent calls. I suggest initiating an event when a client is called. Call your next available agent, if any. If there are more clients than agents, you can check the queue size using the Twilio API. You can then initiate a new agent call when a new agent connects or when a busy agent completes processing a client call.

I hope this helps.

+3
source

Source: https://habr.com/ru/post/1498744/


All Articles