ChatThreadClient class

The client to do chat operations

Constructors

ChatThreadClient(string, string, CommunicationTokenCredential, ChatThreadClientOptions)

Properties

threadId

Thread ID of the ChatThreadClient

Methods

addParticipants(AddParticipantsRequest, OperationOptions)

Adds the details of chat participants belonging to the thread identified by threadId.

deleteImage(string, OperationOptions)

Deletes an image identified by threadId and imageId

deleteMessage(string, OperationOptions)

Deletes a message identified by threadId and messageId

getMessage(string, OperationOptions)

Gets a chat message identified by messageId. Returns the specific message.

getProperties(OperationOptions)

Gets a chat thread. Returns the chat thread.

listMessages(RestListMessagesOptions)

Gets a list of message from a thread identified by threadId. Returns the list of the messages.

listParticipants(RestListParticipantsOptions)

Gets the participants of the thread identified by threadId. Returns the lists of the participants.

listReadReceipts(RestListReadReceiptsOptions)

Gets a list of read receipt from a thread identified by threadId. Returns the list of the messages.

removeParticipant(CommunicationIdentifier, OperationOptions)

Removes participant from the thread identified by threadId.

sendMessage(SendMessageRequest, SendMessageOptions)

Sends a chat message to a thread identified by threadId. Returns the id of the created message.

sendReadReceipt(SendReadReceiptRequest, OperationOptions)

Sends a read receipt to the thread identified by threadId.

sendTypingNotification(SendTypingNotificationOptions)

Sends a typing notification to the thread. Doesn't attempt to send if the time since last notification is smaller than the minimum typing interval

updateMessage(string, UpdateMessageOptions)

Updates a message identified by threadId and messageId

updateProperties(UpdateChatThreadPropertiesOptions)

Updates a thread's properties.

updateTopic(string, UpdateTopicOptions)

Updates a thread's topic.

uploadImage(ArrayBuffer | Blob, string, UploadImageOptions)

Uploads an chat image to a thread identified by threadId. Allowed image types "jpg", "png", "gif", "heic", "webp". Returns the id of the uploaded image.

uploadImage(ReadableStream<Uint8Array> | ReadableStream, string, number, OperationOptions)

Uploads an chat image stream to a thread identified by threadId. Allowed image types "jpg", "png", "gif", "heic", "webp". Returns the id of the uploaded image.

Constructor Details

ChatThreadClient(string, string, CommunicationTokenCredential, ChatThreadClientOptions)

new ChatThreadClient(endpoint: string, threadId: string, credential: CommunicationTokenCredential, options?: ChatThreadClientOptions)

Parameters

endpoint

string

threadId

string

Property Details

threadId

Thread ID of the ChatThreadClient

threadId: string

Property Value

string

Method Details

addParticipants(AddParticipantsRequest, OperationOptions)

Adds the details of chat participants belonging to the thread identified by threadId.

function addParticipants(request: AddParticipantsRequest, options?: OperationOptions): Promise<AddChatParticipantsResult>

Parameters

request
AddParticipantsRequest

Thread participants' details to add in the thread roster

options
OperationOptions

Operation options.

Returns

deleteImage(string, OperationOptions)

Deletes an image identified by threadId and imageId

function deleteImage(imageId: string, options?: OperationOptions): Promise<void>

Parameters

imageId

string

The image id of the image.

options
OperationOptions

Operation options.

Returns

Promise<void>

deleteMessage(string, OperationOptions)

Deletes a message identified by threadId and messageId

function deleteMessage(messageId: string, options?: OperationOptions): Promise<void>

Parameters

messageId

string

The message id of the message.

options
OperationOptions

Operation options.

Returns

Promise<void>

getMessage(string, OperationOptions)

Gets a chat message identified by messageId. Returns the specific message.

function getMessage(messageId: string, options?: OperationOptions): Promise<ChatMessage>

Parameters

messageId

string

The message id of the message.

options
OperationOptions

Operation options.

Returns

Promise<ChatMessage>

getProperties(OperationOptions)

Gets a chat thread. Returns the chat thread.

function getProperties(options?: OperationOptions): Promise<ChatThreadProperties>

Parameters

options
OperationOptions

Operation options.

Returns

listMessages(RestListMessagesOptions)

Gets a list of message from a thread identified by threadId. Returns the list of the messages.

function listMessages(options?: RestListMessagesOptions): PagedAsyncIterableIterator<ChatMessage, ChatMessage[], PageSettings>

Parameters

options
RestListMessagesOptions

Get messages options.

Returns

listParticipants(RestListParticipantsOptions)

Gets the participants of the thread identified by threadId. Returns the lists of the participants.

function listParticipants(options?: RestListParticipantsOptions): PagedAsyncIterableIterator<ChatParticipant, ChatParticipant[], PageSettings>

Parameters

options
RestListParticipantsOptions

Operation options.

Returns

listReadReceipts(RestListReadReceiptsOptions)

Gets a list of read receipt from a thread identified by threadId. Returns the list of the messages.

function listReadReceipts(options?: RestListReadReceiptsOptions): PagedAsyncIterableIterator<ChatMessageReadReceipt, ChatMessageReadReceipt[], PageSettings>

Parameters

options
RestListReadReceiptsOptions

Get messages options.

Returns

removeParticipant(CommunicationIdentifier, OperationOptions)

Removes participant from the thread identified by threadId.

function removeParticipant(participant: CommunicationIdentifier, options?: OperationOptions): Promise<void>

Parameters

participant
CommunicationIdentifier

Thread participant to remove from the thread roster

options
OperationOptions

Operation options.

Returns

Promise<void>

sendMessage(SendMessageRequest, SendMessageOptions)

Sends a chat message to a thread identified by threadId. Returns the id of the created message.

function sendMessage(request: SendMessageRequest, options?: SendMessageOptions): Promise<SendChatMessageResult>

Parameters

request
SendMessageRequest

Request for sending a message.

options
SendMessageOptions

Operation options.

Returns

sendReadReceipt(SendReadReceiptRequest, OperationOptions)

Sends a read receipt to the thread identified by threadId.

function sendReadReceipt(request: SendReadReceiptRequest, options?: OperationOptions): Promise<void>

Parameters

request
SendReadReceiptRequest

Request for sending a read receipt

options
OperationOptions

Operation options.

Returns

Promise<void>

sendTypingNotification(SendTypingNotificationOptions)

Sends a typing notification to the thread. Doesn't attempt to send if the time since last notification is smaller than the minimum typing interval

function sendTypingNotification(options?: SendTypingNotificationOptions): Promise<boolean>

Parameters

options
SendTypingNotificationOptions

Operation options

Returns

Promise<boolean>

True if the typing message notification could be sent, otherwise false.

updateMessage(string, UpdateMessageOptions)

Updates a message identified by threadId and messageId

function updateMessage(messageId: string, options?: UpdateMessageOptions): Promise<void>

Parameters

messageId

string

The message id of the message.

options
UpdateMessageOptions

Operation options.

Returns

Promise<void>

updateProperties(UpdateChatThreadPropertiesOptions)

Updates a thread's properties.

function updateProperties(options?: UpdateChatThreadPropertiesOptions): Promise<void>

Parameters

options
UpdateChatThreadPropertiesOptions

Operation options.

Returns

Promise<void>

updateTopic(string, UpdateTopicOptions)

Updates a thread's topic.

function updateTopic(topic: string, options?: UpdateTopicOptions): Promise<void>

Parameters

topic

string

The topic needs to be updated to.

options
UpdateTopicOptions

Operation options.

Returns

Promise<void>

uploadImage(ArrayBuffer | Blob, string, UploadImageOptions)

Uploads an chat image to a thread identified by threadId. Allowed image types "jpg", "png", "gif", "heic", "webp". Returns the id of the uploaded image.

function uploadImage(image: ArrayBuffer | Blob, imageFilename: string, options?: UploadImageOptions): Promise<UploadChatImageResult>

Parameters

image

ArrayBuffer | Blob

Request for uploading an image.

imageFilename

string

The image's file name with file extension.

options
UploadImageOptions

Operation options.

Returns

uploadImage(ReadableStream<Uint8Array> | ReadableStream, string, number, OperationOptions)

Uploads an chat image stream to a thread identified by threadId. Allowed image types "jpg", "png", "gif", "heic", "webp". Returns the id of the uploaded image.

function uploadImage(image: ReadableStream<Uint8Array> | ReadableStream, imageFileName: string, imageBytesLength: number, options?: OperationOptions): Promise<UploadChatImageResult>

Parameters

image

ReadableStream<Uint8Array> | ReadableStream

Request for uploading an image.

imageFileName

string

The image's file name with file extension.

imageBytesLength

number

The image's file length in bytes.

options
OperationOptions

Operation options.

Returns