1.6.0 • Published 5 years ago
@fabrix/spool-twilio v1.6.0
spool-twilio
Twilio Spool for sending SMS messages
Install
$ npm install @fabrix/spool-twilio --save
Configure
Add TwilioSpool to your Fabrix App:
// config/main.ts
export const main = {
spools: [
// ... other spool
require('@fabrix/spool-twilio').TwilioSpool
]
}
Add configuration for twilio:
// config/twilio.ts
export const twilio = {
/**
* 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.
License
1.6.0
5 years ago