Skip to main content

Listening to Last Message

Getting Started

In this section, we will show you how to listening to all last chat messages.

Prerequisites

  1. Busy Hour Account (Sign Up if you don't have one yet)
  2. Create a Busy Hour Project from the Dashboard/Projects
  3. Create a Busy Hour App from from the Dashboard/Apps
  4. Download Busy Hour App config file from from the Dashboard/Apps

Listen to Last Message

To start listening to last chat messages, you can use the listenToLastMessages functions from @busy-hour/web package. The function itself take the following properties:

PropertyTypeDescription
versionnumberThe version of the last message to listen to
typeprivate | group (optional)The type of the last message to listen to

Quick Example

src/main.tsx
import { listenToLastMessages } from '@busy-hour/web';

let lastChatMessagess = [];

// Listen to last messages
const unsubscribe = listenToLastMessages({
version: 1,
onLastMessages(chats) {
lastChatMessagess = chats;
},
});

// Remove the subscription
unsubscribe();