Conversation
Methods
addParticipants
addParticipants(participants: ): Promise<MessengerEventTypes.EditConversation,MessengerEventTypes.Error>
Adds new participants to the conversation.It is 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 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
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>
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
participants:
Array of ConversationParticipant to be edited in the conversation. Should not be null or empty array
Returns
markAsRead
markAsRead(sequence: number
):
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.
Returns
type:
removeParticipants
removeParticipants(participants: ): Promise<MessengerEventTypes.EditConversation,MessengerEventTypes.Error>
Removes participants from the conversation. It is 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 is 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>
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
Returns
retransmitEventsFrom
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
Returns
retransmitEventsTo
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
Returns
sendMessage
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[]
OptionalMessage payload
Returns
type:
Promise<MessengerEventTypes.SendMessage,MessengerEventTypes.Error>
setCustomData
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
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
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
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.
Returns
type:
Promise<MessengerEventTypes.Typing,MessengerEventTypes.Error>
update
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.
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
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
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 has been triggered in this conversation.
participants
participants:
Array of participants alongside with their permissions.
publicJoin
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
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
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
uuid: string
Universally unique identifier (UUID) of this conversation.