Twilio Message Service Integration with nodejs

Posted By : Vivek Joshi | 09-Sep-2017

For Integrating Twilio Message service to nodejs project you have to follow following steps

Step1:- Go to https://www.twilio.com  and create your Twilio account 

Step2:- After creating account then go to manage number on your Twilio dashboard and click on add number (e.g '+' sign in the number)

Step3:- buy a number according to your location.

            after buying number you will get account SID,authtoken and a message from the number. 

Step4:- Using Twilio messaging service in nodejs there is a nodejs module name called Twilio you have to download for downloading use following command it terminal

          npm install twilio --save

Step5:- After successfully download use the twilio module in your application you have to require it.

Step6:- for sending a message using twilio account use the following steps

Step 6.1:- Declare the twilio account credential into your application as follow

var SID = "<your twilio sid>";
var TOKEN = "<your twilio toke>";
var FROM = "<your twilio from number>";

Step 6.2:- After defining twilio credantials then create a twilio client as follow

var client = require('twilio')(SID, TOKEN);

step 6.3:- after creating twilio client object you can use this object to send message from your application using following code.

var number ="<message receivers number>"; //for sending message add country code also ( USA number's not require country code)
var message ="content of message";
  client.messages.create({to:number ,from: FROM, body: message}, function(smsError, smsResponse) {
    if (!smsError) {
        console.log("messass send successfully.....");

    }else{
      console.log("Error in sending message..",smsError);
     }
  });

About Author

Author Image
Vivek Joshi

Vivek is Web App Developer in Java Technology and also working on NodeJS.

Request for Proposal

Name is required

Comment is required

Sending message..