SIGN UP

Messaging

Messaging allows exchanging instant messages between 2 or more participants. Messaging supports text and metadata. The conversation doesn't bind or depend on the audio/video calls, but there is a possibility to integrate messaging in audio/video calls. FEATURES:

  • 1. messaging is the separate part of WEB SDK but it uses [Client.login*] methods - in brief, if a user was already logged in he can use messaging functionality.
  • 2. messaging doesn't use backend JS scenario at all

See the minimum example to create messaging and to be able start a conversation:

Example

const voxSDK = VoxImplant.getInstance();
voxSDK.init({micRequired:false})
  .then(()=>voxSDK.connect())
  .then(()=>sdk.login('foo@bar.baz.voximplant.com', 'secretpass'))
  .then((e)=>{
    if(!e.result)
      throw e.message;
    console.log('[Voximplant] Ready, connected and logged in.');
    return VoxImplant.getMessenger();
  })
  .then((messaging)=>{
    messaging.on(VoxImplant.Messaging.MessengerEvents.CreateConversation,onCreateConversation);
    messaging.createConversation([]);
  })
  .catch(e=>console.error('[Voximplant] Oops! Something went wrong',e));

function onCreateConversation(e){
  console.log(`[Voximplant] New conversation here! ID:${e.conversation.uuid}`);
  e.conversation.sendMessage('Hello world!');
}

function onSendMessage(e){
  console.log(`[Voximplant] Message from ${e.message.sender}: ${e.message.text}`)
}
  • MessengerEventsCallbacks

    Messaging supports these events. See the details within a particular event.

  • Conversation
    Conversation instance. Created by Messenger.createConversation(). Used to send messages, add or remove users, change moderators list etc.
  • Message
    Describes single message. Received via the 'onSendMessage' or 'onEditMessage' events and used to serialize or edit the message.
  • Messenger
    Messenger class used to control messaging functions. Can't be instantiated directly (singleton), please use [getMessenger] to get the class instance.
  • ConversationParticipant
    User description for the conversation
  • RetransmittedEvent
  • SerializedConversation
    Serialized conversation information that can be stored into some storage (like IndexedDB) and later restored via [Messenger.createConversationFromCache]
  • SerializedMessage
    Serialized message information that can be stored into some storage (like IndexedDB) and later restored via [Messenger.createMessageFromCache]
  • User
    User description returned by the 'getUser' method.
  • UserStatus
    User status information available in the 'onSetStatus' event.
  • MessengerAction
    Available methods to manipulate the messaging flow. Note if the action triggers any of [ConversationEvent.events], the action's name will be set as a value of
  • MessengerError
  • MessengerEvents