chatMessageReceived

Emitted when a new chat message has been received.

You can use that event to play a chime sound on receiving a message or to display chat messages in a custom way in your integration. Note the local boolean flag in the message - it tells if this message was sent by the local user (yourself). For example if you are going to play a chime sound on receiving a message, then you would not want to do it when local flag is true.

Sample payload

{
    "type": "chatMessageReceived",
    "data": {
        "message": {
            "id": "ceb29418-3aa7-4354-9fe6-9875b9b260cf",
            "message": "How are you?",
            "date": "2024-06-11T08:23:16Z",
            //If it was sent by the local user (yourself)
            "local": true,
            "privateGroup": true/false,
            "user": {
               "name": "John Smith",
               "avatarColor": "#4ecdc4",
               "role": "moderator",
               "id": "862f90f8-5a66-4b24-befb-7343a9fd34aa"
            }
        }
        //Contains detailed information if chat panel is opened and which section
        "chatState": {
           "panelOpen": true,
           "activeTab": "public", //public or private
           "privateChatActiveView": {
              //"list" or "personal" depending on if private list is opened or a concrete personal private chat
              "name": "list",
              "data": {
                 //uuid of the user who you are having private chat with
                 "id": "..uuid...",
                 //If the opened chat is the group chat
                 "group": true/undefined
              }
           }
        }    
    }
}

Sample subscription code

sambaFrame.on('chatMessageReceived', (event) => {
  const data = event.data;
  console.log('New chat message is:', data.message);
});

Last updated