Handling your first event

Elarian encourages a reactive programming model, your application emits events to Elarian in the form of commands, and your application reacts to events from Elarian in the form of notifications. Let's set up your first event handler.

const client = new Elarian({
    orgId: 'your-org-id',
    appId: 'your-app-id',
    apiKey: 'your-api-key'
async function onConnected() {
  console.log('App is running!');

  const alice = new client.Customer({
    number: '+254712345678',
    provider: 'cellular'

  await alice.addReminder({
    key: 'loaner',
    payload: 'USD 100',
    remindAt: (Date.now() + 60000) / 1000, // Remind 1m from now

async function onReminder(notification, customer) {
  console.log(`Received reminder notification -> ${notification}`);

    .on('error', (err) => console.error(`Connnection error: ${err}`))
    .on('connected', onConnected)
    .on('reminder', onReminder)

The code above handles reminder events. Elarian provides the ability to schedule reminders that will fire in the future. When the reminder event fires, the set handler will receive the event payload and a programmable customer object belonging to the customer you scheduled the reminder on. There are many other events your application can react to, and you can find the complete list in the Events Reference.