Skip to main content
Mentions in messages enable users to refer to specific individuals within a conversation. This is done by using the <@uid:UID> format, where UID represents the user’s unique identification. Mentions are a powerful tool for enhancing communication in messaging platforms. They streamline interaction by allowing users to easily engage and collaborate with particular individuals, especially in group conversations.
Available via: SDK | REST API | UI Kits

Send Mentioned Messages

Every User object has a String unique identifier associated with them which can be found in a property called uid. To mention a user in a message, the message text should contain the uid in following format: <@uid:UID_OF_THE_USER>. For example, to mention the user with UID cometchat-uid-1 in a text message, your text should be “<@uid:cometchat-uid-1>
On Success — A TextMessage object containing all details of the sent message with mentions:TextMessage Object:
sender Object:
receiver Object:
mentionedUsers Array (per item):
You can mention user in text message and media messages captions

Mentioned Messages

By default, the SDK will fetch all the messages irrespective of the fact that the logged-in user is mentioned or not in the message. The SDK has other optional filters such as tag info and blocked info.

Mentions With Tag Info

To get a list of messages in a conversation where users are mentioned along with the tags of the mentioned users. Relevant fields to access on returned messages and their mentioned users:
On Success — A List<BaseMessage> containing messages with mentioned users and their tag info (each item is a BaseMessage object):BaseMessage Object:
sender Object:
receiver Object:

Mentions With Blocked Info

To get a list of messages in a conversation where users are mentioned along with the blocked relationship of the mentioned users with the logged-in user. Relevant fields to access on returned messages and their mentioned users:
On Success — A List<BaseMessage> containing messages with mentioned users and their blocked relationship info (each item is a BaseMessage object):BaseMessage Object:
sender Object:
receiver Object:

Get Users Mentioned In a Particular Message

To retrieve the list of users mentioned in the particular message, you can use the mentionedUsers property on any BaseMessage. This property will return an array containing User objects of the mentioned users, or an empty array if no users were mentioned in the message.
The mentionedUsers property returns a List<User> objects.

Check if Logged-in user has been mentioned

To check if the logged-in user has been mentioned in a particular message we can use the hasMentionedMe property on any BaseMessage. This property will return a boolean value, true if the logged-in user has been mentioned, otherwise false.

Next Steps

Send Messages

Send text, media, and custom messages

Receive Messages

Listen for incoming messages in real time

Reactions

Add emoji reactions to messages

Threaded Messages

Organize conversations with message threads