How to use nexmo - 6 common examples

To help you get started, we’ve selected a few nexmo 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 celo-org / celo-monorepo / packages / attestation-service / src / sms.ts View on Github external
export async function initializeSmsProviders() {
  nexmoClient = new Nexmo({
    apiKey: fetchEnv('NEXMO_KEY'),
    apiSecret: fetchEnv('NEXMO_SECRET'),
  })

  const availableNumbers = await getAvailableNumbers()

  nexmoNumbers = availableNumbers.map((number: any) => ({
    phoneNumber: number.msisdn,
    code: phoneUtil.getRegionCodeForNumber(phoneUtil.parse('+' + number.msisdn)),
  }))

  console.log(nexmoNumbers)
}
github Nexmo / nexmo-cli / src / client.js View on Github external
if ((appId && privateKey) || appConfig) {
      const app_config = appConfig.read().app_config;
      nexmo = new Nexmo(
        {
          apiKey: credentials.api_key,
          apiSecret: credentials.api_secret,
          applicationId: appId || app_config.app_id,
          privateKey: privateKey || app_config.private_key
        },
        {
          debug: emitter.debugging,
          appendToUserAgent: `nexmo-cli/${packageDetails.version.replace('v', '')}`
        }
      );
    } else {
      nexmo = new Nexmo(
        {
          apiKey: credentials.api_key,
          apiSecret: credentials.api_secret
        },
        {
          debug: emitter.debugging,
          appendToUserAgent: `nexmo-cli/${packageDetails.version.replace('v', '')}`
        }
      );
    }
  } catch(e) {
    if (e instanceof TypeError) {
      emitter.error(`Could not initialize Nexmo library. Please run 'nexmo setup' to setup the CLI correctly. (${e.message})`);
    } else {
      if (e.path.indexOf(`.nexmo-app`) !== -1) {
        emitter.error(`Could not read application credentials. Please run 'nexmo app:setup' to setup a Nexmo application. (${e.message})`);
github celo-org / celo-monorepo / packages / verification-pool-api / src / config.ts View on Github external
export function getNexmoClient() {
  if (nexmoClient == null) {
    nexmoClient = new Nexmo({
      apiKey: functionConfig.shared['nexmo-key'],
      apiSecret: functionConfig.shared['nexmo-secret'],
    })
  }
  return nexmoClient
}
github MoveOnOrg / Spoke / src / server / api / lib / nexmo.js View on Github external
import Nexmo from "nexmo";
import { getFormattedPhoneNumber } from "../../../lib/phone-format";
import { Message, PendingMessagePart } from "../../models";
import { getLastMessage } from "./message-sending";
import { log } from "../../../lib";

let nexmo = null;
const MAX_SEND_ATTEMPTS = 5;
if (process.env.NEXMO_API_KEY && process.env.NEXMO_API_SECRET) {
  nexmo = new Nexmo({
    apiKey: process.env.NEXMO_API_KEY,
    apiSecret: process.env.NEXMO_API_SECRET
  });
}

async function convertMessagePartsToMessage(messageParts) {
  const firstPart = messageParts[0];
  const userNumber = firstPart.user_number;
  const contactNumber = firstPart.contact_number;
  const serviceMessages = messageParts.map(part =>
    JSON.parse(part.service_message)
  );
  const text = serviceMessages
    .map(serviceMessage => serviceMessage.text)
    .join("");
github Nexmo / nexmo-cli / src / client.js View on Github external
const initialize = function(config, emitter, appConfig, appId, privateKey) {
  var nexmo;
  const packageDetails = require(`${__dirname}/../package.json`);

  try {
    const credentials = config.read().credentials;
    if ((appId && privateKey) || appConfig) {
      const app_config = appConfig.read().app_config;
      nexmo = new Nexmo(
        {
          apiKey: credentials.api_key,
          apiSecret: credentials.api_secret,
          applicationId: appId || app_config.app_id,
          privateKey: privateKey || app_config.private_key
        },
        {
          debug: emitter.debugging,
          appendToUserAgent: `nexmo-cli/${packageDetails.version.replace('v', '')}`
        }
      );
    } else {
      nexmo = new Nexmo(
        {
          apiKey: credentials.api_key,
          apiSecret: credentials.api_secret
github Nexmo / nexmo-cli / src / client.js View on Github external
instanceWith(key, secret) {
    return new Nexmo({apiKey: key, apiSecret: secret});
  }

nexmo

Nexmo REST API client for Node.js. API support for SMS, Voice Calls, Text-to-Speech, Numbers, Verify (2FA) and more.

MIT
Latest version published 4 years ago

Package Health Score

51 / 100
Full package analysis

Popular nexmo functions