Skip to main content

Messaging

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

Messaging

To start sending your message, updating your message, and deleting your message, you can use the useMessaging hooks from @busy-hour/react package. The hook itself will return the following objects:

PropertyTypeDescription
sendFunctionThe function to send message
updateFunctionThe function to update message
deleteFunctionThe function to delete message

Sending Message

To send your message, you can use the send function. The function itself take the following properties:

PropertyTypeDescription
versionnumberThe version of the chat
chatIdstringThe chat id where the message belongs to
messagestring (optional)The message to send
metadataobject (optional)The metadata to send
attachmentsarray (optional)The attachments to send
typestringThe 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:

PropertyTypeDescription
versionnumberThe version of the chat
messageIdstringThe message id you want to update
messagestring (optional)The message to send
metadataobject (optional)The metadata to send
attachmentsarray (optional)The attachments to send

Deleting Message

To delete your message, you can use the delete function. The function itself take the following properties:

PropertyTypeDescription
versionnumberThe version of the chat
messageIdstringThe message id you want to delete

Quick Example

src/main.tsx
import React from 'react';
import { useMessaging } from '@busy-hour/react';

export default function Main() {
const manager = useMessaging();

// ...rest of your code
}