Skip to main content

sendMessage

codebolt.chat.sendMessage(message: string, payload: any): void
Sends a message through the WebSocket connection.

Parameters

NameTypeDescription
messagestringThe message to be sent.
payloadanyAdditional data to send along with the message.

Example

// Send a simple message through the WebSocket connection
codebolt.chat.sendMessage("Hi!", null);

// Send a message with additional payload data
codebolt.chat.sendMessage("Process complete", {
status: "success",
items: 5
});

sendMessage

Explanation

The codebolt.chat.sendMessage function sends a message through the WebSocket connection, optionally with additional payload data. This function enables real-time communication by allowing the script to send text messages and structured data to the Codebolt chat.