Skip to main content

ConversationMessagesClient

Client for interacting with Twist conversation message endpoints.

Constructors

Constructor

new ConversationMessagesClient(apiToken: string, baseUrl?: string): ConversationMessagesClient;

Parameters

ParameterType
apiTokenstring
baseUrl?string

Returns

ConversationMessagesClient

Methods

createMessage()

Call Signature

createMessage(args: CreateConversationMessageArgs, options: {
batch: true;
}): BatchRequestDescriptor<{
actions?: unknown[] | null;
attachments?: unknown[] | 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;
version?: number | null;
workspaceId?: number | null;
}>;

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?: unknown[] | 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; version?: number | null; workspaceId?: number | null; }>

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?: unknown[] | 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;
version?: number | null;
workspaceId?: number | null;
}>;

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?: unknown[] | 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; version?: number | null; workspaceId?: number | null; }>

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)

getMessage()

Call Signature

getMessage(id: number, options: {
batch: true;
}): BatchRequestDescriptor<{
actions?: unknown[] | null;
attachments?: unknown[] | 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;
version?: number | null;
workspaceId?: number | null;
}>;

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?: unknown[] | 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; version?: number | null; workspaceId?: number | null; }>

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?: unknown[] | 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;
version?: number | null;
workspaceId?: number | null;
}>;

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?: unknown[] | 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; version?: number | null; workspaceId?: number | null; }>

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?: unknown[] | 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;
version?: number | null;
workspaceId?: number | null;
}[]>;

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?: unknown[] | 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; version?: number | null; workspaceId?: number | null; }[]>

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?: unknown[] | 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;
version?: number | null;
workspaceId?: number | null;
}[]>;

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?: unknown[] | 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; version?: number | null; workspaceId?: number | null; }[]>

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?: unknown[] | 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;
version?: number | null;
workspaceId?: number | null;
}>;

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?: unknown[] | 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; version?: number | null; workspaceId?: number | null; }>

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?: unknown[] | 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;
version?: number | null;
workspaceId?: number | null;
}>;

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?: unknown[] | 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; version?: number | null; workspaceId?: number | null; }>

The updated message object.

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