Easy SMS integration with Node.js

Sam Wierema
MessageBird
3 min readJun 3, 2016

--

Being a technology driven company, we understand how important it is to provide easy integration with the latest and greatest code libraries. That’s why we’re happy to announce a new addition to our list: the MessageBird Node.js package!

Over the summer we were playing around with Node.js at our internal hackathon and thought that it’d be cool if we had a MessageBird package. Turns out, there already was one! We reached out to the author, Franklin van de Meent, and asked him if he’d like to collaborate in building the next version. He accepted, and together we built version 2 of the MessageBird package, which we are releasing today!

If you haven’t heard of Node.js before, it’s a Javascript-driven runtime environment which has become very popular in recent years due to its low barrier to entry; getting something up and running is very quick and straightforward. It’s perfect for building powerful and realtime applications: Paypal uses it extensively for their payments interface, Github’s Atom editor is powered by it and the new WordPress runs on it.

Let me show you how quickly you can build something on Node.js by building a Hello, World! application, using the MessageBird package.

Building a Hello, world! application

Let’s dive straight in. The goal is to have the application send you an SMS containing “Hello, world!” when you run it. Note that, in order to run the code below, you’ll need to have Node.js and npm (Node Package Manager) installed, and you’ll also need tosign up for a MessageBird account.

The first thing you’ll want to do is include the MessageBird package in your project. You can do that easily by running npm install messagebird in your terminal.

The next step is to write the application. Create a filed called index.js in your project folder and copy the code below, replacing both the access key and the phone number with your own values (you can find and create an access key in your dashboard).

What’s happening in the code? We first create the messagebird variable, which contains all the methods to reach our SMS API. Then, we create an array of parameters to send to the API, and lastly, we send the request, making sure we catch any error that might occur.

Execute the code by running node index.js and if all is well, you should receive an SMS saying “Hello, world!”. Success 🙌!

There you have it, you can now enhance your Node.js application with MessageBird. Visit our Github page to view and download the source code, or install it directly vianpm.

I’d love to see what cool things you build. Feel free to reach out if you have any questions. You can reach me via Twitter at @samwierema, on Github at samwierema, or reach out to via email at sam@messagebird.com.

As mentioned in the introduction, a big thank you goes out to Franklin van de Meent. Beside being the author of the previous version of the MessageBird package, Franklin has helped out enormously by building most of version 2, taking care of all the little details. Thank you, Franklin!

--

--

Sam Wierema
MessageBird

Platform Evangelist at MessageBird. Organiser of events (IPAs & APIs, DevRel Amsterdam). Formerly CTO at The Next Web.