SIGN UP

Messenger

Messenger class used to control messaging functions.

Methods

createConversation

createConversation(conversationConfig: ConversationConfig): Promise<ConversationEvent|ErrorEvent>

Create a new conversation with the extended configuration.

Other parties of the conversation (online participants and logged in clients) can be informed about the conversation creation via the MessengerEventTypes.CreateConversation.

Parameters

  • conversationConfig:

    ConversationConfig
    OPTIONAL

    ConversationConfig instance with extended conversation parameters

Returns

editUser

editUser(customData: object, privateCustomData: object): Promise<UserEvent|ErrorEvent>

Edit current user information.

Other users that are subscribed to the user can be informed about the editing via the MessengerEventTypes.EditUser event.

Parameters

  • customData:

    object

    New custom data. If null, previously set custom data will not be changed. If empty object, previously set custom data will be removed.

  • privateCustomData:

    object

    New private custom data. If null, previously set private custom data will not be changed. If empty object, previously set private custom data will be removed.

Returns

getConversation

getConversation(uuid: string): Promise<ConversationEvent|ErrorEvent>

Get a conversation by its UUID.

It's possible if:

  • the user that calls the method is/was a participant of this conversation
  • the conversation is an available public conversation (see Messenger.getPublicConversations)

Only the client that called the method can be informed about getting conversation.

Parameters

  • uuid:

    string

    Conversation UUID

Returns

getConversations

getConversations(uuids: Array<string>): Promise<Array<ConversationEvent>|ErrorEvent>

Get the multiple conversations by the list of UUIDs. Maximum 30 conversations.

It's possible if:

  • the user that calls the method is/was a participant of this conversation
  • the conversation is an available public conversation (see Messenger.getPublicConversations)

Only the client that called the method can be informed about getting conversations.

Parameters

  • uuids:

    Array<string>

    Array of UUIDs. Maximum 30 conversations.

Returns

getMe

getMe(): string

Get the full Voximplant user identifier, for example 'username@appname.accname', for the current user

Returns

  • Return:

    string

getPublicConversations

getPublicConversations(): Promise<ConversationListEvent|ErrorEvent>

Get all public conversations (Conversation.publicJoin is true).

It's possible to get all public conversations (UUIDs) that were created by:

  • the current user
  • other users of the same child account
  • users of the main Voximplant developer account

Only the client that called the method can be informed about getting public conversations UUIDs.

Returns

getSubscriptions

getSubscriptions(): Promise<SubscriptionEvent|ErrorEvent>

Get all current subscriptions, i.e., the array of users the current user is subscribed to.

Only the client that called the method can be informed about getting subscriptions.

Returns

getUserByIMId

getUserByIMId(userId: number): Promise<UserEvent|ErrorEvent>

Get information for the user specified by the IM user id.

It's possible to get any user of the main Voximplant developer account or its child accounts.

Only the client that called the method can be informed about getting user information.

Parameters

  • userId:

    number

    IM User id

Returns

getUserByName

getUserByName(username: string): Promise<UserEvent|ErrorEvent>

Get information for the user specified by the Voximplant user name, e.g., 'username@appname.accname'.

It's possible to get any user of the main Voximplant developer account or its child accounts.

Only the client that called the method can be informed about getting user information.

Parameters

  • username:

    string

    Voximplant user identifier

Returns

getUsersByIMId

getUsersByIMId(users: Array<number>): Promise<Array<UserEvent>|ErrorEvent>

Get information for the users specified by the array of the IM user ids. Maximum 50 users.

It's possible to get any users of the main Voximplant developer account or its child accounts.

Only the client that called the method can be informed about getting users information.

Parameters

  • users:

    Array<number>

    Array of IM user ids

Returns

getUsersByName

getUsersByName(users: Array<string>): Promise<Array<UserEvent>|ErrorEvent>

Get information for the users specified by the array of the Voximplant user names. Maximum 50 users.

It's possible to get any users of the main Voximplant developer account or its child accounts.

Only the client that called the method can be informed about getting users information.

Parameters

  • users:

    Array<string>

    Array of Voximplant user identifiers

Returns

joinConversation

joinConversation(uuid: string): Promise<ConversationListEvent|ErrorEvent>

Join the current user to any conversation specified by the UUID.

It's possible only on the following conditions:

  • a conversation is created by a user of the main Voximplant developer account or its child accounts
  • public join is enabled (Conversation.publicJoin is true)
  • the conversation is not a direct one (Conversation.direct is false)

Other parties of the conversation (online participants and logged in clients) can be informed about joining to the conversation via the MessengerEventTypes.EditConversation event.

Parameters

  • uuid:

    string

    Conversation UUID

Returns

leaveConversation

leaveConversation(uuid: string): Promise<ConversationListEvent|ErrorEvent>

Make the current user leave a conversation specified by the UUID.

It's possible only if the conversation is not a direct one (Conversation.direct is false).

After a successful method call the conversation's UUID will be added to User.leaveConversationList.

Other parties of the conversation (online participants and logged in clients) can be informed about leaving the conversation via the MessengerEventTypes.EditConversation event.

Parameters

  • uuid:

    string

    Conversation UUID

Returns

managePushNotifications

managePushNotifications(notifications: Array<MessengerNotification>): Promise<UserEvent|ErrorEvent>

Manage messenger push notification subscriptions for the current user.

Other logged in clients (of the current user) can be informed about managing push notifications via MessengerEventTypes.EditUser

Parameters

Returns

off

off(eventType: MessengerEventTypes, event: function): void

Remove handler for specified event

Parameters

  • event:

    function

    Handler function. If not specified, all handlers for the event type will be removed.

on

on(eventType: MessengerEventTypes, event: function): void

Register handler for specified messenger event. Use Messenger.off method to delete a handler.

Parameters

setStatus

setStatus(online: boolean): Promise<StatusEvent|ErrorEvent>

Set the current user status.

Other users (that are subscribed to the user) and other clients (of the current user) can be informed about the status changing via the MessengerEventTypes.SetStatus event.

Parameters

  • online:

    boolean

    True if user is available for messaging, false otherwise

Returns

subscribe

subscribe(users: Array<number>): Promise<SubscriptionEvent|ErrorEvent>

Subscribe for other user(s) information and status changes.

It's possible to subscribe for any user of 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 MessengerEventTypes.Subscribe event.

User(s) specified in the 'users' parameter aren't informed about the subscription.

Parameters

  • users:

    Array<number>

    Array of IM user ids

Returns

unsubscribe

unsubscribe(users: Array<number>): Promise<SubscriptionEvent|ErrorEvent>

Unsubscribe from other user(s) information and status changes.

Other logged in clients (of the current user) can be informed about the unsubscription via the MessengerEventTypes.Unsubscribe event.

User(s) specified in the 'users' parameter aren't informed about the unsubscription.

Parameters

  • users:

    Array<number>

    Array of IM user ids

Returns

unsubscribeFromAll

unsubscribeFromAll(): Promise<SubscriptionEvent|ErrorEvent>

Unsubscribe from all subscriptions.

Other logged in clients (of the current user) can be informed about the unsubscription via the MessengerEventTypes.Unsubscribe event.

Other users aren't informed about the unsubscription.

Returns