Messenger
Interface that provides API to control messaging functions.
Methods
addEventListener
addEventListener(eventName: , listener: (event: AnyMessengerEvent) => void | Promise<void>
, options: ): void
Parameters
eventName:
listener:
(event: AnyMessengerEvent) => void | Promise<void>
options:
Returns
type:
void
createConversation
createConversation(conversationConfig: ): Promise<ConversationEventPayload>
Creates a new conversation with extended configuration.
Other participants in the conversation (online participants and logged-in clients) can be informed about the creation via the MessengerEventType.onCreateConversation event. You can use the MessengerEventType.onCreateConversation event to notify online participants and logged-in clients of the status change for that user.
Returns a promise that resolves to a ConversationEventPayload object.
Parameters
conversationConfig:
OptionalConversation configuration
Returns
type:
Promise<ConversationEventPayload>
Throws
editUser
editUser(options: ): Promise<UserEventPayload>
Edits the current user information.
You can use the MessengerEventType.onEditUser event to notify the users subscribed to the current user that user information has been updated.
Returns a promise that resolves to a UserEventPayload object containing the updated data.
Parameters
options:
User data available for editing
Returns
type:
Promise<UserEventPayload>
Throws
getConversation
getConversation(uuid: string
): Promise<ConversationEventPayload>
Gets a conversation by its UUID.
This operation is possible if:
- The user calling the method is or has been a participant in the conversation.
- The conversation is an available public conversation (see Messenger.getPublicConversations).
Returns a promise that resolves to a ConversationEventPayload object.
Parameters
uuid:
string
Conversation UUID
Returns
type:
Promise<ConversationEventPayload>
Throws
getConversations
getConversations(uuids: string[]
): Promise<ConversationEventPayload[]>
Gets multiple conversations by a list of UUIDs. Maximum 30 conversations.
This operation is possible if:
- The user calling the method is or has been a participant in each of the conversations.
- Each conversation is an available public conversation (see Messenger.getPublicConversations).
Returns a promise that resolves to an array of ConversationEventPayload objects.
Parameters
uuids:
string[]
Array of conversation UUIDs. Maximum 30 conversations.
Returns
type:
Promise<ConversationEventPayload[]>
Throws
getMe
getMe(): null | string
Gets the Voximplant user identifier for the current user, e.g., 'username@appname.accname'.
Returns
null
if the user is not logged in.
Returns
type:
null | string
getPublicConversations
getPublicConversations(): Promise<ConversationListEventPayload>
Gets all public conversations (Conversation.isPublicJoin is true).
This operation returns all public conversation UUIDs created by:
- The current user.
- Other users of the same child account.
- Users of the main Voximplant developer account.
Returns a promise that resolves to a ConversationListEventPayload object.
Returns
type:
Promise<ConversationListEventPayload>
Throws
getSubscriptionList
getSubscriptionList(): Promise<SubscriptionEventPayload>
Obtains all current subscriptions and returns a list of users to which the current user is subscribed.
Returns a promise that resolves to a SubscriptionEventPayload object.
Returns
type:
Promise<SubscriptionEventPayload>
Throws
getUser
getUser(userName: string
): Promise<UserEventPayload>
Obtains information about the user specified by the Voximplant username, e.g., 'username@appname.accname'.
You can request any user linked to the main Voximplant developer account or its child accounts.
Returns a promise that resolves to a UserEventPayload object if the operation succeeds.
Parameters
userName:
string
Voximplant user identifier
Returns
type:
Promise<UserEventPayload>
Throws
getUserByImId
getUserByImId(imId: number
): Promise<UserEventPayload>
Obtains information about the user specified by the IM user ID.
You can request any user linked to the main Voximplant developer account or its child accounts.
Returns a promise that resolves to a UserEventPayload object if the operation succeeds.
Parameters
imId:
number
IM user ID
Returns
type:
Promise<UserEventPayload>
Throws
getUsers
getUsers(userNames: string[]
): Promise<UserEventPayload[]>
Obtains information about the users specified by the list of Voximplant user names. Maximum of 50 users.
You can request users linked to the main Voximplant developer account or its child accounts.
Returns a promise that resolves to an array of UserEventPayload objects if the operation succeeds. The array contains one object per requested user name.
Parameters
userNames:
string[]
Array of Voximplant user identifiers, e.g., 'username@appname.accname'
Returns
type:
Promise<UserEventPayload[]>
Throws
getUsersByImIds
getUsersByImIds(imIds: number[]
): Promise<UserEventPayload[]>
Obtains information about the users specified by the list of IM user IDs. Maximum of 50 users.
You can request users linked to the main Voximplant developer account or its child accounts.
Returns a promise that resolves to an array of UserEventPayload objects if the operation succeeds. The array contains one object per requested user ID.
Parameters
imIds:
number[]
Array of IM user IDs
Returns
type:
Promise<UserEventPayload[]>
Throws
joinConversation
joinConversation(uuid: string
): Promise<ConversationEventPayload>
Joins the current user to a conversation specified by its UUID.
This operation is possible only if:
- The conversation has been created by a user of the main Voximplant developer account or its child accounts.
- Public join is enabled (Conversation.isPublicJoin is true).
- The conversation is not a direct conversation (Conversation.isDirect is false).
Other participants in the conversation (online participants and logged-in clients) can be informed about the join via the MessengerEventType.onEditConversation event.
Returns a promise that resolves to a ConversationEventPayload object.
Parameters
uuid:
string
Conversation UUID
Returns
type:
Promise<ConversationEventPayload>
Throws
leaveConversation
leaveConversation(uuid: string
): Promise<ConversationEventPayload>
Makes the current user leave a conversation specified by its UUID.
This operation is possible only if the conversation is not a direct conversation (Conversation.isDirect is false).
After a successful call, the conversation's UUID is added to User.leaveConversationList.
Returns a promise that resolves to a ConversationEventPayload object.
Parameters
uuid:
string
Conversation UUID
Returns
type:
Promise<ConversationEventPayload>
Throws
removeEventListener
removeEventListener(eventName: , listener: (event: AnyMessengerEvent) => void | Promise<void>
): void
Parameters
eventName:
listener:
(event: AnyMessengerEvent) => void | Promise<void>
Returns
type:
void
setStatus
setStatus(online: boolean
): Promise<StatusEventPayload>
Sets the current user status.
You can use the MessengerEventType.onSetStatus event to notify clients and users subscribed to the current user of the status change for that user.
Returns a promise that resolves to a StatusEventPayload object.
Parameters
online:
boolean
Indicates whether the user is online and available for messaging
Returns
type:
Promise<StatusEventPayload>
Throws
subscribe
subscribe(imIds: number[]
): Promise<SubscriptionEventPayload>
Subscribes to information and status changes of the specified users.
You can subscribe the user to any user linked to the main Voximplant developer account or its child accounts.
Other logged-in clients of the current user can be informed about the subscription via the MessengerEventType.onSubscribe event.
You can use the MessengerEventType.onSubscribe event to notify other logged-in clients of the current user of the subscription.
The users specified in the
imIds
parameter are not notified of the subscription.
Returns a promise that resolves to a SubscriptionEventPayload object.
Parameters
imIds:
number[]
Array of IM user IDs
Returns
type:
Promise<SubscriptionEventPayload>
Throws
unsubscribe
unsubscribe(imIds: number[]
): Promise<SubscriptionEventPayload>
Cancels subscription to information and status changes of the specified users.
You can use the MessengerEventType.onUnsubscribe event to notify other logged-in clients of the current user that their subscription has been cancelled.
The users specified in the
imIds
parameter are not notified of the subscription cancellation.
Returns a promise that resolves to a SubscriptionEventPayload object.
Parameters
imIds:
number[]
Array of IM user IDs
Returns
type:
Promise<SubscriptionEventPayload>
Throws
unsubscribeFromAll
unsubscribeFromAll(): Promise<SubscriptionEventPayload>
Cancels all subscriptions to information and status changes.
You can use the MessengerEventType.onUnsubscribe event to notify other logged-in clients of the current user that their subscription has been cancelled.
Other users are not notified of the subscription cancellation.
Returns a promise that resolves to a SubscriptionEventPayload object.
Returns
type:
Promise<SubscriptionEventPayload>