Skip to main content

Messages

Messages are the core building blocks of ChatKitty applications. Users send messages using the client SDK, while bots and system administrators can send messages using the Platform REST API. Text messages have a Unicode text body, while file messages have a file attached to them. User messages are messages sent by end-users of your application through the client SDK. System messages are messages sent via the Platform REST API on behalf of the application.

Properties

NameTypeDescriptionRequired
idnumber64-bit integer identifier associated with this message
typestringThe type of this message. TEXT, or FILE
bodystringThe text body of this message. Present if this is a text message-
fileChatKittyFileThe file attached to this message. Present if this is a file message-
linksMessageLink[]Message links found in this message. Present if this is a text message-
mentionsMention[]Mentions of channels and users in this message. Present if this is a text message-
userUserThe user who sent this message. Absent if this is a system message-
createdTimedatetimeISO 8601 date-time when this message was created
propertiesobjectCustom data associated with this message

Message types

There are four types of messages:

User Text Message

Users can send text messages containing a Unicode text body. These messages can contain emojis and other Unicode characters.

User File Message

Users can send files messages with a file attachment.

System Text Message

You can send text messages containing a Unicode text body on behalf of your application.

System File Message

You can send file messages with a file attachment on behalf of your application.

Sending/replying to a message

You can send messages in a channel, a channel thread, as a reply to another message.

Sending a user text message

Using a client SDK as a channel member, send a user text message.

Parameters

Channel message parameters
NameTypeDescriptionRequired
channelChannelChannel this message belongs to
bodystringThe Unicode text body of this message
propertiesobjectCustom data associated with this message-
const result = await kitty.sendMessage({
channel: channel,
body: 'Hello, world!'
});

if (result.succeeded) {
const message = result.message; // Handle message
}

if (result.failed) {
const error = result.error; // Handle error
}
Message reply parameters
NameTypeDescriptionRequired
messageMessageparent message being replied to
bodystringThe Unicode text body of this message
propertiesobjectCustom data associated with this message-
const result = await kitty.sendMessage({
message: message,
body: 'This is a reply!'
});

if (result.succeeded) {
const message = result.message; // Handle message
}

if (result.failed) {
const error = result.error; // Handle error
}

Sending a user file message

Using a client SDK, send a user file message.

Parameters

Channel message parameters
NameTypeDescriptionRequired
channelChannelChannel this message belongs to
fileFileFile to upload as an attachment or ChatKitty external file properties
propertiesobjectCustom data associated with this message-
progressListenerUploadProgressListenerListener to be notified as the file upload progresses.-
const result = await kitty.sendMessage({
channel: channel,
file: file,
progressListener: {
onStarted: () => {
// Handle file upload started
},

onProgress: (progress) => {
// Handle file upload process
},

onCompleted: (result) => {
// Handle file upload completed
}
}
});

if (result.succeeded) {
const message = result.message; // Handle message
}

if (result.failed) {
const error = result.error; // Handle error
}
Message reply parameters
NameTypeDescriptionRequired
messageMessageparent message being replied to
fileFileFile to upload as an attachment or ChatKitty external file properties
propertiesobjectCustom data associated with this message-
progressListenerUploadProgressListenerListener to be notified as the file upload progresses.-
const result = await kitty.sendMessage({
message: message,
file: file,
progressListener: {
onStarted: () => {
// Handle file upload started
},

onProgress: (progress) => {
// Handle file upload process
},

onCompleted: (result) => {
// Handle file upload completed
}
}
});

if (result.succeeded) {
const message = result.message; // Handle message
}

if (result.failed) {
const error = result.error; // Handle error
}

Getting messages

You can retrieve previous messages and observe new messages.

Retrieving channel messages

A user can retrieve previous messages in a channel he or she is a member.

const result = await kitty.getMessages({
channel: channel
});

if (result.succeeded) {
const messages = result.paginator.items; // Handle messages
}

if (result.failed) {
const error = result.error; // Handle error
}

Retrieving message replies

Retrieve replies to a message.

const result = await kitty.getMessages({
message: message
});

if (result.succeeded) {
const messages = result.paginator.items; // Handle messages
}

if (result.failed) {
const error = result.error; // Handle error
}

Observing channel messages

A user can observe new messages in a channel he or she is a member of.

kitty.startChatSession({
channel: channel,
onReceivedMessage: (message) => {
// Handle received message
}
});