SIGN UP

Messaging

Messaging module allows to exchange instant messages between two or more participants. Messaging supports text and metadata. The conversation doesn't bind or depend on audio/video calls though there is a possibility to integrate messaging in audio/video calls. FEATURES:

  1. Messaging is the separate part of WEB SDK but it uses the Client.login, Client.loginWithOneTimeKey and Client.loginWithToken methods. In brief, if a user has already been logged in, he can use Messaging functionality.
  2. Messaging doesn't use backend JS scenarios at all.

Here is the minimum example of creating a Messenger instance and starting a conversation:

Example

const voxSDK = VoxImplant.getInstance();
const Messaging = VoxImplant.Messaging;

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 Messaging.getInstance();
  })
  .then((messenger) => {
    messenger.on(Messaging.MessengerEvents.CreateConversation, onCreateConversation);
    messenger.on(Messaging.MessengerEvents.SendMessage, onSendMessage);
    messenger.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.logger(`[Voximplant] Message from ${e.message.sender}: ${e.message.text}`)
}

getInstance

Parameters

Returns