MCPcopy
hub / github.com/notifme/notifme-sdk

github.com/notifme/notifme-sdk @v1.16.25 sqlite

repository ↗ · DeepWiki ↗ · release v1.16.25 ↗
343 symbols 880 edges 169 files 0 documented · 0%
README

Notif.me

A Node.js library to send all kinds of transactional notifications.

npm-status license slack

Features

  • Easy channel integration — Want to start sending emails | SMS | pushes | webpushes | slack? Do so in no time!

  • Unique documentation — Don't look everywhere for the parameters you need to pass, just do it once. Switching provider becomes a no-brainer.

  • Multiple providers strategies — Want to use more than one provider? Use fallback and round-robin strategies out of the box.

  • Tools for local testing — Run a catcher locally to intercept all your notifications and display them in a web interface.

  • MIT license — Use it like you want.

Getting Started

$ yarn add notifme-sdk
import NotifmeSdk from 'notifme-sdk'

const notifmeSdk = new NotifmeSdk({}) // empty config = all providers are set to console.log
notifmeSdk
  .send({sms: {from: '+15000000000', to: '+15000000001', text: 'Hello, how are you?'}})
  .then(console.log)

:sparkles: Congratulations, you should see the following lines in your console:

Getting started SMS log

[Recommended] Setup Notification Catcher for your local tests

Notification Catcher is a web interface for viewing and testing notifications during development.

$ yarn add --dev notification-catcher
$ yarn run notification-catcher
import NotifmeSdk from 'notifme-sdk'

const notifmeSdk = new NotifmeSdk({
  useNotificationCatcher: true // <= this sends all your notifications to the catcher running on port 1025
})
notifmeSdk
  .send({sms: {from: '+15000000000', to: '+15000000001', text: 'Hello, how are you?'}})
  .then(console.log)

:heart_eyes_cat: Open http://localhost:1080 on your favorite browser, you should see the notification:

Getting started SMS catcher

Custom connection settings

If you have the Notification Catcher running on a custom port, domain, or you need to change any other connection setting, set the environment variable NOTIFME_CATCHER_OPTIONS with your custom connection smtp url.

$ # Example
$ NOTIFME_CATCHER_OPTIONS=smtp://127.0.0.1:3025?ignoreTLS=true node your-script-using-notifme.js

How to use

1. General options

new NotifmeSdk({
  channels: ..., // Object
  useNotificationCatcher: ... // boolean
})
Option name Required Type Description
channels false Object Define providers (Array) and multiProviderStrategy (string) for each channel (email, sms, push, webpush, slack).

See all details below: 2. Providers. | | useNotificationCatcher | false | boolean | If true, all your notifications are sent to the catcher running on localhost:1025 (channels option will be completely ignored!) |

Complete examples

// Env: development
new NotifmeSdk({
  useNotificationCatcher: true
})

// Env: production
new NotifmeSdk({
  channels: {
    email: {
      // If "Provider1" fails, use "Provider2"
      multiProviderStrategy: 'fallback',
      providers: [{
        type: 'Provider1',
        // ...credentials
      }, {
        type: 'Provider2',
        // ...credentials
      }]
    },
    sms: {
      // Use "Provider1" and "Provider2" in turns (and fallback if error)
      multiProviderStrategy: 'roundrobin',
      providers: [{
        type: 'Provider1',
        // ...credentials
      }, {
        type: 'Provider2',
        // ...credentials
      }]
    }
  }
})

HTTP proxy option

If you want to use a HTTP proxy, set an environment variable NOTIFME_HTTP_PROXY.

$ # Example
$ NOTIFME_HTTP_PROXY=http://127.0.0.1:8580 node your-script-using-notifme.js

2. Providers

Email providers

Logger (for development)

new NotifmeSdk({
  channels: {
    email: {
      providers: [{
        type: 'logger'
      }]
    }
  }
})

SMTP (can be used for almost all providers)

new NotifmeSdk({
  channels: {
    email: {
      providers: [{
        type: 'smtp',
        host: 'smtp.example.com',
        port: 465,
        secure: true,
        auth: {
          user: 'xxxxx',
          pass: 'xxxxx'
        }
      }]
    }
  }
})

Sendmail

new NotifmeSdk({
  channels: {
    email: {
      providers: [{
        type: 'sendmail',
        sendmail: true,
        newline: 'unix',
        path: '/usr/sbin/sendmail'
      }]
    }
  }
})

Mailgun

new NotifmeSdk({
  channels: {
    email: {
      providers: [{
        type: 'mailgun',
        apiKey: 'xxxxx',
        domainName: 'example.com'
      }]
    }
  }
})

Mandrill

new NotifmeSdk({
  channels: {
    email: {
      providers: [{
        type: 'mandrill',
        apiKey: 'xxxxx'
      }]
    }
  }
})

Sendgrid

new NotifmeSdk({
  channels: {
    email: {
      providers: [{
        type: 'sendgrid',
        apiKey: 'xxxxx'
      }]
    }
  }
})

SES

new NotifmeSdk({
  channels: {
    email: {
      providers: [{
        type: 'ses',
        region: 'xxxxx',
        accessKeyId: 'xxxxx',
        secretAccessKey: 'xxxxx',
        sessionToken: 'xxxxx' // optional
      }]
    }
  }
})

SparkPost

new NotifmeSdk({
  channels: {
    email: {
      providers: [{
        type: 'sparkpost',
        apiKey: 'xxxxx'
      }]
    }
  }
})

Custom (define your own)

new NotifmeSdk({
  channels: {
    email: {
      providers: [{
        type: 'custom',
        id: 'my-custom-email-provider...',
        send: async (request) => {
          // Send email
          return 'id...'
        }
      }]
    }
  }
})

request being of the following type.

See all options: Email provider options

SMS providers

Logger (for development)

new NotifmeSdk({
  channels: {
    sms: {
      providers: [{
        type: 'logger'
      }]
    }
  }
})

46elks

new NotifmeSdk({
  channels: {
    sms: {
      providers: [{
        type: '46elks',
        apiUsername: 'xxxxx',
        apiPassword: 'xxxxx'
      }]
    }
  }
})

Callr

new NotifmeSdk({
  channels: {
    sms: {
      providers: [{
        type: 'callr',
        login: 'xxxxx',
        password: 'xxxxx'
      }]
    }
  }
})

Clickatell

new NotifmeSdk({
  channels: {
    sms: {
      providers: [{
        type: 'clickatell',
        apiKey: 'xxxxx' // One-way integration API key
      }]
    }
  }
})

Infobip

new NotifmeSdk({
  channels: {
    sms: {
      providers: [{
        type: 'infobip',
        username: 'xxxxx',
        password: 'xxxxx'
      }]
    }
  }
})

Nexmo

new NotifmeSdk({
  channels: {
    sms: {
      providers: [{
        type: 'nexmo',
        apiKey: 'xxxxx',
        apiSecret: 'xxxxx'
      }]
    }
  }
})

OVH

new NotifmeSdk({
  channels: {
    sms: {
      providers: [{
        type: 'ovh',
        appKey: 'xxxxx',
        appSecret: 'xxxxx',
        consumerKey: 'xxxxx',
        account: 'xxxxx',
        host: 'xxxxx' // https://github.com/ovh/node-ovh/blob/master/lib/endpoints.js
      }]
    }
  }
})

Plivo

new NotifmeSdk({
  channels: {
    sms: {
      providers: [{
        type: 'plivo',
        authId: 'xxxxx',
        authToken: 'xxxxx'
      }]
    }
  }
})

Twilio

new NotifmeSdk({
  channels: {
    sms: {
      providers: [{
        type: 'twilio',
        accountSid: 'xxxxx',
        authToken: 'xxxxx'
      }]
    }
  }
})

Seven

new NotifmeSdk({
  channels: {
    sms: {
      providers: [{
        type: 'seven',
        apiKey: 'xxxxx'
      }]
    }
  }
})

Custom (define your own)

new NotifmeSdk({
  channels: {
    sms: {
      providers: [{
        type: 'custom',
        id: 'my-custom-sms-provider...',
        send: async (request) => {
          // Send SMS
          return 'id...'
        }
      }]
    }
  }
})

request being of the following type.

See all options: SMS provider options

Voice providers

Logger (for development)

new NotifmeSdk({
  channels: {
    voice: {
      providers: [{
        type: 'logger'
      }]
    }
  }
})

Twilio

new NotifmeSdk({
  channels: {
    voice: {
      providers: [{
        type: 'twilio',
        accountSid: 'xxxxx',
        authToken: 'xxxxx'
      }]
    }
  }
})

Custom (define your own)

new NotifmeSdk({
  channels: {
    voice: {
      providers: [{
        type: 'custom',
        id: 'my-custom-voice-provider...',
        send: async (request) => {
          // Send Voice
          return 'id...'
        }
      }]
    }
  }
})

request being of the following type.

See all options: Voice provider options

Push providers

Logger (for development)

new NotifmeSdk({
  channels: {
    push: {
      providers: [{
        type: 'logger'
      }]
    }
  }
})

APN (Apple Push Notification)

new NotifmeSdk({
  channels: {
    push: {
      providers: [{
        type: 'apn',
        token: {
          key: './certs/key.p8',
          keyId: 'xxxxx',
          teamId: 'xxxxx'
        }
      }]
    }
  }
})

FCM (Firebase Cloud Messaging, previously called GCM, Google Cloud Messaging)

new NotifmeSdk({
  channels: {
    push: {
      providers: [{
        type: 'fcm',
        id: 'xxxxx'
      }]
    }
  }
})

WNS (Windows Push Notification)

new NotifmeSdk({
  channels: {
    push: {
      providers: [{
        type: 'wns',
        clientId: 'xxxxx',
        clientSecret: 'xxxxx',
        notificationMethod: 'sendTileSquareBlock'
      }]
    }
  }
})

ADM (Amazon Device Messaging)

new NotifmeSdk({
  channels: {
    push: {
      providers: [{
        type: 'adm',
        clientId: 'xxxxx',
        clientSecret: 'xxxxx'
      }]
    }
  }
})

Custom (define your own)

new NotifmeSdk({
  channels: {
    push: {
      providers: [{
        type: 'custom',
        id: 'my-custom-push-provider...',
        send: async (request) => {
          // Send push
          return 'id...'
        }
      }]
    }
  }
})

request being of [the following typ

Extension points exported contracts — how you extend this code

SenderType (Interface)
(no doc) [35 implementers]
src/sender.js
ProviderType (Interface)
(no doc) [34 implementers]
src/providers/index.js
WebpushProviderType (Interface)
(no doc) [34 implementers]
src/providers/webpush/index.js
EmailProviderType (Interface)
(no doc) [34 implementers]
src/providers/email/index.js
PushProviderType (Interface)
(no doc) [34 implementers]
src/providers/push/index.js
WhatsappProviderType (Interface)
(no doc) [34 implementers]
src/providers/whatsapp/index.js

Core symbols most depended-on inside this repo

send
called by 121
src/sender.js
sendToCatcher
called by 14
src/providers/notificationCatcherProvider.js
_objectSpread
called by 11
lib/index.js
_objectSpread
called by 8
lib/sender.js
log
called by 8
src/util/logger.js
mergeWithDefaultConfig
called by 6
src/index.js
hmac
called by 6
src/util/crypto.js
warn
called by 6
src/util/logger.js

Shape

Function 157
Method 101
Class 76
Interface 9

Languages

TypeScript100%

Modules by API surface

src/util/aws/v4.js18 symbols
src/util/logger.js9 symbols
src/sender.js7 symbols
lib/providers/whatsapp/notificationCatcher.js6 symbols
lib/providers/webpush/notificationCatcher.js6 symbols
lib/providers/push/notificationCatcher.js6 symbols
src/providers/sms/ovh.js5 symbols
src/providers/notificationCatcherProvider.js5 symbols
src/providers/email/ses.js5 symbols
src/index.js5 symbols
lib/sender.js5 symbols
src/providers/whatsapp/infobip.js4 symbols

Dependencies from manifests, versioned

@babel/cli7.0.0 · 1×
@babel/core7.0.0 · 1×
@babel/node7.0.0 · 1×
@babel/plugin-proposal-class-properties7.0.0 · 1×
@babel/plugin-proposal-decorators7.0.0 · 1×
@babel/plugin-proposal-export-namespace-from7.0.0 · 1×
@babel/plugin-proposal-function-sent7.0.0 · 1×
@babel/plugin-proposal-json-strings7.0.0 · 1×
@babel/plugin-proposal-numeric-separator7.0.0 · 1×
@babel/plugin-proposal-throw-expressions7.0.0 · 1×
@babel/plugin-syntax-dynamic-import7.0.0 · 1×
@babel/plugin-syntax-import-meta7.0.0 · 1×

For agents

$ claude mcp add notifme-sdk \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact