Messaging
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
Messaging
To start sending your message, updating your message, and deleting your message, you can use the core.messaging instance instance from useServiceStore. The instance itself will return the following objects:
| Property | Type | Description |
|---|---|---|
| send | Function | The function to send message |
| update | Function | The function to update message |
| delete | Function | The function to delete message |
Sending Message
To send your message, you can use the send function. The function itself take the following properties:
| Property | Type | Description |
|---|---|---|
| version | number | The version of the chat |
| chatId | string | The chat id where the message belongs to |
| message | string (optional) | The message to send |
| metadata | object (optional) | The metadata to send |
| attachments | array (optional) | The attachments to send |
| type | string | The type of the message, useful for sending different types of message |
Updating Message
To update your message, you can use the update function. The function itself take the following properties:
| Property | Type | Description |
|---|---|---|
| version | number | The version of the chat |
| messageId | string | The message id you want to update |
| message | string (optional) | The message to send |
| metadata | object (optional) | The metadata to send |
| attachments | array (optional) | The attachments to send |
Deleting Message
To delete your message, you can use the delete function. The function itself take the following properties:
| Property | Type | Description |
|---|---|---|
| version | number | The version of the chat |
| messageId | string | The message id you want to delete |
Quick Example
src/main.tsx
import { useServiceStore } from '@busy-hour/web';
const manager = useServiceStore.getState().core.messaging;