Skip to content

ShoppReDigital/node-omniengage

Repository files navigation

OmniEngage

Javascript Client SDK for OmniEngage Server

Getting Started

You need to install OmniEngage and set API credentials before you get started

If you not installed yet, you can install using below options

  1. DigitalOcean One Click Installation
  2. Installing by your own

Installation

npm i @shoppredigital/omniengage -S

Usage

for building emails for developers in command line

{
 "scripts": {
    "event:fire": "OMNIENGAGE_URL=https://engage.yourdomain.com ./node_modules/.bin/omniengage events",
    "email-build": "OMNIENGAGE_URL=https://engage.yourdomain.com ./node_modules/.bin/omniengage build",
    "email-update-send": "OMNIENGAGE_URL=https://engage.yourdomain.com ./node_modules/.bin/omniengage update-send",
    "email-deploy": "OMNIENGAGE_URL=https://engage.yourdomain.com DEBUG=q-* ./node_modules/.bin/omniengage deploy"
  }
}

for sending emails from nodejs

if (!process.env.OMNIENGAGE_URL) {
  process.env.OMNIENGAGE_URL = 'https://engage.yourdomain.com';
}

const { ses } = require('@shoppredigital/omniengage');
const { FROM_EMAIL = '[email protected]' } = process.env;
const customer = {
  email: '[email protected]',
};

ses.sendTemplatedEmail({
    Source: `"OmniEngage" <${FROM_EMAIL}>`,
    Destination: {
      ToAddresses: [customer.email],
    },
    Template: 'user_signup',
    TemplateData: JSON.stringify({
      customer,
    }),
  })
const { comment, user } = require('@shoppredigital/omniengage');
// Register a user 
user.signup({
      id: userId,
      first_name: 'Vikas',
      last_name: 'Kumar',
      email: '[email protected]',
    });

// Sending Chat Message from Server
comment.create({
      object_id: 1,
      user_id: userId,
      state_id: 1,
      comments: 'Lead Completed',
    }, 'leads')