Twilio Sending messages in Node.js Sending Your First Message


Example

Installing The Node Module

You can install this module by running the command below in your project directory:

npm install twilio

Sending Your Message

const accountSID = ''; // Obtained from the Twilio Console
const authToken = '';   // Obtained from the Twilio Console

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

client.messages.create({
    to: '',  // Number you want to send to
    from: '', // From a valid Twilio number
    body: 'Hello, from Stack Overflow', // What appears in the text message
})
.then((message) => console.log(message.sid));