sails-service-sms
Service for Sails framework with SMS features.
List of supported SMS services
- Twilio (Docs)
Getting Started
Install this module.
npm install sails-service-sms
Then require it in your service and create sms instance.
// api/services/SmsService.js; 'twilio' sender: '<TWILIO_NUMBER>' provider: accountSid: '' authToken: '' ; // api/controllers/SMSController.js { SmsService ; };
Configuration
When you instantiate new instance via SmsService(type, config)
you can provide configuration object with next keys:
config.provider
- {Object} Options that will go to each of SDKsconfig.sender
- {String} Number of senderconfig.recipient
- {Array} Array of strings with phone numbers of recipientsconfig.message
- {String} Default message to send (you can override it insend()
)
API
Each of SMS instances has only one method:
send([config])
Sends SMS and returns Promise.
config
- Configuration object for sending SMS:
config.sender
- {String} Sender's numberconfig.recipient
- {Array} Phone numbers to which need to send (mixed up with pre-defined recipients).config.message
- {String} Message body text
Examples
TwilioSMS
let twilio = ; twilio ;
License
The MIT License (MIT)
Copyright (c) 2015 Eugene Obrezkov
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.