Admin panel

Message Count API

This function is created for showing how many messages are in the room by providing the roomId.

REST API

⚠️

Regional endpoints: Replace chatbackend.watchers.io with the endpoint matching your project region. See Supported Regions for details.

Region Endpoint
Europe (default) chatbackend.watchers.io
North America chatbackend.us.watchers.io
South America chatbackend.sa.watchers.io
Asia chatbackend.hk.watchers.io
Africa chatbackend.za.watchers.io

URLs https://chatbackend.watchers.io/message/external/count

Parameters:

Name type Description
roomiIds string(Array) roomID used in the chat initialisation in your App
apiKey string API Key

Response Example:

JSON
[{"count":2,"roomId":"1234"},{"count":0,"roomId":"123"}]

usage Example:

Shell
curl --location --request POST 'https://chatbackend.watchers.io/message/external/count' --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'roomIds[]={ROOM ID}' --data-urlencode 'roomIds[]={ROOM ID}' --data-urlencode 'apiKey={API KEY}'

WS Version

You can connect by WebSockets to URLs below and emit event “listenMessageCount” with parameters

Name Type Description
roomIds string(Array) room id of room which you want to get a last message (Limit 50 rooms)
apiKey string your puclic API key

And you will receive the events for each room with name “messageCount” every 30 seconds

Urls https://chatbackend.watchers.io

Response (WS payload what you will receive)

Our server will send different events for each room every 30 seconds(If you provide 50 room ids you will receive 50 events)

JSON
//Event 1

{
    "roomId": "123",
    "count": 2982
}

//Event 2

{
    "roomId": "456",
    "count": 441
}

Usage example

JavaScript
const socket3 = io("https://chatbackend.watchers.io", {
  transports: ["websocket"],
  upgrade: false,
});

socket3.on("messageCount", (payload) => {
  console.log(payload);
});

socket3.on("connect", () => {
  socket3.emit("listenMessageCount", {
    roomIds: "<ROOM ID>",
    apiKey: "<API KEY>",
  });
});
Updated 3 days ago