I am trying to send media messages in programmable chat on Twilio. But as per the docs, only Channel admin and Channel user roles can send media messages. When I create my chatClient, it automatically assigns them with Service admin and Service User role. How can I join the channel as a channel admin or channel user so that i can send media messages.
Below is the code I am using for creating chat client and joining the channel:
initChat = () => {
this.chatClient = new Chat(this.state.token);
this.chatClient.initialize().then(this.clientInitiated.bind(this));
};
clientInitiated = () => {
this.setState({ chatReady: true }, () => {
this.chatClient
.getChannelByUniqueName(this.channelName)
.then(channel => {
if (channel) {
return (this.channel = channel);
}
})
.catch(err => {
if (err.body.code === 50300) {
return this.chatClient.createChannel({
uniqueName: this.channelName
});
}
})
.then(channel => {
this.channel = channel;
window.channel = channel;
if (channel.state.status !== "joined") {
console.log("New member joining in");
return this.channel.join();
} else {
console.log("already joined the channel earlier");
return this.channel;
}
})
.then(() => {
console.log("Channel: ", this.channel);
this.channel.getMessages().then(this.messagesLoaded);
this.channel.on("messageAdded", this.messageAdded);
});
});
};