Twilio Sending an SMS Message from a US Number


Example

This is how to send an SMS text message from a US number using Twilio's Node.js SDK.

First you need to install the Node.js client using:

npm install twilio

Then, you have to create an account on their website.

Once you have an account, you'll need the account SID and auth token that you can find on the online dashboard.

Location of Account SID and auth token on online dashboard

In the code example below, replace [Account SID] and [Auth Token] with the ones from your account.

// Twilio Credentials 
var accountSid = '[Account SID]'; 
var authToken = '[Auth Token]'; 
 
//require the Twilio module and create a REST client 
var client = require('twilio')(accountSid, authToken); 
 
client.messages.create({ 
    to: "+16518675309", // Any number Twilio can deliver to
    from: "+14158141829", // A number you bought from Twilio and can use for outbound communication
    body: "Hey Jenny, thanks for the pull request, will merge it right away." 
}, function(err, message) { 
    console.log(message.sid); 
});