Conferences and Participants

For more information, see the Conference REST Resource and Participant REST Resource documentation.

Listing Conferences

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
@conferences = @client.conferences.list()

@conferences.each do |conference|
  puts conference.sid
end

Filtering Conferences

The Twilio::REST::Conferences.list() method supports filtering on status, date_updated, date_created and friendly_name. The following code will return a list of all in-progress conferences and print their friendly name.

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
@conferences = @client.conferences.list(status: "in-progress")

@conference.each do |conference|
  puts conference.friendly_name
end

Listing Participants

Each Conference has a participants instance which represents all current users in the conference

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
@conference = @client.conferences.get("CF123")

@conference.participants.list.each.do |paricipant|
  puts participant.sid
end

Conferences and Participants are subclasses of ListResource. Therefore, their instances have the inherited methods such as count().

Managing Participants

Each Conference has a participants function that returns a Participants instance. This behavior differs from other list resources because Participants needs a participant sid AND a conference sid to access the participants resource.

Participants can be either muted or kicked out of the conference. The following code kicks out the first participant and mutes the rest.

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
@participants = @client.conferences.get("CF123").participants.list()

return if @participants.empty?

# Kick the first person out
@participants.pop().kick()

# And mute the rest
@participants.each do |participant|
  participant.mute()
end