Let's integrate our SDK in few minutes

Quick Start#
Download SDK Files

Chat SDKs for Web#

CONTUS MirrorFly Chat SDK with its robust features and functionalities makes the integration more efficient and easy for every client’s app.

On client-side implementation, our chat SDK allows you to initialize and configure the chat easily. On server-side implementation, we ensure the most reliable infra-management services for the chat within the app.

This guided documentation here demonstrates the process as how to install the chat SDK in your app so that you can send and receive the messages without any interruption within a few simple steps.


CONTUS MirrorFly Chat SDKs use the fastest way in action, to experience the same you must use our trial app to enhance your existing chat app. So just download our sample app and make a start with your app development. Click here to download the sample app.

Supported browsers#

BrowserSupported versions
Edge13 or higher
Chrome16 or higher
Firefox11 or higher
Safari7 or higher

Make a note of Below Points Before Making a Start#

PART I - SDK License Key#

Before moving forward with CONTUS MirrorFly Chat SDK integration, it is necessary for an SDK to be authenticated by the MirrorFly server using the license key for further processing.

The below given is the process that needs to be followed to obtain a license key:

Step 1: Get started - Signup into MirrorFly Console page (https://console.mirrorfly.com/register) and create a free MirrorFly account

Step 2: While creating an account you can provide your basic details that includes your name, organization details, work email, and contact number

Step 3: Once you’re in! You get access to your MirrorFly account ‘Overview page’ where you can find a license key ,Api base Url as well as downloadable JavaScript SDK files.


PART II - Integrate Chat SDK into Your Web App#

CONTUS MirrorFly Chat for JavaScript, makes the in-app chat development process easy with all the essential messaging features

Since it’s the core of all the languages - Importing JavaScript into the application is the fundamental step to proceed further before using any language.

Step 1: Include script file into your index.html

<script src="./index.js"></script>
<script src="./socket.io.js"></script>

Step 2: Create a new file SDK.js in the project root and paste the below code,

const SDK = window.SDK;
export default SDK;

Step 3: Import the SDK into your application

import SDK from "./SDK";

PART III - Terminology#

The below are the common keywords/terminologies used in SDKs with their descriptions

userIdUnique ID assigned for each user Ex: 12345678 (any alphanumeric). The below characters is not allowed in userId: U+0022 (") U+0026 (&) U+0027 (') U+002F (/) U+003A (:) U+003C (<) U+003E (>) U+0040 (@) userID should follow below specification: https://xmpp.org/extensions/xep-0106.html
userJiduserID+@+domain of the chat server Ex. 12345678@xmpp.chatsystem.dev.contus.us
groupJidUnique ID assigned for each group Ex: group123456 (any alphanumeric). GroupJID = groupID +@mix.+domain of the chat server Ex: group123456@mix.xmpp.mirrorfly.dev.contus.us`

Initialize Chat SDK#

To begin with the initialization process of the chat SDK you are required to have certain data that responds to the changes in the connection status in the client's app.

Now, paste the license key on the licensekey param and use the below given method to pass these data through the SDK for further processing.


You can find the sandbox server details in the further Sandbox section for testing purposes.

const initializeObj = {
apiBaseUrl: `API_URL`,
licenseKey: `LICENSE_KEY`,
isTrialLicenseKey: `TRIAL_MODE`,
callbackListeners: {},
await SDK.initializeSDK(initializeObj);

Request Params#

apiBaseUrlAPI Base URL for BackendStringtrue
licenseKeyMirrorfly's License KeyStringtrue
isTrialLicenseKeyif true Trial Mode will be EnabledBooleanfalse
callbackListenersCheck here for callback listernersObjecttrue

Response Params#

statusCodeStatus CodeNumber
messageSuccess/Error MessageString

Sandbox Details#

The apiUrl and licenseKey details can get it from the 'Overview' section in the mirrorfly Console dashboard.


function connectionListener(response) {
if (response.status === "CONNECTED") {
console.log("Connection Established");
} else if (response.status === "DISCONNECTED") {
const initializeObj = {
apiBaseUrl: "https://api-preprod-sandbox.mirrorfly.com/api/v1",
isTrialLicenseKey: true,
callbackListeners: {
await SDK.initializeSDK(initializeObj);

To learn more about callback listeners, go to the Callback Event Listener Section.

Example Response#

"statusCode": 200,
"message": "Success"

PART IV - Create a User#

Register User#

Step 1: You can use the below given method to register a new user.

Step 2: Once you are registered, you will be provided with a username and password that you can utilize to make the connection with the server via connect method.

await SDK.register(`USER_IDENTIFIER`);

Request Params#

USER_IDENTIFIERUnique Id to Register the UserStringtrue

Response Params#

statusCodeStatus CodeNumber
messageSuccess/Error MessageString
dataUsername and PasswordObject

Sample Response:#

statusCode: 200,
message: "Success",
data: {
username: "123456789",
password: "987654321"

username is the unique id that allows you to connect with other users to send or receive messages.

Connect to MirrorFly Server#

Step 1: You can use the credentials that you have obtained while registration to make the connection with the server.

Step 2: Once you have created the connection successfully, you will be responded with an approval message as ‘statusCode of 200’ or else will get an execution error.

Step 3: With this you can also trace the connection status that you receive in connectionListener callback function.

Step 4: If you face any error while making a connection with the server, you will receive an error message with callback.

await SDK.connect(`USERNAME`, `PASSWORD`);

Request Params#


Response Params#

statusCodeStatus CodeNumber
messageSuccess/Error MessageString

To learn more about all possible logins and profile related setup, go to Profile Section.

PART V - Send a Message#

Finally, to send a message to another user you can use the below given method,


You can use the const userJid = SDK.getJid(USER_ID) method, to generate a JID for any user.

await SDK.sendTextMessage(`TO_USER_JID`, `MESSAGE_BODY`);

Request Param#

TO_USER_JIDJID of the To User. username + "@" + xmppSocketHostJID Stringtrue
MESSAGE_BODYText Message BodyStringtrue

Response Params#

statusCodeStatus CodeNumber
messageSuccess/Error MessageString

PART VI - Receive a Message#

To receive a message from another user you must implement the messageListener function. It’s a function that will be triggered whenever you receive a new message or related event in one-to-one or group chat. Further to initialize the SDK, you need to add the below callback method during the process.

function messageListener(response) {
console.log("Message Listener", response);

To learn more on 'message listener callbacks,' see the Message Callback Event Listener Section