Wondering what’s next for npm?Check out our public roadmap! »

trailpack-twilio

1.0.1 • Public • Published

trailpack-twilio

NPM version Build status Dependency Status Code Climate

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.

License

MIT

Install

npm i trailpack-twilio

DownloadsWeekly Downloads

2

Version

1.0.1

License

MIT

Last publish

Collaborators

  • avatar