Connection

Learn how to build scalable customer engagement applications using the Elarian Framework.

To establish a connection to Elarian, you need an orgId appId and apiKey. You can get an orgId from any of the organizations you have listed on your dashboard. Once you get an orgId, generate an apiKey for the respective org on the Api Keys section. Lastly for the appId, you get to define a value when creating channels, it can be any string value, as long as it exists on a channel.

import { Elarian } from 'elarian';

const client = new Elarian({
  apiKey: 'YOUR-API-KEY',
  orgId: 'YOUR-ORG-ID',
  appId: 'YOUR-APP-ID',
});

client
  .on('connected', () => {
    console.log('Elarian is running!');
    // Client ready for use
  })
  .on('error', (error) => {
    console.error(error);
    // Connection error
  })
  .connect();

Once you authenticate, you can initiate engagements as well as handle incoming engagement events.

...

const resp = await client.sendMessage(...);

client.on('receivedWhatsapp', (notification, customer, appData, callback) => { ... });