0

I'm working in a project with Twilio to make and recieve calls. So, imagine you want to do a call, and in the other side we have 3 agents to take the call, with three twilio numbers. I want to show the inbound call only to one of the agents (randomly).

I'm not sure if to achieve this behaviour I should generate a different response with a different or a different of one of the agents.

For example:

response = Twilio::TwiML::Response.new do |r|
  # Should be your Twilio Number or a verified Caller ID
  r.Dial :callerId => caller_id do |d|
      d.Client <custom_client_name>
  end

or

response = Twilio::TwiML::Response.new do |r|
  # Should be your Twilio Number or a verified Caller ID
  r.Dial :callerId => caller_id do |d|
      d.Number <custom_client_number>
  end

Thank you guys!

jmolina
  • 259
  • 3
  • 12

2 Answers2

2

Twilio developer evangelist here.

This sounds like a pretty good use case for our TaskRouter API. TaskRouter allows you to place incoming calls into a queue which will use a workflow to assign those calls to agents when they are available.

This blog post shows how to build a priority based queueing system using TaskRouter, but if you just follow it up to the point before priorities arrive then you will have a queue in which agents are automatically assigned incoming calls.

Let me know if this helps at all.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • I think this is the best solution because I will have to implement multiple routers for different groups of agents, as well. I'm gonna take a look at it, and I will tell you how I'm doing. Thanks – jmolina Jul 10 '15 at 10:46
1

I see the scenario as this:

                         /- agent 1
client    -> pick random |- agent 2
(make call)              \- agent 3

For that I would:

  1. Track the agent availability independently from the Twilio. E.g. every time agent starts a call, you mark him as in call in your backend and when the call ends, you mark the agent available again.
  2. If voice endpoint is hit when client requests new call, you query the available agents and pick one in random. Then return necessary TwiML to dial that agent. You could also set up a Conference for more flexibility (e.g. switching agents during a call).
  3. When no agent is available, return TwiML with <say> verb letting the client know that no agents are available.
Madis Nõmme
  • 1,264
  • 2
  • 15
  • 25
  • This is the scenario, but when you say "return necessary TwiML to dia that agent". Do you mean the number of the available agent, or a client string? Because they should receive the call in the browser, not in the phone. – jmolina Jul 10 '15 at 10:44
  • In the *voice* endpoint you use `````` verb but with nested `````` for the *Twilio.Device* id that you generated the token for (i.e. ```capability.allow_client_incoming("agent_007")```. https://www.twilio.com/docs/api/twiml/client – Madis Nõmme Jul 10 '15 at 11:05