Add admin privileges to your chat app
Click below to play with Ably's chat admin privileges implementation and to browse through the code that powers it. You can test the demo in realtime, on multiple browser windows/devices, or with a friend.
Chat admin privileges
This is an easy way to give your app users different roles and capabilities. This can be a useful functionality when you’re managing live experiences with multiple participants. For example, in a chat room where one user needs admin or moderator privileges to delete spam or inappropriate content.
Switch between roles
You have the ability to give users different roles in different parts of your application, and you can switch those roles at any time. In the chat example, you would give one user admin role in a specific chat room, while they stay a simple participant in all other chat rooms. The user can only delete other user’s comments in the room where he has admin privileges.
Where can I use this functionality?
Other Possible Features?
Ably gives you the flexibility to create a wide range of app features using the same basic building blocks. For example, beyond the message deletion use case we showed above, you could use the same logic for:
Customizing which users have access to different message interaction types, such as who can reply to a post
Including trusted information about the identity of a user in messages they send
Building chat admin privileges into your app
Ably has simple yet powerful APIs to help you effortlessly build and implement admin privileges in your realtime application.
Ably Channels
Channel is the unit of distribution of messages. Messages can be anything and a channel can represent a chat room, direct messaging, a virtual event etc. Users or their devices can connect to a specific channel. The Avatar Stack is not related to messages in a channel, but the digital place where an Avatar Stack can be used is the channel itself.
channels.get - to get an existing channel or create a new channel
channel.presence - to get the presence object
Ably JWT user claims
Ably’s support for JWTs allows a token-based authentication scheme that defines channel capabilities, as well as ‘admin privileges’ — or any other trusted information about a client that can be used to describe a user’s roles. Clients receive information about other clients on each message.
Token authentication - to create JWTs for use with Ably channels
Read our changelog on implementing JWT user claims
Getting started: Chat Admin Privileges
You'll need to do the following to get started.
Implement chat functionality using Ably message interactions and JWTs
Include custom user claims in your JWTs to represent the roles your application needs
Add logic into the user interface to process message interactions according to role information
What's next?
Recommended Articles
Activity Feeds: Explanation, benefits and how to get started
Discover what activity feeds and streams are, their use cases and benefits, and how to use Ably APIs and SDKs to set up an activity feed.
Allow users to lock specific parts of your app for editing
Component locking is a great collaborative feature that let members of a virtual space lock specific parts of your app to edit without blocking overall collaboration.
Add live cursors for collaborative multiplayer experiences
It’s easy to add live cursors with Ably. Using our Spaces SDK you can build live cursors and other realtime collaboration features to enhance your product.