Twilio Getting started with Twilio Sending an SMS Message from a US Number

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

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); 
});


Got any Twilio Question?