Skip to main content

ConversationMessagesClient

Client for interacting with Twist conversation message endpoints.

Extends​

  • BaseClient

Constructors​

Constructor​

new ConversationMessagesClient(config: ClientConfig): ConversationMessagesClient;

Parameters​

ParameterType
configClientConfig

Returns​

ConversationMessagesClient

Inherited from​

BaseClient.constructor

Properties​

PropertyModifierType
apiTokenreadonlystring
baseUrl?readonlystring
customFetch?readonlyCustomFetch
defaultVersionreadonly"v3" | "v4"

Methods​

createMessage()​

Call Signature​

createMessage(args: CreateConversationMessageArgs, options: {
batch: true;
}): BatchRequestDescriptor<{
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;
content: string;
conversationId: number;
creator: number;
directGroupMentions?: number[] | null;
directMentions?: number[] | null;
id: number;
isDeleted?: boolean | null;
lastEdited?: Date | null;
objIndex?: number | null;
posted: Date;
reactions?: Record<string, number[]> | null;
systemMessage?: unknown;
url: string;
version?: number | null;
workspaceId: number;
}>;

Creates a new message in a conversation.

Parameters​
ParameterTypeDescription
argsCreateConversationMessageArgsThe arguments for creating a message.
options{ batch: true; }Optional configuration. Set batch: true to return a descriptor for batch requests.
options.batchtrue-
Returns​

BatchRequestDescriptor<{ 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; content: string; conversationId: number; creator: number; directGroupMentions?: number[] | null; directMentions?: number[] | null; id: number; isDeleted?: boolean | null; lastEdited?: Date | null; objIndex?: number | null; posted: Date; reactions?: Record<string, number[]> | null; systemMessage?: unknown; url: string; version?: number | null; workspaceId: number; }>

The created message object.

Example​
const message = await api.conversationMessages.createMessage({
conversationId: 456,
content: 'Thanks for the update!'
})

Call Signature​

createMessage(args: CreateConversationMessageArgs, options?: {
batch?: false;
}): 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;
content: string;
conversationId: number;
creator: number;
directGroupMentions?: number[] | null;
directMentions?: number[] | null;
id: number;
isDeleted?: boolean | null;
lastEdited?: Date | null;
objIndex?: number | null;
posted: Date;
reactions?: Record<string, number[]> | null;
systemMessage?: unknown;
url: string;
version?: number | null;
workspaceId: number;
}>;

Creates a new message in a conversation.

Parameters​
ParameterTypeDescription
argsCreateConversationMessageArgsThe arguments for creating a message.
options?{ batch?: false; }Optional configuration. Set batch: true to return a descriptor for batch requests.
options.batch?false-
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; content: string; conversationId: number; creator: number; directGroupMentions?: number[] | null; directMentions?: number[] | null; id: number; isDeleted?: boolean | null; lastEdited?: Date | null; objIndex?: number | null; posted: Date; reactions?: Record<string, number[]> | null; systemMessage?: unknown; url: string; version?: number | null; workspaceId: number; }>

The created message object.

Example​
const message = await api.conversationMessages.createMessage({
conversationId: 456,
content: 'Thanks for the update!'
})

deleteMessage()​

Call Signature​

deleteMessage(id: number, options: {
batch: true;
}): BatchRequestDescriptor<void>;

Permanently deletes a conversation message.

Parameters​
ParameterTypeDescription
idnumberThe message ID.
options{ batch: true; }Optional configuration. Set batch: true to return a descriptor for batch requests.
options.batchtrue-
Returns​

BatchRequestDescriptor<void>

Example​
await api.conversationMessages.deleteMessage(789)

Call Signature​

deleteMessage(id: number, options?: {
batch?: false;
}): Promise<void>;

Permanently deletes a conversation message.

Parameters​
ParameterTypeDescription
idnumberThe message ID.
options?{ batch?: false; }Optional configuration. Set batch: true to return a descriptor for batch requests.
options.batch?false-
Returns​

Promise<void>

Example​
await api.conversationMessages.deleteMessage(789)

getBaseUri()​

protected getBaseUri(version?: "v3" | "v4"): string;

Gets the base URI for API requests with proper trailing slash handling. This method fixes the trailing slash bug that occurred when using custom baseUrl.

Parameters​

ParameterTypeDescription
version?"v3" | "v4"Optional API version override. Defaults to the configured version or 'v3'

Returns​

string

Base URI with guaranteed trailing slash for proper URL resolution

Inherited from​

BaseClient.getBaseUri

getLinkBaseUrl()​

protected getLinkBaseUrl(): string | undefined;

Base URL for entity web links, or undefined to use getFullTwistURL's default web app.

Returns​

string | undefined

Inherited from​

BaseClient.getLinkBaseUrl

getMessage()​

Call Signature​

getMessage(id: number, options: {
batch: true;
}): BatchRequestDescriptor<{
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;
content: string;
conversationId: number;
creator: number;
directGroupMentions?: number[] | null;
directMentions?: number[] | null;
id: number;
isDeleted?: boolean | null;
lastEdited?: Date | null;
objIndex?: number | null;
posted: Date;
reactions?: Record<string, number[]> | null;
systemMessage?: unknown;
url: string;
version?: number | null;
workspaceId: number;
}>;

Gets a single conversation message by id.

Parameters​
ParameterTypeDescription
idnumberThe message ID.
options{ batch: true; }Optional configuration. Set batch: true to return a descriptor for batch requests.
options.batchtrue-
Returns​

BatchRequestDescriptor<{ 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; content: string; conversationId: number; creator: number; directGroupMentions?: number[] | null; directMentions?: number[] | null; id: number; isDeleted?: boolean | null; lastEdited?: Date | null; objIndex?: number | null; posted: Date; reactions?: Record<string, number[]> | null; systemMessage?: unknown; url: string; version?: number | null; workspaceId: number; }>

The conversation message object.

Example​
const message = await api.conversationMessages.getMessage(514069)

Call Signature​

getMessage(id: number, options?: {
batch?: false;
}): 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;
content: string;
conversationId: number;
creator: number;
directGroupMentions?: number[] | null;
directMentions?: number[] | null;
id: number;
isDeleted?: boolean | null;
lastEdited?: Date | null;
objIndex?: number | null;
posted: Date;
reactions?: Record<string, number[]> | null;
systemMessage?: unknown;
url: string;
version?: number | null;
workspaceId: number;
}>;

Gets a single conversation message by id.

Parameters​
ParameterTypeDescription
idnumberThe message ID.
options?{ batch?: false; }Optional configuration. Set batch: true to return a descriptor for batch requests.
options.batch?false-
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; content: string; conversationId: number; creator: number; directGroupMentions?: number[] | null; directMentions?: number[] | null; id: number; isDeleted?: boolean | null; lastEdited?: Date | null; objIndex?: number | null; posted: Date; reactions?: Record<string, number[]> | null; systemMessage?: unknown; url: string; version?: number | null; workspaceId: number; }>

The conversation message object.

Example​
const message = await api.conversationMessages.getMessage(514069)

getMessages()​

Call Signature​

getMessages(args: GetConversationMessagesArgs, options: {
batch: true;
}): BatchRequestDescriptor<{
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;
content: string;
conversationId: number;
creator: number;
directGroupMentions?: number[] | null;
directMentions?: number[] | null;
id: number;
isDeleted?: boolean | null;
lastEdited?: Date | null;
objIndex?: number | null;
posted: Date;
reactions?: Record<string, number[]> | null;
systemMessage?: unknown;
url: string;
version?: number | null;
workspaceId: number;
}[]>;

Gets all messages in a conversation.

Parameters​
ParameterTypeDescription
argsGetConversationMessagesArgsThe arguments for getting messages.
options{ batch: true; }Optional configuration. Set batch: true to return a descriptor for batch requests.
options.batchtrue-
Returns​

BatchRequestDescriptor<{ 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; content: string; conversationId: number; creator: number; directGroupMentions?: number[] | null; directMentions?: number[] | null; id: number; isDeleted?: boolean | null; lastEdited?: Date | null; objIndex?: number | null; posted: Date; reactions?: Record<string, number[]> | null; systemMessage?: unknown; url: string; version?: number | null; workspaceId: number; }[]>

An array of message objects.

Example​
const messages = await api.conversationMessages.getMessages({
conversationId: 456,
newerThan: new Date('2024-01-01')
})

Call Signature​

getMessages(args: GetConversationMessagesArgs, options?: {
batch?: false;
}): 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;
content: string;
conversationId: number;
creator: number;
directGroupMentions?: number[] | null;
directMentions?: number[] | null;
id: number;
isDeleted?: boolean | null;
lastEdited?: Date | null;
objIndex?: number | null;
posted: Date;
reactions?: Record<string, number[]> | null;
systemMessage?: unknown;
url: string;
version?: number | null;
workspaceId: number;
}[]>;

Gets all messages in a conversation.

Parameters​
ParameterTypeDescription
argsGetConversationMessagesArgsThe arguments for getting messages.
options?{ batch?: false; }Optional configuration. Set batch: true to return a descriptor for batch requests.
options.batch?false-
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; content: string; conversationId: number; creator: number; directGroupMentions?: number[] | null; directMentions?: number[] | null; id: number; isDeleted?: boolean | null; lastEdited?: Date | null; objIndex?: number | null; posted: Date; reactions?: Record<string, number[]> | null; systemMessage?: unknown; url: string; version?: number | null; workspaceId: number; }[]>

An array of message objects.

Example​
const messages = await api.conversationMessages.getMessages({
conversationId: 456,
newerThan: new Date('2024-01-01')
})

updateMessage()​

Call Signature​

updateMessage(args: UpdateConversationMessageArgs, options: {
batch: true;
}): BatchRequestDescriptor<{
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;
content: string;
conversationId: number;
creator: number;
directGroupMentions?: number[] | null;
directMentions?: number[] | null;
id: number;
isDeleted?: boolean | null;
lastEdited?: Date | null;
objIndex?: number | null;
posted: Date;
reactions?: Record<string, number[]> | null;
systemMessage?: unknown;
url: string;
version?: number | null;
workspaceId: number;
}>;

Updates a conversation message.

Parameters​
ParameterTypeDescription
argsUpdateConversationMessageArgsThe arguments for updating a message.
options{ batch: true; }Optional configuration. Set batch: true to return a descriptor for batch requests.
options.batchtrue-
Returns​

BatchRequestDescriptor<{ 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; content: string; conversationId: number; creator: number; directGroupMentions?: number[] | null; directMentions?: number[] | null; id: number; isDeleted?: boolean | null; lastEdited?: Date | null; objIndex?: number | null; posted: Date; reactions?: Record<string, number[]> | null; systemMessage?: unknown; url: string; version?: number | null; workspaceId: number; }>

The updated message object.

Example​
const message = await api.conversationMessages.updateMessage({
id: 789,
content: 'Updated message content'
})

Call Signature​

updateMessage(args: UpdateConversationMessageArgs, options?: {
batch?: false;
}): 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;
content: string;
conversationId: number;
creator: number;
directGroupMentions?: number[] | null;
directMentions?: number[] | null;
id: number;
isDeleted?: boolean | null;
lastEdited?: Date | null;
objIndex?: number | null;
posted: Date;
reactions?: Record<string, number[]> | null;
systemMessage?: unknown;
url: string;
version?: number | null;
workspaceId: number;
}>;

Updates a conversation message.

Parameters​
ParameterTypeDescription
argsUpdateConversationMessageArgsThe arguments for updating a message.
options?{ batch?: false; }Optional configuration. Set batch: true to return a descriptor for batch requests.
options.batch?false-
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; content: string; conversationId: number; creator: number; directGroupMentions?: number[] | null; directMentions?: number[] | null; id: number; isDeleted?: boolean | null; lastEdited?: Date | null; objIndex?: number | null; posted: Date; reactions?: Record<string, number[]> | null; systemMessage?: unknown; url: string; version?: number | null; workspaceId: number; }>

The updated message object.

Example​
const message = await api.conversationMessages.updateMessage({
id: 789,
content: 'Updated message content'
})