2.1.0 • Published 2 years ago

subscribejs v2.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

SubscribeJs

Subscriptions management built in Node.js using PostgreSQL. Subscribe contacts to predefined campaigns with actions thats triggered by developer defined logic causing an action to occur e.g. sending an email to the contact after a period of time.

Requirements

  • Node 12 or higher
  • PostgreSQL 9.5 or higher

Installation

npm install subscribejs

Initialize

const SubscribeJS = require('subscribejs')

const sub = new SubscribeJS({
  pgDbUrl: process.env.DB_URL, 
  interval: 60 * 1000 * 60, 
  findContact: (contactId) => ..., //callback returning contact by its id
  email: { 
    host: '...',
    user: '...',
    pass: '...',
    port: '...',
    fromEmail: 'jd@gmail.com',
    fromName: 'John Doe',
  },
  //campaigns and actions
  campaigns: [ 
    {
      id: 'my-campaign',
      active: true,
      actions: [
        {
          id: 'my-campaign-action-1',
          should: (options) => true,  //true will trigger the callback
          callback: (options) => sub.sendEmail({ to: options.contact.email, subject: 'Hello', html: `Hello ${options.contact.name}` }),
        },
        {
          id: 'my-campaign-action-2',
          should: (options) => sub.triggerEveryDays(90),
          callback: (options) => sub.sendEmail({ to: options.contact.email, subject: 'Hello', html: `Hello ${options.contact.name}` }),
        },
      ]
    }
})

Subscribe contact

sub.subscribe('my-campaign', [432,543]) //subscribe two contacts by their ids to 'my-campaign'
2.1.0

2 years ago

1.1.0

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago