Mentions

Learn how to use mentions in your chat.

Mentions are a great way to get someone's attention in a conversation or a chat. Mentions start with the @ symbol followed by a name.

Settings

  1. Login to the CometChat Dashboard.
  2. Select one of your apps.
  3. On the Extensions page, enable Mentions.

How does it work?

Sending messages with mentions

At CometChat, we have decided upon the following format for a mention: @{NAME|UID}.

Whenever the @ symbol is typed in the message composer of a group, you can show a list of users in that group. On clicking of a particular user's name in that list, a text with the user's name and uid gets inserted in the composer. Refer to our Retrieve Group Members documentation for more details.

For example, if you want to mention Spiderman with uid superhero3, then the text message should be formatted as "Hello @{Spiderman|superhero3}".

📘

The extension by itself does not handle the UI part of things of displaying the mention in composer. You have to use appropriate libraries to handle View accordingly.

Listing messages with mentions

To get all the messages with mentions for a user, make use of the callExtension method provided by CometChat SDK as shown below:

const URL = "v1/fetch";
CometChat.callExtension('mentions', 'GET', URL, null).then(response => {
    // {messages: []}
})
.catch(error => {
    // Error occured
});
String URL = "/v1/fetch";

CometChat.callExtension("mentions", "GET", URL, null,
new CometChat.CallbackListener < JSONObject > () {
    @Override
    public void onSuccess(JSONObject jsonObject) {
        // {messages: []}
    }
    @Override
    public void onError(CometChatException e) {
        // Some error occured
    }
});
CometChat.callExtension(slug: "mentions", type: .get, endPoint: "/v1/fetch", body: nil, onSuccess: { (response) in
        // { messages: [] }
      }) { (error) in
        // Some error occured
      }
    }

Did this page help you?