trailpack-twilio
v1.0.1
Published
Twilio Trailpack for sending SMS
Downloads
4
Maintainers
Readme
trailpack-twilio
Twilio Trailpack for sending SMS
Install
With yo :
$ yo trails:trailpack trailpack-twilio
With npm
$ npm install --save trailpack-twilio
Configure
Add you trailpack to Trails :
// config/main.js
module.exports = {
packs: [
// ... other trailpacks
require('trailpack-twilio')
]
}
Add configuration for twilio :
// config/twilio.js
module.exports = {
/**
* The "account sid" associated with your Twilio account.
*/
accountSid: null,
/**
* The "auth token" associated with your Twilio account.
*/
authToken: null,
/**
* This is the 'From' phone number you'd like to use to send the SMS.
*/
from: null
}
Usage
Use the TwilioService
like this (from controllers/policies/services) :
//Send basic SMS
this.app.services.TwilioService.sendSMSTo('toNumber', 'message to send').then(response => {
this.app.log.debug('ok')
}).catch(err => {
this.app.log.error(err)
})
//Send basic SMS with media URL
this.app.services.TwilioService.sendSMSTo('toNumber', 'message to send', {mediaUrl: 'http://myurl.fr'}).then(response => {
this.app.log.debug('ok')
}).catch(err => {
this.app.log.error(err)
})
Contributing
We love contributions! Please check out our Contributor's Guide for more information on how our projects are organized and how to get started.