npm twillio code example

Example: npm twilio

npm i --save twillio dotenv
// login into twillio account 
// create app.js file
require('dotenv').config();

var accountSid = process.env.TWILIO_ACCOUNT_SID; // Your Account SID from www.twilio.com/console
console.log("======> :: accountSid", accountSid);
var authToken = process.env.TWILIO_AUTH_TOKEN;   // Your Auth Token from www.twilio.com/console

const client = require('twilio')(accountSid, authToken);

client.messages.create({
    body: 'sss',
    from: '+4444',//enter you phone number
    to: '+55'//the number that you want to send the message //must be verified by twillio
})
    .then((message) => console.log(message))
    .catch((err) => console.log(err));

Tags:

Misc Example