8000 GitHub - willj/simple-sms: A wrapper around Amazon SNS to send simple transactional SMS messages.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A wrapper around Amazon SNS to send simple transactional SMS messages.

License

Notifications You must be signed in to change notification settings

8000 willj/simple-sms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple-SMS

A wrapper around Amazon SNS to send simple transactional SMS messages.

Installation

npm install simple-sms

Usage

The simplest way is to set three environment variables:

  • process.env.AwsAccessKeyId - your AWS access key created in IAM, with SNS priveleges
  • process.env.AwsSecretAccessKey - your AWS secret key
  • process.env.AwsRegion - your AWS region

To send a message call the send() function, which returns a promise.

const sms = require("simple-sms");

sms.send({
    message: "Hello World!",
    phoneNumber: "+447xxxxxxxxx",
    senderId: "WillJ"
}).then((result) => {
    console.log("Sent!");
    console.log(result);
}).catch((err) => {
    console.log(err);
});

If you can't or don't want to use those env var names, you can pass the information to the init() function before calling send.

const sms = require("simple-sms");

sms.init({
    accessKeyId: yourKey,
    secretAccesskey: yourSecret,
    awsRegion: "eu-west-1"
});

sms.send({
    message: "Hello World!",
    phoneNumber: "+447xxxxxxxxx",
    senderId: "WillJ"
}).then((result) => {
    console.log("Sent!");
    console.log(result);
}).catch((err) => {
    console.log(err);
});

Notes

You can read more about SNS here https://aws.amazon.com/documentation/sns/

Ensure you set a region that supports SNS http://docs.aws.amazon.com/sns/latest/dg/sms_supported-countries.html

About

A wrapper around Amazon SNS to send simple transactional SMS messages.

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0