Rate this page:

Conversation

Methods

addParticipants

Copy URL
addParticipants(participants: 

ConversationParticipant[]

):

Promise<MessengerEventTypes.EditConversation,MessengerEventTypes.Error>

Adds new participants to the conversation.It is possible only on the following conditions:

Duplicated users are ignored. The promise is 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>

Edits participants' permissions. It is possible only if the current user can manage other participants ConversationParticipant.canManageParticipants is true).Duplicated users are ignored. The list of participants should 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>

Marks 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 marks 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. Should not be greater than currently possible.

removeParticipants

Copy URL
removeParticipants(participants: 

ConversationParticipant[]

):

Promise<MessengerEventTypes.EditConversation,MessengerEventTypes.Error>

Removes participants from the conversation. It is 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>

Requests 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 cannot be retransmitted.

Use this method 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 number of retransmitted events per method call is 100. The promise is 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 are not to 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>

Requests 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 cannot be retransmitted.

Use this method 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 number of retransmitted events per method call is 100. The promise is 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 are not to be retransmitted later.

The result contains maximum available events for the current user even if it is 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>

Requests 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 cannot be retransmitted.

Use this method 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 number of retransmitted events per method call is 100. The promise is 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 are not to be retransmitted later.

The result contains maximum available events for the current user even if it is 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>

Sends 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

Sets 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

Sets 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

Sets 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>

Informs the cloud that the user is typing some text.The promise is 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>

Sends conversation changes to the cloud. The sent changes are: title, public join flag and custom data.Successful update happens 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

Whether the conversation is direct. A direct conversation cannot 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 cannot 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 returns 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 has been triggered in this conversation.

participants

Copy URL
participants: 

ConversationParticipant[]

Array of participants alongside with their permissions.

publicJoin

Copy URL
publicJoin: 

boolean

Whether a conversation is public. If true, anyone can join the conversation by UUID. A public conversation cannot 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

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

Whether the conversation is uber. A uber conversation cannot be direct.

Users in a uber conversation cannot retrieve messages that have been posted to the conversation after they quit.

uuid

Copy URL
uuid: 

string

Universally unique identifier (UUID) of this conversation.