Skip to main content

Posts

Showing posts from May, 2017

How to make a Call in Nodejs through Twilio API

In order to make a call from our application in Nodejs, we can use TwilioAPI for doing so. We need to create an account on Twilio and specify details. Once we have done that we can use the following code: // Twilio Credentials var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' ; var authToken = "your_auth_token" ; var client = require ( 'twilio' )( accountSid , authToken );   client . calls . create ({     url : "http://demo.twilio.com/docs/voice.xml" ,     to : "+1XXXXXXXXXX" ,     from : "+1XXXXXXXXX" }, function ( err , call ) {     process . stdout . write ( call . sid ); }); We need to specify  to  and  from numbers. To  is the number that is verified under Twilio account and  from  is the number that Twilio generates for you at the account setup. Also url is the property that we need to setup so as to pick up the voice information.

How to send an SMS through Nodejs with Twilio API

In order to send an SMS from our application in Nodejs, we can use TwilioAPI for doing so. We need to create an account on Twilio and specify details. Once we have done that we can use the following code to send an SMS. // Twilio Credentials var accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' ; var authToken = 'your_auth_token' ; //require the Twilio module and create a REST client var client = require( 'twilio' )(accountSid, authToken); client.messages.create({     to : "+15XXXXXXXX" ,     from : "+15XXXXXXX0" ,     body : "Test Message from Twilio" , }, function (err, message) {     console.log(message.sid); }); We need to specify to and from numbers. To is the number that is verified under Twilio account and from is the number that Twilio generates for you at the account setup.