Chat Overview

The Chat API allows users to communicate through chat embedded directly within the application. The main entry point to the Chat API is the ChatService. The ChatService can be obtained from the domain using the chat() method.

const chatService =;

Chat Rooms

Chat rooms provide a group messaging capability. Chat rooms are identified by a unique id. Users may join and leave the chat room. While a user is joined to a chat room, they will receive messages sent within the room. Once they leave the room, they will no longer receive messages. A user must be joined to the room to send a message in it. Joining happens asynchronously via a Promise -- on a successful join, the promise will resolve with the joined ChatRoom. From there, clients can send and receive messages.

Examples are shown below:

// Join the room
chatService.join('my room').then(room => {

  // Listen for incoming messages
  room.on("message", (evt) => {
    console.log(evt.message); // "Did you finish the dev guide yet?"

  // Send a message
  room.send("OMG no. So much text. I'm dreaming in Markdown");

  // Leave the room.
}).catch(e => {

Room Info

Users may wish to obtain information about the chat room, such as the current members or the number of messages sent. This information can be obtained from the room via several methods.

chatService.join('my room').then(room => {
  console.log(room.members()); // ChatMember[]
  console.log(room.members[0].username()); // jimbob

  console.log(room.messageCount()); // 31

  console.log(room.lastMessageTime()); // timestamp

results matching ""

    No results matching ""