Skip to main content

Chatting

Getting Started

In this section, we will show you how to manage your chats.

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

Chatting

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

PropertyTypeDescription
createFunctionThe function to create chat
updateFunctionThe function to update chat
listFunctionThe function to list chat
findFunctionThe function to find chat
deleteFunctionThe function to delete chat
addMemberFunctionThe function to add member
removeMemberFunctionThe function to remove member
leaveFunctionThe function to leave chat

Creating Chat

To create your chat, you can use the create function. The function itself take the following properties:

PropertyTypeDescription
versionnumberThe version of the chat
namestringThe name of the chat
avatarstring (optional)The avatar of the chat
descriptionstring (optional)The description of the chat
metadataobject (optional)The metadata of the chat
typeprivate | groupThe type of the chat
membersarrayThe members of the chat

Updating Chat

To update your chat, you can use the update function. The function itself take the following properties:

PropertyTypeDescription
versionnumberThe version of the chat
chatIdstringThe chat id you want to update
namestringThe name of the chat
avatarstring (optional)The avatar of the chat
descriptionstring (optional)The description of the chat
metadataobject (optional)The metadata of the chat

Listing Chats

To list your chat, you can use the list function. The function itself take the following properties:

PropertyTypeDescription
versionnumberThe version of the chat to retrieve
namestring (optional)The name of the chat to retrieve
typeprivate | groupThe type of the chat to retrieve
limitnumber (optional)Total number of chats to retrieve, (default: 10)
pagenumber (optional)The page number of chats to retrieve, (default: 1)

Finding Chat

To find your chat, you can use the find function. The function itself take the following properties:

PropertyTypeDescription
versionnumberThe version of the chat
chatIdstringThe chat id you want to find

Deleting Chat

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

PropertyTypeDescription
versionnumberThe version of the chat
chatIdstringThe chat id you want to delete

Adding Member

To add member to your chat, you can use the addMember function. The function itself take the following properties:

PropertyTypeDescription
versionnumberThe version of the chat
chatIdstringThe chat id you want to add member
membersarrayThe members you want to add

Removing Member

To remove member from your chat, you can use the removeMember function. The function itself take the following properties:

PropertyTypeDescription
versionnumberThe version of the chat
chatIdstringThe chat id you want to remove member
userIdsarrayThe members you want to remove

Leaving Chat

To leave your chat, you can use the leave function. The function itself take the following properties:

PropertyTypeDescription
versionnumberThe version of the chat
chatIdstringThe chat id you want to leave

Quick Example

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

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

// ...rest of your code
}