Reputation: 4264
The Twilio documentation page mentions using Roles to change the name of a channel (https://www.twilio.com/docs/api/chat/rest/roles), but does not provide any example code. How would I do this in the below example:
var channel = this.state.channel;
var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var authToken = 'your_auth_token';
var Twilio = require('twilio').Twilio;
var client = new Twilio(accountSid, authToken);
var service = client.chat.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
service.roles.list().then(function(response) {
// what do I insert here to change the name of the channel variable
});
Upvotes: 0
Views: 546
Reputation: 73027
Twilio developer evangelist here.
In Twilio Programmable Chat each user gets a default role when they are created. There is also a default channel role that is assigned to each member that joins a channel. The roles say what permissions each user/member has. There is a guide on roles and permissions available in the Chat documentation which I recommend you take a read through.
The default user role has these permissions:
And the default channel member role has these permissions:
You can update these roles or create new roles using the REST API. If you want users to be able to update the channel name you need to give them the editChannelName
permission. You can either do this on the user level or the channel level. Once you have granted this permission to the role, or created a new role with this permission and assigned it to the user, the user will be able to call channel.updateFriendlyName
from the SDK.
Alternatively, you can use the Channels resource in the REST API to change the friendly name of the channel too.
channel.update({
friendlyName: 'channel_name',
})
.then(response => {
console.log(response);
});
Upvotes: 1