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.
Schema
type required | string The type of this message |
id required | integer <int64> 64-bit integer identifier associated with this resource |
body required | string The text body of this message |
channel_id required | integer <int64> The ID of the channel this message belongs to |
created_time required | string <date-time> The time this message was created |
group_tag | string Optional string to associate this message with other messages. Can be used to group messages into a gallery |
last_edited_time | string <date-time> The time this message was last edited |
Array of objects (MessageLinkProperties) Link previews in this message | |
Array of objects (MessageMentionProperties) Mentions in this message | |
nested_level required | integer <int32> The nested thread level of this message |
required | object Custom data associated with this message |
Array of objects (MessageReactionsSummaryProperties) Reactions to this message | |
replies_count | integer <int64> The number of replies to this message |
required | object (ChatUserProperties) |
Array of objects (Link) Hypermedia control links for this resource |
{- "id": 44902,
- "type": "TEXT",
- "channelId": 702,
- "user": {
- "id": 39953,
- "type": "PERSON",
- "name": "hey@mailinator.com",
- "displayName": "hey",
- "presence": {
- "status": "UNAVAILABLE",
- "online": false
}, - "properties": { }
}, - "body": "🌞",
- "properties": { },
- "createdTime": "2021-09-16T20:45:33.696Z",
- "_links": {
}
}
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 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
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 | - |
const result = await chatkitty.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
Name | Type | Description | Required |
---|---|---|---|
message | Message | parent message being replied to | ✔ |
body | string | The Unicode text body of this message | ✔ |
properties | object | Custom data associated with this message | - |
const result = await chatkitty.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
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. | - |
const result = await chatkitty.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
Name | Type | Description | Required |
---|---|---|---|
message | Message | parent message being replied 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. | - |
const result = await chatkitty.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
}
Listing messages
You can list previous messages and observe new messages.
Listing channel messages
A user can list previous messages in a channel he or she is a member.
const result = await chatkitty.listMessages({
channel: channel
});
if (result.succeeded) {
const messages = result.paginator.items; // Handle messages
}
if (result.failed) {
const error = result.error; // Handle error
}
Listing message replies
List replies to a message.
const result = await chatkitty.listMessages({
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.
chatkitty.startChatSession({
channel: channel,
onMessageReceived: (message) => {
// Handle received message
}
});
Mentions
Mentions are a direct way to notify users of things that need their attention in a message. Mentions can trigger notifications and are embedded inside a message.
Schema
type required | string The type of this message mention |
end_position required | integer <int32> The ending position of this mention reference inside its message |
start_position required | integer <int32> The starting position of this mention reference inside its message |
tag required | string The literal text referencing the mentioned entity inside the message |
required | object (MessageMentionChannelProperties) Channel properties embedded in channel mentions |
{- "type": "CHANNEL",
- "end_position": 0,
- "start_position": 0,
- "tag": "string",
- "channel": {
- "type": "DIRECT",
- "id": 0,
- "created_time": "2019-08-24T14:15:22Z",
- "creator": {
- "type": "PERSON",
- "id": 0,
- "call_status": "AVAILABLE",
- "display_name": "string",
- "display_picture_url": "string",
- "isGuest": true,
- "name": "string",
- "presence": {
- "online": true,
- "status": "string"
}, - "properties": {
- "property1": { },
- "property2": { }
}
}, - "display_name": "string",
- "name": "string",
- "properties": {
- "property1": { },
- "property2": { }
}
}
}
Mention types
There are two types of message mentions:
Channel mention
This notifies all members of a public or private channel.
Additional Properties
Name | Type | Description | Required |
---|---|---|---|
channel | Channel | The channel that was mentioned | ✔ |
User mention
This notifies a user.
Additional Properties
Name | Type | Description | Required |
---|---|---|---|
user | User | The user that was mentioned | ✔ |
Mentioning users and channels
Users can mention channels and users inside their messages using ChatKitty's mention syntax.
Mentioning a user
You can mention a user using the ChatKitty user mention syntax inside a text message: <@username>
where username
is the username of the user being mentioned.
const result = await chatkitty.sendMessage({
channel: channel,
body: 'Hello, <@jane@chatkitty.com>!'
});
if (result.succeeded) {
const message = result.message; // Handle message
}
if (result.failed) {
const error = result.error; // Handle error
}
Mentioning a channel
You can mention a channel using the ChatKitty channel mention syntax inside a text message: <#channelName>
where channelName
is the name of the channel being mentioned.
const result = await chatkitty.sendMessage({
channel: channel,
body: 'Hello, <#my-public-channel>!'
});
if (result.succeeded) {
const message = result.message; // Handle message
}
if (result.failed) {
const error = result.error; // Handle error
}
Message Links
Message Links contain parsed link preview data like an image and description and are embedded inside a message.
Schema
end_position required | integer <int32> The ending index of this link within the message |
object (MessageLinkPreviewProperties) Embedded link preview data | |
source required | string The href of the URL this message link represents |
start_position required | integer <int32> The starting index of this link within the message |
{- "end_position": 0,
- "preview": {
- "description": "string",
- "image": {
- "source": "string"
}, - "site_name": "string",
- "title": "string",
- "url": "string"
}, - "source": "string",
- "start_position": 0
}
Creating message links
Message links are automatically created for URLs embedded inside text messages:
const result = await chatkitty.sendMessage({
channel: channel,
body: "Here's a link! https://chatkitty.com"
});
if (result.succeeded) {
const links = result.message.links; // Handle message links
}
if (result.failed) {
const error = result.error; // Handle error
}