AdonisJS (NodeJS MVC Framework) Addon Provider for Twilio (SMS Service)
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
providers
src
stubs
.editorconfig
.gitignore
CHANGELOG.md
CREDITS.md
LICENSE
README.md
package.json

README.md

adonis-twilio

Version Downloads License

Twilio Provider for AdonisJs framework.

Installation

In order to use adonis-twilio

npm install adonis-twilio --save

Setup

Once you have installed the provider from the npm, make sure to follow the below steps to setup the provider.

bootstrap/app.js
const providers = [
  ...,
  'adonis-twilio/providers/TwilioProvider'
]

Also, for registering commands.

bootstrap/app.js
const aceProviders = [
  ...,
  'adonis-twilio/providers/CommandsProvider'
]

const commands = [
  ...,
  'Adonis/Commands/Twilio:Config'
]

Also, it is a good practice to setup an alias to avoid typing the complete namespace.

bootstrap/app.js
const aliases = {
  ...,
  Twilio: 'Adonis/Addons/Twilio'
}

Then, for generating a config file.

./ace twilio:config

Configuration

Adonis Twilio configuration file located at config/twilio.js and set your environment variables in .env with following.

TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=
TWILIO_FROM=+15005550006

Usage

Load the module first

const Twilio = use('Adonis/Addons/Twilio')
Send SMS
Twilio.sendMessage('+14108675309', 'Hello from Node', function(err, response) {
    console.log( err, response );
}
Send MMS
Twilio.sendMessage('+14108675309', 'Hello from Node', 'http://cdn.memegenerator.co/images/200x/42.jpg', function(err, response) {
    console.log( err, response );
}
Make a Call
Twilio.makeCall('+14108675309', 'http://www.example.com/twiml.php', function(err, response) {
    console.log( err, response );
}

Changelog

CHANGELOG

Credits

Thanks to the community of AdonisJs.

Copyright and License

Copyright (c) 2016 Ahsaan Muhammad Yousuf, MIT License