20,000 Text Messages Under the Sea with OpenROV, Node.js and Twilio

August 19, 2015
Written by


Meet Rovie. Rovie is our underwater robotic friend here at Twilio:

Rovie and Brent. Rovie is the one on the left.

Over the past couple months myself and fellow Developer Evangelist Brent Schooley have been teaching Rovie to swim and send underwater pictures whenever she gets a text message.  Last week at That Conference we took Rovie to her first party and he enjoyed swimming in the beautiful pool at the Kalahari Resort with 500 of her closest friends.

Building Rovie

Rovie is an OpenROV – an open-source, low-cost underwater robot for exploration and education. One of my favorite things about working with an OpenROV is that the cockpit software is a Node.js application. When we wanted to modify Rovie to receive text messages we immediately opened up the cockpit application and started poking around.

Rovie’s cockpit application uses Express which made it really easy for us to add a new route that Twilio would be able to send a request to whenever an incoming message arrives at Rovie’s phone number::

app.post('/sms', function( req, res ) {
  var twilio = require('twilio');
  var resp = new twilio.TwimlResponse();

  camera.snapshot( function( filename ) {
    resp.message(function() {
      this.body('Greetings from the Kalahari Pool! Here's a picture. Check out: http://twilio.com')
        .media('http://our-openrov-ngrok-url.ngrok.com/photos/' + filename);


Here we tell Rovie to snap a picture and then respond with some TwiML that sends the picture back to whoever texted in.

Before we could run this code we needed to make this route publicly available using one of my favorite tools – ngrok. You may know ngrok as a super rad command line script that you run to open up your localhost to the outside world. But there’s also a Node.js module for ngrok that lets us open up a new ngrok tunnel directly from within our application:

var ngrok = require('ngrok');

    authtoken: '%ngrok-key%',
    subdomain: '%our-openrov-ngrok-url%',
    port: 8080
}, function (err, url) {
    console.log( err );

That’s all the code we needed. Here are a couple pictures from Rovie’s big swim courtesy of the That Conference flickr album:


What’s Your Summer Hack?

It’s been hot in New York City and hacking on an underwater robot has been the perfect way to cool off. Are you working on any great summer hacks? We’d love to see them! Find us on Twitter (@rickyrobinett and @brentschooley) or say “hi” in the comments.