Conferences and Participants

The Conference resource manages all interaction with Twilio conferences, such as listing and managing participants. For more information, see the Conference REST Resource and Participant REST Resource documentation.

Listing Conferences

from twilio.rest import TwilioRestClient

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

client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
conferences = client.conferences.list()

for conference in conferences:
    print conference.sid

Filtering Conferences

The 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.

from twilio.rest import TwilioRestClient

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

client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
conferences = client.conferences.list(status="in-progress")

for conference in conferences:
    print conference.friendly_name

Listing Participants

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

from twilio.rest import TwilioRestClient

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

client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
conference = client.conferences.get("CF123")

for participant in conference.participants.list():
    print participant.sid

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.

from twilio.rest import TwilioRestClient

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

client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
participants = client.participants("CF123").list()

if len(participants) == 0:
    return

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

# And mute the rest
for participant in participants:
    participant.mute()