Conversation
Methods
addParticipants
addParticipants(participants: ): Promise<MessengerEventTypes.EditConversation,MessengerEventTypes.Error>
Add new participants to the conversation.It's possible only on the following conditions:
- the participants are users of the main Voximplant developer account or its child accounts
- the current user can manage other participants (ConversationParticipant.canManageParticipants is true)
- the conversation is not a direct one (Conversation.direct is false)
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
participants:
Array of ConversationParticipant to be added to the conversation. Should not be null or empty array
Returns
editParticipants
editParticipants(participants: ): 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
participants:
Array of ConversationParticipant to be edited in the conversation. Should not be null or empty array
Returns
markAsRead
markAsRead(sequence: number
):
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.
Returns
type:
removeParticipants
removeParticipants(participants: ): Promise<MessengerEventTypes.EditConversation,MessengerEventTypes.Error>
Remove participants from the conversation. It's possible only on two conditions:
- the current user can manage other participants (ConversationParticipant.canManageParticipants is true).
- the conversation is not a direct one (Conversation.direct is false)Duplicated users are ignored. The promise will be rejected with MessengerEventTypes.Error if at least one user:
- does not exist
- is already removed
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
participants:
Array of ConversationParticipant to be removed from the conversation. Should not be null or empty array
Returns
retransmitEvents
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
Returns
retransmitEventsFrom
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
Returns
retransmitEventsTo
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
Returns
sendMessage
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[]
OptionalMessage payload
Returns
type:
Promise<MessengerEventTypes.SendMessage,MessengerEventTypes.Error>
setCustomData
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
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
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
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.
Returns
type:
Promise<MessengerEventTypes.Typing,MessengerEventTypes.Error>
update
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.
Returns
Props
createdTime
createdTime: number
UNIX timestamp (seconds) that specifies the time of the conversation creation.
customData
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
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
lastSequence: number
Sequence of the last event in the conversation.
lastUpdateTime
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
participants:
Array of participants alongside with their permissions.
publicJoin
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
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
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
uuid: string
Universally unique identifier (UUID) of this conversation.