How to use notifme-sdk - 4 common examples

To help you get started, we’ve selected a few notifme-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aol / moloch / notifiers / provider.notifme.js View on Github external
exports.sendSlackAlert = function (config, message, links) {
  if (!config.slackWebhookUrl) {
    console.error('Please add a Slack webhook URL on the Settings page to enable Slack notifications');
    return;
  }

  const slackNotifier = new Notifme.default({
    channels: {
      slack: {
        providers: [{
          type: 'webhook',
          webhookUrl: config.slackWebhookUrl
        }]
      }
    }
  });

  // add links to the slack alert
  let slackMsgObj = { slack: { text: message } };
  if (links && links.length) {
    slackMsgObj.slack.attachments = [];
    for (let link of links) {
      slackMsgObj.slack.attachments.push({
github notifme / notifme-template / example / index.js View on Github external
const nunjucks = require('nunjucks')
const NotifmeSdk = require('notifme-sdk').default
const getRenderer = require('..') // notifme-template

// Renderer (Example with nunjucks)
nunjucks.configure({autoescape: false})
const render = getRenderer(nunjucks.renderString, 'example/templates')

// Notif.me sender
const notifmeSdk = new NotifmeSdk({
  useNotificationCatcher: true
})

// Render a template and send it
const data = {
  smsFrom: 'Notifme',
  emailFrom: '"David, Notif.me team" ',
  user: {
    firstname: 'John',
    email: 'john@example.com',
    phone: '+15000000001',
    pushToken: 'xxxxx',
    webpush: {
      endpoint: 'xxxxx',
      keys: {
        auth: 'xxxxx',
github aol / moloch / notifiers / provider.notifme.js View on Github external
exports.sendTwilioAlert = function (config, message, links) {
  if (!config.accountSid || !config.authToken || !config.toNumber || !config.fromNumber) {
    console.error('Please fill out the required fields for Twilio notifications on the Settings page.');
    return;
  }

  const twilioNotifier = new Notifme.default({
    channels: {
      sms: {
        providers: [{
          type: 'twilio',
          accountSid: config.accountSid,
          authToken: config.authToken
        }]
      }
    }
  });

  if (links && links.length) {
    for (let link of links) {
      message += `\n${link.text}: ${link.url}`;
    }
  }
github aol / moloch / notifiers / provider.notifme.js View on Github external
exports.sendEmailAlert = function (config, message, links) {
  if (!config.host || !config.port || !config.to || !config.from) {
    console.error('Please fill out the required fields for Email notifications on the Settings page.');
    return;
  }

  if (!config.secure) {
    config.secure = false;
  }

  const emailNotifier = new Notifme.default({
    channels: {
      email: {
        providers: [{
          type: 'smtp',
          host: config.host,
          port: config.port,
          secure: config.secure,
          auth: {
            user: config.user,
            pass: config.password
          }
        }]
      }
    }
  });

notifme-sdk

Unified notification SDK (emails, SMS, pushes, webpushes...) for Node.js

MIT
Latest version published 7 days ago

Package Health Score

81 / 100
Full package analysis

Popular notifme-sdk functions

Similar packages