Twilio Provider for AdonisJs framework.
In order to use adonis-twilio
npm install adonis-twilio --save
Once you have installed the provider from the npm, make sure to follow the below steps to setup the provider.
const providers = [
...,
'adonis-twilio/providers/TwilioProvider'
]
Also, for registering commands.
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.
const aliases = {
...,
Twilio: 'Adonis/Addons/Twilio'
}
Then, for generating a config file.
./ace twilio:config
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
Load the module first
const Twilio = use('Adonis/Addons/Twilio')
Twilio.sendMessage('+14108675309', 'Hello from Node', function(err, response) {
console.log( err, response );
}
Twilio.sendMessage('+14108675309', 'Hello from Node', 'http://cdn.memegenerator.co/images/200x/42.jpg', function(err, response) {
console.log( err, response );
}
Twilio.makeCall('+14108675309', 'http://www.example.com/twiml.php', function(err, response) {
console.log( err, response );
}
Thanks to the community of AdonisJs.
Copyright (c) 2016 Ahsaan Muhammad Yousuf, MIT License