Mentioning users via the REST API

Last updated: 2022-04-25Contributors
Edit this page

A key need in a team messaging environment is capturing the attention of a person or group within it. When a person is mentioned in a conversation for example, their unread messages in that conversation is highlighted to indicate that a specific message was directed at them. For example:

When a bot needs to mention a user, they use a special markdown syntax to do so:

![:Person](<INSERT PERSON ID>)

A bot can also mention an entire team using this markdown syntax:

![:Team](<INSERT TEAM ID>)

Within the context of sending a message in Javascript, it might look like this:

require('dotenv').config();
var RingCentral = require('@ringcentral/sdk').SDK;
var rcsdk = new RingCentral({
  server:       RINGCENTRAL_SERVER_URL,
  clientId:     RINGCENTRAL_CLIENT_ID,
  clientSecret: RINGCENTRAL_CLIENT_SECRET
});
var platform = rcsdk.platform();
platform.login({
    'username':  process.env.RC_USERNAME,
    'password':  process.env.RC_PASSWORD,
    'extension': process.env.RC_EXTENSION
})

platform.on(platform.events.loginSuccess, () => {
    try {
        var personId = "1234";
        var groupId = "5678";
        await platform.post(`/restapi/v1.0/glip/chats/${groupId}/posts`, {
            "text": `Here is a mention: ![:Person](${personId})`
        })
    } catch(e) {
        console.log(e)
    }
})

Rate this page: