Skip to main content
Pin messages so important information stays visible in a conversation.

Extension settings

1

Open your CometChat app

Login to CometChat and select your app.
2

Enable Pin Message

Go to Chat & Messaging —> Features, under Extentions and enable Pin Message.

How does it work?

Pin message extension provides you the ability to:
  • Pin messages: Keep important messages visible in a conversation.
  • Unpin messages: Remove pinned messages when they are no longer relevant.
  • Fetch pinned messages: Retrieve all pinned messages for a conversation.
Messages pinned in a conversation (be it one-on-one or group) are visible to the receiver(s) as well.

Choose Your Integration Method

Choose the integration method that best suits your needs:

UI Kit Builder

  • Enable it in both Dashboard and UI Kit Builder settings, then you can use the Pin Message extension in your custom chat experience.

Widget Builder

  • Enable it in both Dashboard and Widget Builder settings, then you can use the Pin Message extension in your custom chat widget.

UI Kits

  • Enable it in the Dashboard settings, then you can use the Pin Message extension in your custom chat experience built with our UI Kits.

SDK

  • Enable it in the Dashboard settings, then you can use the Pin Message extension in your custom chat experience built with our SDK.

Code

1. Pin a message

To pin a message, use the callExtension method provided by the SDK to make an HTTP POST request with the parameters as shown below. You need to pass the msgId that has to be pinned.
CometChat.callExtension('pin-message', 'POST', 'v1/pin', {
    "msgId": 280 // The ID of the message to be pinned. Here 280.
}).then(response => {
    // { success: true }
})
.catch(error => {
    // Error occurred
});

2. Unpin a message

To unpin a message, use the callExtension method provided by the SDK to make an HTTP DELETE request with the parameters as shown below. You need to pass the msgId, receiverType and the receiver (can be either UID or GUID based on receiverType).
CometChat.callExtension('pin-message', 'DELETE', 'v1/unpin', {
    "msgId": 111,
    "receiverType": "group",
    "receiver": "cometchat-guid-1"
}).then(response => {
    // { success: true }
})
.catch(error => {
    // Error occurred
});

3. Fetch pinned messages

To fetch the pinned messages for a conversation, use the callExtension method provided by the SDK to make an HTTP GET request with the query parameters as shown below. You need to pass the receiverType and the receiver (can be either UID or GUID based on receiverType).
const URL = `v1/fetch?receiverType=${RECEIVER_TYPE}&receiver=${RECEIVER}`;
CometChat.callExtension('pin-message', 'GET', URL, null).then(response => {
    // {pinnedMessages: []}
})
.catch(error => {
    // Error occured
});