Mention in Messages

The mention feature in chat can be used to call attention to specific members. By @mentioning their names, this will promptly notify them so you can get a faster response to your message.

Mention is only supported in TEXT message type. As for channels, mention is supported in these channel types:

  • Community

  • Live

Mention is not supported in the Conversation channel type.

Amity.Message contains new properties related to mention feature:

  • metadata - a dictionary which can contain any information about the current message. Our default structure to represent mentions is inside the metadata property. Customers can use any structure to represent mentions.

  • mentionees - an array of Amity.Mentionees objects. Amity.Mentionees model represents the following information about mentions in the message:

    • type - the type of the current mention. This can either be user or channel.

    • users - nullable array of Amity.User. This is the list of users who are mentioned in the current message.

The mentionees array can contain a maximum of two objects because mention type can only be either channel or user. Each object in the array represents information about a specific type of mention.

How mention works

You can define your own structure to represent mentions. To do this, you can use the metadata property of Amity.Message and store mentions in the metadata property.

Create a message with mentions

There are 2 types of mentions:

USER - When using mention of this type, a specific member being mentioned will receive a push notification. Up to 30 channel members can be mentioned per message:

CHANNEL - When using mention of this type, all channel members will receive push notification:

Mentioning banned users

Banned users cannot be mentioned. However, admins can still find the banned users' names in the suggestion list during search when composing the message. But once the message is sent, the banned users’ information will not be included in the message payload anymore. Banned users will not be notified nor receive any push notification.

Update mentions in a message

To update the mentioned users in a message:

Unread mention count

When a user is mentioned(mention type could be channel as well) in a text message and the message is not read, then hasMention property is true in Amity.Channel class. Everytime the hasMention property is true, this means that the user has an unread message with mention(message could be created or updated as well).

Viewing mentions

SDK only sends push notifications according to mention input during message creation. The system doesn't handle any data related to UI rendering. However, Amity.Message has a property called metadata which can hold an object and will not be tampered by the system. So, it can be utilized as a storage for UI-related data.

Mention notifications

When users are being mentioned, they will receive push notifications. You can customize the push notification content such as the title and the body using the notification setting API.

Provide the notification title and body in the titleTemplate and bodyTemplate parameters respectively. Here is a sample model:

{
  "level": "network",
  "isPushNotifiable": true,
  "notifiableEvents": [
   {
      "name": "text-mention-message.created",
      "isPushNotifiable": true,
      "titleTemplate": "{{UserDisplayName}} mentioned you in {{ChannelName}}",
      "bodyTemplate": "{{Message}}"
    }
  ]
}
NameData TypeDescription

name

String

Event name

isPushNotifiable

Boolean

If set to true,push notification will be received for all text messages. If set to false, only messages with mention will have push notifications.

titleTemplate

String

Notification title

bodyTemplate

String

Notification body

Last updated