How to use the plivo.Client function in plivo

To help you get started, we’ve selected a few plivo 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 Qolzam / firestore-social-backend / functions / src / services / authorize / authorizeService.ts View on Github external
request(verificationURL, (error: any, response: any, body: any) => {
        body = JSON.parse(body);
        if (body.success !== undefined && !body.success) {
            console.log('Captha/responseError', error)
            console.log('Captha/responseError',response)
            console.log('Captha/responseError', body)
            res.status(HttpStatusCode.BadRequest).json(new SocialError("ServerError/ResponseCaptchaError", "Failed captcha verification"))
        }
        console.log('Captha/responseSuccess')
        const client = new plivo.Client(functions.config().plivo.authid, functions.config().plivo.authtoken);        
        client.messages.create(sourcePhoneNumber,targetPhoneNumber,phoneMessage.replace('<code>', String(code)))
        .then(function (message_created: any) {
            const verifyRef = firestoreDB.collection('verification').doc(userId).collection('phone')
            .doc()
            const phoneVerification = new Verification(
                verifyRef.id, 
                String(code), 
                targetPhoneNumber, 
                moment().unix(),
                remoteIpAddress,
                userId
            )
            verifyRef.set({...phoneVerification})
            return res.status(HttpStatusCode.OK).json({ "verifyId": verifyRef.id });
        })
    });</code>
github lskjs / lskjs / packages / sms / src / transports / plivo.js View on Github external
constructor(config) {
    this.config = config;
    this.client = new plivo.Client(config.authId, config.authToken);
  }
  send({ phone, text, ...params } = {}) {
github transitive-bullshit / sms-number-verifier / lib / provider-plivo.js View on Github external
constructor (opts = { }) {
    super()

    ow(opts, ow.object.plain.label('opts'))

    const authId = opts.authId || process.env.PLIVO_AUTH_ID
    const authToken = opts.authToken || process.env.PLIVO_AUTH_TOKEN

    ow(authId, ow.string.nonEmpty.label('plivo authId'))
    ow(authToken, ow.string.nonEmpty.label('plivo authToken'))

    this._messages = { }

    this._client = new plivo.Client(authId, authToken)

    this._server = new IncomingSMSServer({
      transform: (body) => {
        const message = {
          from: body.From,
          to: body.To,
          text: body.Text,
          id: body.MessageUUID,
          timestamp: new Date()
        }

        const result = parseMessage(message.text)
        if (result && result.code && result.service) {
          message.code = result.code
          message.service = result.service
          return message

plivo

A Node.js SDK to make voice calls and send SMS using Plivo and to generate Plivo XML

MIT
Latest version published 16 days ago

Package Health Score

75 / 100
Full package analysis