Listening to Chat Messages
Getting Started
In this section, we will show you how to listening to all last chat messages.
Prerequisites
- Busy Hour Account (Sign Up if you don't have one yet)
- Create a Busy Hour Project from the Dashboard/Projects
- Create a Busy Hour App from from the Dashboard/Apps
- Download Busy Hour App config file from from the Dashboard/Apps
Listen to Chat Messages
To start listening to chat messages, you can use the listenToMessages
functions from @busy-hour/web
package. The function itself take the following properties:
Property | Type | Description |
---|---|---|
chatId | string | The chat id that you want to listen to |
version | number | The version of the last message to listen to |
Quick Example
src/main.tsx
import { listenToMessages } from '@busy-hour/web';
let lastMessages = [];
// Listen to last messages
const unsubscribe = listenToMessages({
version: 1,
onMessages(messages) {
lastMessages = messages;
},
});
// Remove the subscription
unsubscribe();