CommentsClient
Client for /api/v1/comments/. The SDK auto-generates the comment id
on createComment when the caller doesn't supply one.
Extends
BaseClient
Constructors
Constructor
new CommentsClient(config: ClientConfig): CommentsClient;
Parameters
| Parameter | Type |
|---|---|
config | ClientConfig |
Returns
CommentsClient
Inherited from
BaseClient.constructor
Properties
| Property | Modifier | Type |
|---|---|---|
apiToken | readonly | string |
baseUrl? | readonly | string |
customFetch? | readonly | CustomFetch |
defaultVersion | readonly | "v1" |
Methods
createComment()
createComment(args: {
actions?: unknown;
attachments?: | {
[key: string]: unknown;
attachmentId: string;
description?: string | null;
duration?: string | null;
fileName?: string | null;
fileSize?: number | null;
image?: string | null;
imageHeight?: number | null;
imageWidth?: number | null;
title?: string | null;
underlyingType?: string | null;
uploadState?: string | null;
url?: string | null;
urlType: string;
video?: string | null;
videoAutoPlay?: boolean | null;
videoType?: string | null;
}[]
| null;
content: string;
directGroupMentions?: string[] | null;
directMentions?: number[] | null;
groups?: string[] | null;
id?: string;
notifyAudience?: "channel" | "thread" | null;
recipients?: number[] | null;
threadId: string;
}): Promise<{
actions?: unknown[] | null;
attachments?: | {
[key: string]: unknown;
attachmentId: string;
description?: string | null;
duration?: string | null;
fileName?: string | null;
fileSize?: number | null;
image?: string | null;
imageHeight?: number | null;
imageWidth?: number | null;
title?: string | null;
underlyingType?: string | null;
uploadState?: string | null;
url?: string | null;
urlType: string;
video?: string | null;
videoAutoPlay?: boolean | null;
videoType?: string | null;
}[]
| null;
channelId: string;
content: string;
conversationId?: string | null;
creator: number;
creatorName?: string | null;
deleted?: boolean | null;
deletedBy?: number | null;
directGroupMentions?: string[] | null;
directMentions?: number[] | null;
groups?: string[] | null;
id: string;
lastEdited?: Date | null;
objIndex?: number | null;
posted: Date;
reactions?: Record<string, unknown> | null;
recipients?: number[] | null;
systemMessage?: unknown;
threadId: string;
toEmails?: string[] | null;
url: string;
version?: number | null;
workspaceId: number;
}>;
Creates a new comment on a thread. id is auto-generated if not supplied.
Parameters
| Parameter | Type | Description |
|---|---|---|
args | { actions?: unknown; attachments?: | { [key: string]: unknown; attachmentId: string; description?: string | null; duration?: string | null; fileName?: string | null; fileSize?: number | null; image?: string | null; imageHeight?: number | null; imageWidth?: number | null; title?: string | null; underlyingType?: string | null; uploadState?: string | null; url?: string | null; urlType: string; video?: string | null; videoAutoPlay?: boolean | null; videoType?: string | null; }[] | null; content: string; directGroupMentions?: string[] | null; directMentions?: number[] | null; groups?: string[] | null; id?: string; notifyAudience?: "channel" | "thread" | null; recipients?: number[] | null; threadId: string; } | The arguments for creating a comment. |
args.actions? | unknown | - |
args.attachments? | | { [key: string]: unknown; attachmentId: string; description?: string | null; duration?: string | null; fileName?: string | null; fileSize?: number | null; image?: string | null; imageHeight?: number | null; imageWidth?: number | null; title?: string | null; underlyingType?: string | null; uploadState?: string | null; url?: string | null; urlType: string; video?: string | null; videoAutoPlay?: boolean | null; videoType?: string | null; }[] | null | Optional array of Attachment objects. |
args.content | string | The comment content. |
args.directGroupMentions? | string[] | null | - |
args.directMentions? | number[] | null | Optional array of user IDs that were @-mentioned in content. |
args.groups? | string[] | null | Optional array of custom group IDs to notify. |
args.id? | string | - |
args.notifyAudience? | "channel" | "thread" | null | Optional broader audience to notify in addition to recipients and groups. 'channel' notifies everyone in the channel; 'thread' notifies everyone who has interacted with the thread. |
args.recipients? | number[] | null | Optional array of user IDs to notify directly. |
args.threadId | string | The thread ID. |
Returns
Promise<{
actions?: unknown[] | null;
attachments?: | {
[key: string]: unknown;
attachmentId: string;
description?: string | null;
duration?: string | null;
fileName?: string | null;
fileSize?: number | null;
image?: string | null;
imageHeight?: number | null;
imageWidth?: number | null;
title?: string | null;
underlyingType?: string | null;
uploadState?: string | null;
url?: string | null;
urlType: string;
video?: string | null;
videoAutoPlay?: boolean | null;
videoType?: string | null;
}[]
| null;
channelId: string;
content: string;
conversationId?: string | null;
creator: number;
creatorName?: string | null;
deleted?: boolean | null;
deletedBy?: number | null;
directGroupMentions?: string[] | null;
directMentions?: number[] | null;
groups?: string[] | null;
id: string;
lastEdited?: Date | null;
objIndex?: number | null;
posted: Date;
reactions?: Record<string, unknown> | null;
recipients?: number[] | null;
systemMessage?: unknown;
threadId: string;
toEmails?: string[] | null;
url: string;
version?: number | null;
workspaceId: number;
}>
The created comment object.
Example
// Notify everyone who has interacted with the thread, plus two extra users.
const comment = await api.comments.createComment({
threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
content: 'Great idea! Let\'s proceed.',
notifyAudience: 'thread',
recipients: [101, 202],
})
deleteComment()
deleteComment(id: string): Promise<{
status: "ok";
}>;
Permanently deletes a comment.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The comment ID. |
Returns
Promise<{
status: "ok";
}>
getBaseUri()
protected getBaseUri(): string;
Returns the base URI for an API request, with a guaranteed trailing
slash so relative paths resolve cleanly through URL.
Returns
string
Inherited from
BaseClient.getBaseUri
getComment()
getComment(id: string): Promise<{
actions?: unknown[] | null;
attachments?: | {
[key: string]: unknown;
attachmentId: string;
description?: string | null;
duration?: string | null;
fileName?: string | null;
fileSize?: number | null;
image?: string | null;
imageHeight?: number | null;
imageWidth?: number | null;
title?: string | null;
underlyingType?: string | null;
uploadState?: string | null;
url?: string | null;
urlType: string;
video?: string | null;
videoAutoPlay?: boolean | null;
videoType?: string | null;
}[]
| null;
channelId: string;
content: string;
conversationId?: string | null;
creator: number;
creatorName?: string | null;
deleted?: boolean | null;
deletedBy?: number | null;
directGroupMentions?: string[] | null;
directMentions?: number[] | null;
groups?: string[] | null;
id: string;
lastEdited?: Date | null;
objIndex?: number | null;
posted: Date;
reactions?: Record<string, unknown> | null;
recipients?: number[] | null;
systemMessage?: unknown;
threadId: string;
toEmails?: string[] | null;
url: string;
version?: number | null;
workspaceId: number;
}>;
Gets a single comment object by id. The API wraps it in {comment: ...}.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | The comment ID. |
Returns
Promise<{
actions?: unknown[] | null;
attachments?: | {
[key: string]: unknown;
attachmentId: string;
description?: string | null;
duration?: string | null;
fileName?: string | null;
fileSize?: number | null;
image?: string | null;
imageHeight?: number | null;
imageWidth?: number | null;
title?: string | null;
underlyingType?: string | null;
uploadState?: string | null;
url?: string | null;
urlType: string;
video?: string | null;
videoAutoPlay?: boolean | null;
videoType?: string | null;
}[]
| null;
channelId: string;
content: string;
conversationId?: string | null;
creator: number;
creatorName?: string | null;
deleted?: boolean | null;
deletedBy?: number | null;
directGroupMentions?: string[] | null;
directMentions?: number[] | null;
groups?: string[] | null;
id: string;
lastEdited?: Date | null;
objIndex?: number | null;
posted: Date;
reactions?: Record<string, unknown> | null;
recipients?: number[] | null;
systemMessage?: unknown;
threadId: string;
toEmails?: string[] | null;
url: string;
version?: number | null;
workspaceId: number;
}>
The comment object.
getComments()
getComments(args: {
limit?: number | null;
newerThan?: Date | null;
olderThan?: Date | null;
threadId: string;
}): Promise<{
actions?: unknown[] | null;
attachments?: | {
[key: string]: unknown;
attachmentId: string;
description?: string | null;
duration?: string | null;
fileName?: string | null;
fileSize?: number | null;
image?: string | null;
imageHeight?: number | null;
imageWidth?: number | null;
title?: string | null;
underlyingType?: string | null;
uploadState?: string | null;
url?: string | null;
urlType: string;
video?: string | null;
videoAutoPlay?: boolean | null;
videoType?: string | null;
}[]
| null;
channelId: string;
content: string;
conversationId?: string | null;
creator: number;
creatorName?: string | null;
deleted?: boolean | null;
deletedBy?: number | null;
directGroupMentions?: string[] | null;
directMentions?: number[] | null;
groups?: string[] | null;
id: string;
lastEdited?: Date | null;
objIndex?: number | null;
posted: Date;
reactions?: Record<string, unknown> | null;
recipients?: number[] | null;
systemMessage?: unknown;
threadId: string;
toEmails?: string[] | null;
url: string;
version?: number | null;
workspaceId: number;
}[]>;
Gets all comments for a thread. newerThan / olderThan (Date) are
converted to newer_than_ts / older_than_ts epoch seconds on the
wire.
Parameters
| Parameter | Type | Description |
|---|---|---|
args | { limit?: number | null; newerThan?: Date | null; olderThan?: Date | null; threadId: string; } | The arguments for getting comments. |
args.limit? | number | null | Optional limit on number of comments returned. |
args.newerThan? | Date | null | Optional date to get comments newer than. |
args.olderThan? | Date | null | Optional date to get comments older than. |
args.threadId | string | The thread ID. |
Returns
Promise<{
actions?: unknown[] | null;
attachments?: | {
[key: string]: unknown;
attachmentId: string;
description?: string | null;
duration?: string | null;
fileName?: string | null;
fileSize?: number | null;
image?: string | null;
imageHeight?: number | null;
imageWidth?: number | null;
title?: string | null;
underlyingType?: string | null;
uploadState?: string | null;
url?: string | null;
urlType: string;
video?: string | null;
videoAutoPlay?: boolean | null;
videoType?: string | null;
}[]
| null;
channelId: string;
content: string;
conversationId?: string | null;
creator: number;
creatorName?: string | null;
deleted?: boolean | null;
deletedBy?: number | null;
directGroupMentions?: string[] | null;
directMentions?: number[] | null;
groups?: string[] | null;
id: string;
lastEdited?: Date | null;
objIndex?: number | null;
posted: Date;
reactions?: Record<string, unknown> | null;
recipients?: number[] | null;
systemMessage?: unknown;
threadId: string;
toEmails?: string[] | null;
url: string;
version?: number | null;
workspaceId: number;
}[]>
An array of comment objects.
Example
const comments = await api.comments.getComments({
threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z',
newerThan: new Date('2024-01-01'),
})
comments.forEach(c => console.log(c.content))
getLinkBaseUrl()
protected getLinkBaseUrl(): string | undefined;
Base URL for entity web links, or undefined to use getFullCommsURL's
default web app. Trailing-slash normalization happens in
getFullCommsURL, so the configured value is returned verbatim.
Returns
string | undefined
Inherited from
BaseClient.getLinkBaseUrl
markPosition()
markPosition(args: MarkCommentPositionArgs): Promise<{
status: "ok";
}>;
Marks the user's read position in a thread. Used to track where the user has read up to, so clients can scroll to this position and show a visual indicator (blue line). Comment IDs are strings.
Parameters
| Parameter | Type | Description |
|---|---|---|
args | MarkCommentPositionArgs | The arguments for marking read position. |
Returns
Promise<{
status: "ok";
}>
Example
await api.comments.markPosition({ threadId: '7YpL3oZ4kZ9vP7Q1tR2sX3z', commentId: '7YpL3oZ4kZ9vP7Q1tR2sX41' })
updateComment()
updateComment(args: {
content: string;
id: string;
}): Promise<{
actions?: unknown[] | null;
attachments?: | {
[key: string]: unknown;
attachmentId: string;
description?: string | null;
duration?: string | null;
fileName?: string | null;
fileSize?: number | null;
image?: string | null;
imageHeight?: number | null;
imageWidth?: number | null;
title?: string | null;
underlyingType?: string | null;
uploadState?: string | null;
url?: string | null;
urlType: string;
video?: string | null;
videoAutoPlay?: boolean | null;
videoType?: string | null;
}[]
| null;
channelId: string;
content: string;
conversationId?: string | null;
creator: number;
creatorName?: string | null;
deleted?: boolean | null;
deletedBy?: number | null;
directGroupMentions?: string[] | null;
directMentions?: number[] | null;
groups?: string[] | null;
id: string;
lastEdited?: Date | null;
objIndex?: number | null;
posted: Date;
reactions?: Record<string, unknown> | null;
recipients?: number[] | null;
systemMessage?: unknown;
threadId: string;
toEmails?: string[] | null;
url: string;
version?: number | null;
workspaceId: number;
}>;
Updates a comment's properties.
Parameters
| Parameter | Type | Description |
|---|---|---|
args | { content: string; id: string; } | The arguments for updating a comment. |
args.content | string | The new comment content. |
args.id | string | The comment ID. |
Returns
Promise<{
actions?: unknown[] | null;
attachments?: | {
[key: string]: unknown;
attachmentId: string;
description?: string | null;
duration?: string | null;
fileName?: string | null;
fileSize?: number | null;
image?: string | null;
imageHeight?: number | null;
imageWidth?: number | null;
title?: string | null;
underlyingType?: string | null;
uploadState?: string | null;
url?: string | null;
urlType: string;
video?: string | null;
videoAutoPlay?: boolean | null;
videoType?: string | null;
}[]
| null;
channelId: string;
content: string;
conversationId?: string | null;
creator: number;
creatorName?: string | null;
deleted?: boolean | null;
deletedBy?: number | null;
directGroupMentions?: string[] | null;
directMentions?: number[] | null;
groups?: string[] | null;
id: string;
lastEdited?: Date | null;
objIndex?: number | null;
posted: Date;
reactions?: Record<string, unknown> | null;
recipients?: number[] | null;
systemMessage?: unknown;
threadId: string;
toEmails?: string[] | null;
url: string;
version?: number | null;
workspaceId: number;
}>
The updated comment object.