Get invited users from Twilio Channel

271 views Asked by At

I have a Twilio channel and I'm trying to get its invited users, but I'm not sure how to do this:

    let messagingClient = this.state.messagingClient;
    messagingClient.getUserChannelDescriptors().then(channels => {
        let channelsHash = {};
        channels.items.map(channelDescriptor => {
            var channel = channelDescriptor.getChannel().then((channel) => {
            channelsHash[channel.uniqueName] = channel;
            console.log(channel.getInvited()) // print invited users
            });
        });

What would I replace the channel.getInvited() by? It seems like Twilio channels do indeed have such a property, as there is an invited resource here: https://www.twilio.com/docs/api/chat/rest/invites#action-list

1

There are 1 answers

7
philnash On BEST ANSWER

Twilio developer evangelist here.

I'm afraid that right now the JavaScript SDK does not have a method to retrieve the invited users. In order to get this functionality right now, you will need to use the REST API.

Getting invited users from the SDK is on the backlog though, so keep an eye on the library releases.

Edit

Using the REST API to get the invited members:

from twilio.rest import Client

# Initialize the client
account = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
token = "your_auth_token"
client = Client(account, token)

# Retrieve the channel
channel = client.chat \
                .services("ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") \
                .channels("CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
invites = channel.invites.list()