Queues and Members

For more information, see the Queue REST Resource and Member REST Resource documentation.

Listing Queues

require 'twilio-ruby'

# To find these visit https://www.twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXX"
auth_token = "YYYYYYYYYYYYYYYYYY"

@client = Twilio::REST::Client.new account_sid, auth_token
@queues = @client.queues.list

@queues.each do |queue|
  puts queue.sid
end

Listing Queue Members

Each Queue has a members instance which represents all current calls in the queue.

require 'twilio-ruby'

# To find these visit https://www.twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXX"
auth_token = "YYYYYYYYYYYYYYYYYY"

@client = Twilio::REST::Client.new account_sid, auth_token
@queue = @client.queues.get("QU123")

@queue.members.list().each do |member|
  puts member.call_sid
end

Getting a specific Queue Member

To retrieve information about a specific member in the queue, each Members has a get method. get accepts one argument. The argument can either be a call_sid thats in the queue, in which case get will return a Member instance representing that call, or the argument can be ‘Front’, in which case Get will return a Member instance representing the first call in the queue.

require 'twilio-ruby'

# To find these visit https://www.twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXX"
auth_token = "YYYYYYYYYYYYYYYYYY"

@client = Twilio::REST::Client.new account_sid, auth_token

queue_sid = "QUAAAAAAAAAAAAA"
call_sid = "CAXXXXXXXXXXXXXX"

@members = @client.queues.get(queue_sid).members

# Get the first call in the queue
puts members.front.date_enqueued

# Get the call with the given call sid in the queue
puts members.get(call_sid).current_position

Dequeueing Queue Members

To dequeue a specific member from the queue, each Members has a dequeue method. dequeue accepts an argument and two optional keyword arguments. The first argument is the url of the twiml document to be executed when the member is dequeued. The other two are call_sid and method, their default values are ‘Front’ and ‘GET’

require 'twilio-ruby'

# To find these visit https://www.twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXX"
auth_token = "YYYYYYYYYYYYYYYYYY"

@client = Twilio::REST::Client.new account_sid, auth_token

queue_sid = "QUAAAAAAAAAAAAA"

@members = @client.queues.get(queue_sid).members

# Dequeue the first call in the queue
puts @members.dequeue('http://www.twilio.com/welcome/call')