Skip to main content

ChatMessage

Represents a message in a chat.

Properties

id
stringrequired

The id of this message.

channel
stringrequired

The channel in which the message was sent.

content
anyrequired

The content of this message. This can be any JSON-serializable object or value.

publishedAt
Daterequired

The date and time at which this message was published.

member
ChatMemberrequired

The member which sent this message. See ChatMember.

meta
any

Any metadata associated to this message.

Example

Listening for messages and accessing ChatMessage properties:

import { SignalWire } from "@signalwire/realtime-api";

const client = await SignalWire({ project: "your-project-id", token: "your-api-token" });

await client.chat.listen({
channels: ["my-channel"],
onMessageReceived: (message) => {
console.log("Message ID:", message.id);
console.log("Channel:", message.channel);
console.log("Content:", message.content);
console.log("Published at:", message.publishedAt);
console.log("From member:", message.member.id);
console.log("Metadata:", message.meta);
}
});