Skip to main content

Other chat functions

The object exposes certain other methods for convenience when working with chat.

Get messages by a user

You can get messages by a particular user by passing the user's ID to the method.

// Find the userId of the user with name "Freddie".
const { userId } = meeting.participants.joined
.find((p) => === 'Freddie');

const messages =;

Get messages of a particular type

You can also get messages of a particular type using the method. For example, you can get all image messages present in the chat using the following snippet.

const imageMessages ='image');

Pinning a chat message

You can pin a number of messages to the chat. When you pin a message, the message object will have the attribute pinned: true, using which you can identify if a message is pinned.

To pin a message, run the following snippet.

// Let's say we want to pin the first message in the chat (could be a text, image, or file).
const { id } =[0];


Once you pin a message, it will be added to

const { id } =[0];


console.log( > 0); // Should be true

You can also unpin a pinned message, by using the method.

// Unpin the first pinned message.

const { id } =[0];

You can listen for events to know when a message is pinned or unpinned.'pinMessage', ({ message }) => {
console.log('A message was pinned', JSON.stringify(message));
});'unpinMessage', ({ message }) => {
console.log('A message was unpinned', JSON.stringify(message));

Deleting a chat message

The namespace exposes a method called deleteMessage(). It takes a parameter meesageId of type string.

const messageId = '...';