Rate this page:

Messenger

Interface that provides API to control messaging functions.

Methods

addEventListener

Copy URL
addEventListener(eventName: 

MessengerEventType

,
listener:

(event: AnyMessengerEvent) => void | Promise<void>

,
options:

ListenerOptions

):

void

Parameters

Returns

  • type:

    void

createConversation

Copy URL
createConversation(conversationConfig: 

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

Returns

editUser

Copy URL
editUser(options: 

EditUserOptions

):

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

Returns

getConversation

Copy URL
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

getConversations

Copy URL
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

getMe

Copy URL
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

Copy URL
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

getSubscriptionList

Copy URL
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

getUser

Copy URL
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

getUserByImId

Copy URL
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

getUsers

Copy URL
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

getUsersByImIds

Copy URL
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

joinConversation

Copy URL
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

leaveConversation

Copy URL
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

removeEventListener

Copy URL
removeEventListener(eventName: 

MessengerEventType

,
listener:

(event: AnyMessengerEvent) => void | Promise<void>

):

void

Parameters

Returns

  • type:

    void

setStatus

Copy URL
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

subscribe

Copy URL
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

unsubscribe

Copy URL
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

unsubscribeFromAll

Copy URL
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