Rate this page:

Conversation

Class that represents a conversation. A Conversation instance is returned by the Messenger.createConversationand Messenger.createConversationFromCachemethods. It's used to send messages, manage participants, receive conversation events history etc.

Props

createdAt

Copy URL
createdAt: 

number

UNIX timestamp (seconds) that specifies the time the conversation was created.

customData

Copy URL
customData: 

any

Any JavaScript structure with custom data, up to 5Kb. Note that setting this property does not send changes to the cloud. Use the Conversation.updatemethod to send all changes at once or Conversation.setCustomDatato update just the custom data.

direct

Copy URL
direct: 

boolean

A direct conversation includes only 2 participants. There can't be more than 1 direct conversation between 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 existing direct conversation. A direct conversation can't be uber and/or public.

lastSeq

Copy URL
lastSeq: 

any

The sequence of the last event in the conversation.

lastUpdate

Copy URL
lastUpdate: 

any

UNIX timestamp (seconds) that specifies the time of the last event in the conversation.

participants

Copy URL
participants: 

ConversationParticipant[]

The list of conversation participants alongside with their rights. The default permissions for all participants are: write / edit / remove their own messages (see ConversationParticipant.canWrite ConversationParticipant.canEditand ConversationParticipant.canRemove. The creator of the conversation is an owner by default. An owner of the conversation (see ConversationParticipant.isOwner:

  • can write messages
  • can edit and remove own and other participants' messages
  • can manage conversation participants

publicJoin

Copy URL
publicJoin: 

boolean

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 cloud. Use the Conversation.updatemethod to send all changes at once or Conversation.setPublicJointo update only the public join property.

title

Copy URL
title: 

string

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

uberConversation

Copy URL
uberConversation: 

boolean

Users in a uber conversation are not able to retrieve messages that were posted to the conversation after they quit or before they joined. A uber conversation can't be direct.

uuid

Copy URL
uuid: 

string

The universally unique identifier (UUID) of the conversation.

Methods

addParticipants

Copy URL
addParticipants(participants: 

ConversationParticipant[]

):

Promise<EditConversationEvent>

Add new participants to the conversation. Duplicated users are ignored. Triggers the MessengerEvents.EditConversationevent for all parties of the conversation (online participants and logged in clients). To get the result, use one of these options:

Parameters

Returns

editParticipants

Copy URL
editParticipants(participants: 

ConversationParticipant[]

):

Promise<EditConversationEvent>

Change permissions for conversation participants. Duplicated users are ignored. This method doesn't add or remove participants. Use the Conversation.addParticipantsand Conversation.removeParticipantsmethods instead. Triggers the MessengerEvents.EditConversationevent for all parties of the conversation (online participants and logged in clients). To get the result, use one of these options:

Parameters

Returns

markAsRead

Copy URL
markAsRead(seq: 

number

):

Promise<ReadEvent>

Mark the event which has the specified sequence as read. This affects the current participant's ConversationParticipant.lastReadproperty and can be used to display unread messages. Triggers the MessengerEvents.Readevent for all parties of the conversation (online participants and logged in clients). To get the result, use one of these options:

Parameters

  • seq:

    number

Returns

removeParticipants

Copy URL
removeParticipants(participants: 

ConversationParticipant[]

):

Promise<EditConversationEvent>

Remove participants from the conversation. Duplicated users are ignored. Will fail if any user does not exist. Triggers the MessengerEvents.EditConversationevent for all parties of the conversation (online participants and logged in clients). To get the result, use one of these options:

Parameters

Returns

retransmitEvents

Copy URL
retransmitEvents(eventsFrom: 

number

,
eventsTo:

number

,
count:

number

):

Promise<RetransmitEventsEvent>

Request events in the specified sequence range to be sent from the cloud to this client. Only MessengerEvents.CreateConversation MessengerEvents.EditConversation MessengerEvents.SendMessageand MessengerEvents.EditMessageevents can be retransmitted; any other events cannot. 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 conversation event sequence received from the cloud and last event sequence saved locally (if any). If the current user quits an uber conversation (see Conversation.uberConversation, messages that are posted during the user's absence will not be retransmitted later. The maximum amount for requested events per method call is 100. Triggers multiple MessengerEvents.RetransmitEventsevents (for each retransmitted event). To get the result, use one of these options:

Parameters

  • eventsFrom:

    number

    First event in sequence range, inclusive

  • eventsTo:

    number

    Last event in sequence range, inclusive

  • count:

    number

    Optional

Returns

sendMessage

Copy URL
sendMessage(text: 

string

,
payload:

any[]

):

Promise<SendMessageEvent>

Send a message to the conversation. Triggers the MessengerEvents.SendMessageevent for all parties of the conversation (online participants and logged in clients). To get the result, use one of these options:

Parameters

  • text:

    string

  • payload:

    any[]

    Optional

    Custom payload; can be an array of any objects, but not primitive types

Returns

setCustomData

Copy URL
setCustomData(customData: 

any

):

Promise<EditConversationEvent>

Set new custom data for the conversation. Triggers the MessengerEvents.EditConversationevent. To get the result, use one of these options:

Parameters

  • customData:

    any

Returns

setPublicJoin

Copy URL
setPublicJoin(publicJoin: 

boolean

):

Promise<EditConversationEvent>

Set the public join flag and send changes to the server. Triggers the MessengerEvents.EditConversationevent. To get the result, use one of these options:

Parameters

  • publicJoin:

    boolean

Returns

setTitle

Copy URL
setTitle(title: 

string

):

Promise<EditConversationEvent>

Set a new title for the current conversation. Triggers the MessengerEvents.EditConversationevent. To get the result, use one of these options:

Parameters

  • title:

    string

Returns

toCache

Copy URL
toCache(): 

SerializedConversation

Serialize the conversation so it can be stored (e.g. in IndexedDB) and restored later via the Messenger.createConversationFromCachemethod.

typing

Copy URL
typing(): 

Promise<TypingEvent,false>

Inform the cloud that the user is typing some text. The minimum interval between the two method calls must be 10 seconds. Triggers the MessengerEvents.Typingevent for all parties of the conversation (online participants and logged in clients). To get the result, use one of these options:

Returns

update

Copy URL
update(): 

Promise<EditConversationEvent>

Send changes made via modifying conversation properties (Conversation.title Conversation.publicJoinand Conversation.customData to the cloud. Triggers the MessengerEvents.EditConversationevent. To get the result, use one of these options:

Returns