Getting started with Nodejs and Twilio

In this post I show how I can send smses with nodejs and

In this little sample, I am showing you how you can send sms with, while learning a little about typescript and nodejs at the same time.

This is my second day with nodejs and its really fast and easy to create demo applications. Yesterday I created a Virtual Machine on Windows Azure with Ubuntu and with a few statements nodejs was installed with npm (the package manager).

sudo apt-get install nodejs

The node package manager (npm) is one of the reasons why it is fast to create something with nodejs. When I create a project, in visual studio, I just add a json file package.json with the dependencies and then npm install will pull down all the dependencies and put them in a folder node_modules. That is where it all start, now we can use require in JavaScript to load the modules. I am going to switch over to talk about typescript instead now and all my JavaScript will be generated from my ts files.


The reason for using typescript if you ask me is because of all the developing support you get - just like when you use visual studio for c# development. Not having to worry about typing functions names correct and not having to look up the APIs all the time. Most times, you know what function you want from seeing it in the dropdown menu. However, this is where typescript has a major flaw right now - all the type information need to come from somewhere.

There are a few good repositories on github, and if that one do not have the module you are looking for you can look in this one: So when the javascript libs do not have its own official definitely typed files module.d.ts, then people are creating their owns. Instead, people should contribute to the first of the two links above and help each other out. The good thing is that when you start using typescript, you do not need those and will just import your typescript modules, and if you cannot find or dent want to create a module.d.ts file for some external lib, you can just use it as it was JavaScript with no type safety and error checking. 

The good thing about borisyankovs github is we can get the typescript definitions with nuget.

For the demo to this post, I created a twilio.d.ts just to get me started.

I made it up just from going over nodejs intro on

Above you can see the code needed to send a sms with nodejs and twilio. Typescript on the left and javascript on the right, and then testing on my windows server machine that it works by sending myself a sms. And here is the screenshot from my mobile (Just learned i can do windows button + power to do screenshots).

Also a thanks to to providing me with an upgraded account and 25$ for testing.

I am planing on creating a little sms alert system and integrating it into composite c1 over the next few weeks together with combining nodejs and azure for scaling the application out. Stay tuned

comments powered by Disqus