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:

const RC = require('@ringcentral/sdk').SDK
require('dotenv').config();

var rcsdk = new RC({
    'server':       process.env.RC_SERVER_URL,
    'clientId':     process.env.RC_APP_CLIENT_ID,
    'clientSecret': process.env.RC_APP_CLIENT_SECRET
});
var platform = rcsdk.platform();
platform.login({ 'jwt':  process.env.RC_USER_JWT })

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: