ChatKitty
Search…
Messages
Users, bots, and system administrators can send 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 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 API on behalf of the application.

Properties

Name
Type
Description
Required
id
number
64-bit integer identifier associated with this message
type
string
The type of this message. TEXT, or FILE
body
string
The text body of this message. Present if this is a text message
-
file
ChatKittyFile
The file attached to this message. Present if this is a file message
-
links
MessageLink [ ]
Message links found in this message. Present if this is a text message
-
mentions
Mention [ ]
Mentions of channels and users in this message. Present if this is a text message
-
user
User
The user who sent this message. Absent if this is a system message
-
createdTime
datetime
ISO 8601 date-time when this message was created
properties
object
Custom 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 a message

You can send messages in a channel.

Sending a user text message

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

Parameters

Name
Type
Description
Required
channel
Channel
Channel this message belongs to
body
string
The Unicode text body of this message
properties
object
Custom data associated with this message
-
1
const result = await kitty.sendMessage({
2
channel: channel,
3
body: 'Hello, world!',
4
});
5
6
if (result.succeeded) {
7
const message = result.message; // Handle message
8
}
9
10
if (result.failed) {
11
const error = result.error; // Handle error
12
}
Copied!

Sending a user file message

Using a client SDK, send a user file message.

Parameters

Name
Type
Description
Required
channel
Channel
Channel this message belongs to
file
File
File to upload as an attachment or ChatKitty external file properties
properties
object
Custom data associated with this message
-
progressListener
UploadProgressListener
Listener to be notified as the file upload progresses.
-
1
const result = await kitty.sendMessage({
2
channel: channel,
3
file: file,
4
progressListener: {
5
onStarted: () => {
6
// Handle file upload started
7
},
8
9
onProgress: (progress) => {
10
// Handle file upload process
11
},
12
13
onCompleted: (result) => {
14
// Handle file upload completed
15
},
16
},
17
});
18
19
if (result.succeeded) {
20
const message = result.message; // Handle message
21
}
22
23
if (result.failed) {
24
const error = result.error; // Handle error
25
}
Copied!
post
/channels/:id/messages
Sending a system text message

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 of.
1
const result = await kitty.getMessages({
2
channel: channel,
3
});
4
5
if (result.succeeded) {
6
const messages = result.paginator.items; // Handle messages
7
}
8
9
if (result.failed) {
10
const error = result.error; // Handle error
11
}
Copied!

Observing channel messages

A user can observe new messages in a channel he or she is a member of.
1
kitty.startChatSession({
2
channel: channel,
3
onReceivedMessage: (message) => {
4
// Handle recevied message
5
},
6
});
Copied!
Last modified 3mo ago