Rate this page:

Conversation

Methods

addParticipants

Copy URL
addParticipants(participants: 

ConversationParticipant[]

):

Promise<MessengerEventTypes.EditConversation,MessengerEventTypes.Error>

Add new participants to the conversation.It's possible only on the following conditions:

Duplicated users are ignored. The promise will be rejected with MessengerEventTypes.Error if at least one user does not exist or already belongs to the conversation.

Other parties of the conversation (online participants and logged in clients) can be informed about adding participants via the MessengerEventTypes.EditConversation event.

Parameters

  • Array of ConversationParticipant to be added to the conversation. Should not be null or empty array

editParticipants

Copy URL
editParticipants(participants: 

ConversationParticipant[]

):

Promise<MessengerEventTypes.EditConversation,MessengerEventTypes.Error>

Edit participants' permissions. It's possible only if the current user can manage other participants ConversationParticipant.canManageParticipants is true).Duplicated users are ignored. The list of participants must contain all participants. Other parties of the conversation (online participants and logged in clients) can be informed about editing participants via the MessengerEventTypes.EditConversation event.

Parameters

  • Array of ConversationParticipant to be edited in the conversation. Should not be null or empty array

markAsRead

Copy URL
markAsRead(sequence: 

number

):

Promise<MessengerEventTypes.Read,MessengerEventTypes.Error>

Mark the event with the specified sequence as read.A method call with the specified sequence makes the ConversationParticipant.lastReadEventSequence return this sequence, i.e., such sequences can be get for each participant separately.

If the sequence parameter specified less than 1, the method will mark all the events as unread (for this participant) except the event with the sequence equals to '1'.

Other parties of the conversation (online participants and logged in clients) can be informed about marking events as read via the MessengerEventTypes.Read event.

Parameters

  • sequence:

    number

    Sequence number of the event in the conversation to be marked as read. Shouldn't be greater than currently possible.

removeParticipants

Copy URL
removeParticipants(participants: 

ConversationParticipant[]

):

Promise<MessengerEventTypes.EditConversation,MessengerEventTypes.Error>

Remove participants from the conversation. It's possible only on two conditions:

Note that you can remove participants that are marked as deleted (User.isDeleted is true).

The removed participants can later get this conversation's UUID via the User.leaveConversationList.

Other parties of the conversation (online participants and logged in clients) can be informed about removing participants via the MessengerEventTypes.EditConversation event.

Parameters

  • Array of ConversationParticipant to be removed from the conversation. Should not be null or empty array

retransmitEvents

Copy URL
retransmitEvents(from: 

number

,
to:

number

):

Promise<MessengerEventTypes.RetransmitEvents,MessengerEventTypes.Error>

Request events in the specified sequence range to be sent from the cloud to this client.Only MessengerEventTypes.CreateConversation, MessengerEventTypes.EditConversation, MessengerEventTypes.SendMessage, MessengerEventTypes.EditMessage and MessengerEventTypes.RemoveMessage events can be retransmitted; any other events can't be retransmitted.

The method is used to get history or missed events in case of network disconnect. Client should use this method to request all events based on the last event sequence received from the cloud and last event sequence saved locally (if any).

The maximum amount of retransmitted events per method call is 100. The promise will be rejected with MessengerEventTypes.Error if more than 100 events are requested.

If the current user quits a Conversation.uber conversation, messages that are posted during the user's absence will not be retransmitted later.

Parameters

  • from:

    number

    First event in range sequence, inclusive

  • to:

    number

    Last event in sequence range, inclusive

retransmitEventsFrom

Copy URL
retransmitEventsFrom(from: 

number

,
count:

number

):

Promise<MessengerEventTypes.RetransmitEvents,MessengerEventTypes.Error>

Request a number of events starting with the specified sequence to be sent from the cloud to this client.Only MessengerEventTypes.CreateConversation, MessengerEventTypes.EditConversation, MessengerEventTypes.SendMessage, MessengerEventTypes.EditMessage and MessengerEventTypes.RemoveMessage events can be retransmitted; any other events can't be retransmitted.

The method is used to get history or missed events in case of network disconnect. Client should use this method to request all events based on the last event sequence received from the cloud and last event sequence saved locally (if any).

The maximum amount of retransmitted events per method call is 100. The promise will be rejected with MessengerEventTypes.Error if more than 100 events are requested.

If the current user quits a Conversation.uber conversation, messages that are posted during the user's absence will not be retransmitted later.

The result contains maximum available events for the current user even if it's less than the specified count value.

Parameters

  • from:

    number

    First event in sequence range, inclusive

  • count:

    number

    Number of events

retransmitEventsTo

Copy URL
retransmitEventsTo(to: 

number

,
count:

number

):

Promise<MessengerEventTypes.RetransmitEvents,MessengerEventTypes.Error>

Request a number of events up to the specified sequence to be sent from the cloud to this client.Only MessengerEventTypes.CreateConversation, MessengerEventTypes.EditConversation, MessengerEventTypes.SendMessage, MessengerEventTypes.EditMessage and MessengerEventTypes.RemoveMessage events can be retransmitted; any other events can't be retransmitted.

The method is used to get history or missed events in case of network disconnect. Client should use this method to request all events based on the last event sequence received from the cloud and last event sequence saved locally (if any).

The maximum amount of retransmitted events per method call is 100. The promise will be rejected with MessengerEventTypes.Error if more than 100 events are requested.

If the current user quits a Conversation.uber conversation, messages that are posted during the user's absence will not be retransmitted later.

The result contains maximum available events for the current user even if it's less than the specified count value.

Parameters

  • to:

    number

    Last event in sequence range, inclusive

  • count:

    number

    Number of events

sendMessage

Copy URL
sendMessage(text: 

string

,
payload:

object[]

):

Promise<MessengerEventTypes.SendMessage,MessengerEventTypes.Error>

Send a message to the conversation.Sending messages is available only for participants that have write permissions (ConversationParticipant.canWrite is true).

Other parties of the conversation (online participants and logged in clients) can be informed about sending messages to the conversation via the MessengerEventTypes.SendMessage event.

To be informed about sending messages while being offline, participants can subscribe to the MessengerNotification.SendMessage messenger push notification.

Parameters

  • text:

    string

    Message text, maximum 5000 characters

  • payload:

    object[]

    Optional

    Message payload

setCustomData

Copy URL
setCustomData(customData: 

object

):

void

Set the JS object custom data. Note that setting this property does not send changes to the server. Use the Conversation.update to send all changes at once.

Parameters

  • customData:

    object

    New custom data of the conversation

Returns

  • type:

    void

setPublicJoin

Copy URL
setPublicJoin(publicJoin: 

boolean

):

void

Set the public join flag. Note that setting this property does not send changes to the server. Use the Conversation.update to send all changes at once.

Parameters

  • publicJoin:

    boolean

Returns

  • type:

    void

setTitle

Copy URL
setTitle(title: 

string

):

void

Set the conversation title. Note that setting this property does not send changes to the server. Use the Conversation.update to send all changes at once.

Parameters

  • title:

    string

Returns

  • type:

    void

typing

Copy URL
typing(): 

Promise<MessengerEventTypes.Typing,MessengerEventTypes.Error>

Inform the cloud that the user is typing some text.The promise will be rejected with MessengerEventTypes.Error for the method calls within 10s interval from the last call cause.

Other parties of the conversation (online participants and logged in clients) can be informed about typing via the MessengerEventTypes.Typing event.

update

Copy URL
update(): 

Promise<MessengerEventTypes.EditConversation,MessengerEventTypes.Error>

Send conversation changes to the cloud. The sent changes are: title, public join flag and custom data.Successful update will happen if a participant is the owner (ConversationParticipant.owner is true).

Other parties of the conversation (online participants and logged in clients) can be informed about changing the title or custom data and enabling/disabling public join via the MessengerEventTypes.EditConversation event.

Props

createdTime

Copy URL
createdTime: 

number

UNIX timestamp (seconds) that specifies the time of the conversation creation.

customData

Copy URL
customData: 

object

JavaScript object with custom data, up to 5kb. Note that setting this property does not send changes to the server. Use the Conversation.update to send all changes at once.

direct

Copy URL
direct: 

boolean

Check if the conversation is direct. A direct conversation can't be uber and/or public.

There can be only 2 participants in a direct conversation which is unique and the only one for these participants. There can't be more than 1 direct conversation for the same 2 users.

If one of these users tries to create a new direct conversation with the same participant via Messenger.createConversation, the method will return the UUID of the already existing direct conversation.

lastSequence

Copy URL
lastSequence: 

number

Sequence of the last event in the conversation.

lastUpdateTime

Copy URL
lastUpdateTime: 

number

UNIX timestamp (seconds) that specifies the time when the last MessengerEventTypes.CreateConversation, MessengerEventTypes.EditConversation, MessengerEventTypes.SendMessage, MessengerEventTypes.EditMessage or MessengerEventTypes.RemoveMessage event was provoked in this conversation.

participants

Copy URL
participants: 

ConversationParticipant[]

Array of participants alongside with their permissions.

publicJoin

Copy URL
publicJoin: 

boolean

Check if a conversation is public or not. If true, anyone can join the conversation by UUID. A public conversation can't be direct.

Note that setting this property does not send changes to the server. Use the Conversation.update to send all changes at once.

title

Copy URL
title: 

string

The current conversation title. Note that setting this property does not send changes to the server. Use the Conversation.update to send all changes at once.

uber

Copy URL
uber: 

boolean

Check if the conversation is uber or not. A uber conversation can't be direct.

Users in a uber conversation will not be able to retrieve messages that were posted to the conversation after they quit.

uuid

Copy URL
uuid: 

string

Universally unique identifier (UUID) of this conversation.