---
title: Last Message Widget API
updatedAt: 2026-09-06T11:12:34.150Z
---

Fetch the complete documentation index at: https://docs.watchers.io/llms.txt

# Last Message Widget API

An opportunity to see what's going on a chat before entering.

## Overview

> ⚠️ **Regional endpoints:** Replace `chatbackend.watchers.io` with the endpoint matching your project region. See [Supported Regions](https://docs.watchers.io/docs/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` |

Last Message is an advanced chat utility designed to increase user conversion to chat participants. It displays the last text message from any room in your product interface, and users can access the chat by clicking on it. The widget ensures users stay in touch with chat updates and return there, never missing important parts of the conversation.

<img src="https://docs-assets.watchers.io/docs/readme/d4447664e6eed3a77a02935579812008c58cf371890a73465cfdb988d95e0188-Untitled-9.png" alt="" width="600" class="img-center">

<img src="https://docs-assets.watchers.io/docs/readme/d399f833c88b48b2c8bca11d67018921dee7ecf70dface10164f6b269b2a0be2-Untitled-13.png" alt="" width="600" class="img-center">

<img src="https://docs-assets.watchers.io/docs/readme/5995081406a1bcd4467aad6aa595816a781a236ce538153bcac48f7809009615-Untitled-14.png" alt="" width="286" class="img-center">

Key Features:

* Easy integration with the application or website
* Real-time updates with WebSocket technology
* Efficient and reliable performance

## Architecture

![](https://docs-assets.watchers.io/docs/readme/946a7b751545466ef3c95f6f8b1f354b1f2ee00be0815ed5c4dd3f561beef044-image.png)

## REST API

### **Urls**

**[https://chatbackend.watchers.io/room/last-message/load](https://chatbackend.watchers.io/room/last-message/load)**

**Parameters:**

| Name     | type          | Description                                                        |
| -------- | ------------- | ------------------------------------------------------------------ |
| roomiIds | string(Array) | roomId used in chat initialisation in your App (50 room ids limit) |
| apiKey   | string        | API key                                                            |

**Response Example:**

```json
[
    {
        "externalRoomId": "123",
        "id": 94,
        "newMessage": "Hello!",
        "postingTime": "2025-04-17T12:45:06.575Z",
        "author": "user3d486ft",
        "avatar": "https://watchers.io/_next/static/media/solutions.png"
    },
    {
        "externalRoomId": "321",
        "id": 99,
        "newMessage": "123",
        "postingTime": "2025-04-17T12:45:57.381Z",
        "author": "user3d486ft",
        "avatar": "https://watchers.io/_next/static/media/solutions.png"
    }
]
```

**Production stand usage Example:**

```bash Bash
curl --location --request POST '[https://chatbackend.watchers.io/room/last-message/load](https://chatbackend.watchers.io/room/last-message/load)' --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 “**listenLastMessage**” with parameters

| **roomId** | room id of room which you want to get a last message |
| ---------- | ---------------------------------------------------- |
| **apiKey** | your puclic API key                                  |

And you will recieve the event with name “**lastMessage**” every 30 seconds

### **Urls** [https://chatbackend.watchers.io](https://chatbackend.watchers.io/)

### Response (WS payload what you will recive)

```json
{
    "id": 10394, //Message id
    "newMessage": "XZY", // Message text
    "postingTime": "2023-12-19T17:15:06.247Z", // date sent
    "author": "Test User", //nickname
    "avatar": "https://watchers.io/watchers/4a7830fa-db2e-4e76-a1d0-bafef0d530b5.png"
}
```

### JavaScript example

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

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

socket3.on("connect", () => {
  socket3.emit("listenLastMessage", {
    roomId: "<ROOM ID>",
    apiKey: "<API KEY>",
  });
});
```
