npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

msg91-sdk

v1.0.7

Published

This is used to handle msg91 apis such as send otp, sms and sms flow.

Downloads

83

Readme

msg91-sdk

This is used to handle msg91 apis such as send otp, sms and sms flow.

NPM

How to implement

Install node module package in your project

npm install msg91-sdk --save

Send OTP

use the below code snippet for sending OTP message to the specified mobile number

const sendOtpService = require('msg91-sdk').SendOtpService;
const sendOtp = new sendOtpService("AUTH_KEY", "MESSAGE_TEMPLATE");
sendOtp.otpLength = 6 // 'XXXXXX'
sendOtp.otpExpiry = 5 // In minutes

const aOptions = {
    mobile: "91988448XXXXX",// Mandatory param along with country dial code
    otp: "XXXXXX"
}

sendOtp.sendOTP(aOptions).then(() => {
//Handle success result
}).catch(() => {
//Handle failure result
})

Verifying OTP message to the specified mobile number

const sendOtpService = require('msg91-sdk').SendOtpService;
const sendOtp = new sendOtpService("AUTH_KEY", "MESSAGE_TEMPLATE");

const aOptions = {
    mobile: "91988448XXXXX",// (*) mobile number of the client
    otp: "XXXXXX"// (*) OTP received from the client
}

sendOtp.verifyOTP(aOptions).then(() => {
//Handle success result
}).catch(() => {
//Handle failure result
})

Retry OTP message to the specified mobile number

const sendOtpService = require('msg91-sdk').SendOtpService;
const sendOtp = new sendOtpService("AUTH_KEY", "MESSAGE_TEMPLATE");

const aOptions = {
    mobile: "91988448XXXXX",// (*) mobile number of the client
    retrytype: "voice"// (optional) ["voice", "text"] "text" -> default one
}

sendOtp.retryOTP(aOptions).then(() => {
//Handle success result
}).catch(() => {
//Handle failure result
})

Send SMS

Sending sms to many messages to many users using a below snippet

const sendSmsService = require('msg91-sdk').SendSmsService;
const sendSms = new sendSmsService("AUTH_KEY", "SENDER_ID", "ROUTE_ID");
sendSms.senderId
const mobileNumbers = [
    "988448XXXXX",
    "988447XXXXX",
    "988547XXXXX",
] // (*) mobile number of the client

const messages = [
    "Hello all, We welcome you all for msg91-sdk",
    "This sdk will give you many advantages from others"
]

const countryDialCode = "91" // "91" -> India, "1" -> USA, "44" -> UK, etc

sendSms.sendSMS(mobileNumbers, messages, countryDialCode).then(() => {
//Handle success result
}).catch(() => {
//Handle failure result
})

sendSms.sendSMS("988448XXXXX", "Hello All", countryDialCode).then(() => {
//Handle success result
}).catch(() => {
//Handle failure result
})

sendSms.sendSMS("988448XXXXX,988458XXXXX,988468XXXXX", "Hello All,New Message", countryDialCode).then(() => {
//Handle success result
}).catch(() => {
//Handle failure result
})

Sending sms with flow

const sendSmsService = require('msg91-sdk').SendSmsService;
const sendSms = new sendSmsService("AUTH_KEY", "SENDER_ID", "ROUTE_ID");
sendSms.senderId

const mobileNumber = "91988448XXXXX" // mobile number of the user
const templateId = "TEMPLATE_ID" // Template created in msg91 platform 

//Template Message in msg91 ->  Hi All, Welcome you all##COMPANY_NAME## 
/**
 * const params = {COMPANY_NAME:"MSG91-SDK"}
 **/

const params = {
    param_one: "COMPANY_NAME",
    param_two: "Welcome Message",
}


sendSms.sendSMSFlow(mobileNumber, templateId, params).then(() => {
//Handle success result
}).catch(() => {
//Handle failure result
})

Utilities

Checking balance of the route type

require('msg91-sdk').getBalance("AUTH_KEY", "ROUTE_ID").then(() => {
//Handle success result
}).catch(() => {
//Handle failure result
})

Buy Me a Coffee

License

MIT License

Copyright (c) 2020 Naveen Kumar Kuppan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.