Twilio Brings the Power of Communications to IBM Cloud Platform, Codename: BlueMix


Twilio is joining forces with IBM to bring voice, messaging, and VoIP functionality to developers on the IBM Cloud Platform. Today, IBM announced the open beta for Codename: BlueMix, a cloud platform that combines open source PaaS technology with a host of application services. Developers can deploy and manage Twilio applications quickly from the BlueMix administrative console, configuring Twilio account information in a single step.

The BlueMix beta and the Twilio partnership were announced on stage at IBM’s Pulse Conference in Las Vegas, NV. Robert LeBlanc, IBM SVP, Software and Cloud Solutions Group, revealed IBM Codename: BlueMix to the audience and introduced Jeff Lawson, Twilio CEO and Co-Founder, who talked about the partnership and demonstrated building a Twilio SMS and Client application on top of the BlueMix platform.

The Nitty Gritty On BlueMix


As a developer, you have likely seen explosive growth in the number of cloud offerings that promise to abstract infrastructure (Infrastructure as a service, IaaS) and the app development stack (Platform as a service, PaaS). BlueMix is definitely born of that movement, but it has some properties that stand out in the crowd.

The core technology that powers BlueMix is the popular and powerful Cloud Foundry, an open source PaaS that is infrastructure agnostic. For BlueMix, it means that developers can immediately take advantage of open source contributions to that ecosystem, like custom buildpacks. Cloud Foundry also makes it really easy to deploy your application and view logs from your production apps. In addition to the functionality of Cloud Foundry, developers will be able to quickly integrate services provided both by IBM and and third parties like Twilio.

 To get started, sign up for the BlueMix beta. Once you’re accepted into the beta, you’ll be able to install the standard Cloud Foundry “cf” command line utility (version 6 is a Go executable you can download here).  Follow these instructions to configure the “cf” CLI app to hit the IBM BlueMix API server. Next, open the BlueMix admin console to create your first app.

Get Started Building a Twilio App on BlueMix

When you signed up for the BlueMix beta, you created an IBM ID.  Use that ID to log in to the BlueMix dashboard (linked from the home page here). Here, you should be able to create a new app

1On the next screen, you will see a variety of choices for what type of app to create.  You can choose a boilerplate app with some pre-configured code and services, or you can create a new app in Java, Ruby, or node.js. Let’s create a new app using node.js

2Click the “Create Application” button, and give your app a name.  I’ve called my app “twilio-big-blue”. Once created, your app should be listed on your dashboard home page

3Click on the app. You have a little bit of configuration you have to take care of to get your app ready to rock with Twilio. On your app’s detail page, scroll down a bit to a section titled “services.” Here you can choose application services like MongoDB, Redis, IBM SSO, or Twilio to add to your application a la carte. Click “Add New Service”

4..and then scroll down to choose Twilio

5In the resulting dialogue, you will need to input your Twilio Account SID and Auth Token. You can then pull in these values as system environment variables in the code you are about to write.  These values can be found on your Twilio account dashboard

6After adding your Twilio service, it will appear under your app’s configuration, but it will probably be named something goofy


Click on the Twilio service, and rename it to just plain ”Twilio”

8Awesome – now let’s write a simple node.js app, and push it up to BlueMix!


Writing and Deploying A Twilio-powered node.js App

First thing is first, if you haven’t done so already, you will need to install node.js on your system. Then, open up a terminal window and create a new directory for your Twilio/BlueMix app. Initialize your node app with a package.json config file using this command

> npm init
You should be able to accept the defaults for most of the questions the “npm init” command will ask you by pressing enter. Next, install the twilio module for node, as well as gopher, a variant of the popular Express web framework with a bit more functionality and default configuration out of the box
> npm install --save twilio gopher
Next, create a new file called “app.js.” This will pull in our Twilio account credentials and define a single URL route that will send us a text message. Then display the message’s unique identifier in the browser when the URL is requested

Make sure to change the “to” and “from” fields to be your mobile number and a Twilio number you control. Now, it’s time to push our code to BlueMix. Using the cf utility, enter the following command in your app’s directory, replacing “twilio-big-blue” with your app name:
> cf push twilio-big-blue
After a minute or so, your application will be pushed up to BlueMix. Visit your app’s root URL in a web browser. Behold! You just sent a text message with Twilio on BlueMix


If you have any questions or comments on the integration, be sure to let us know.

  • Sanjay Joshi

    After trying this blog’s Node.js sample code on Bluemix, I suspect a bug exists. I needed to add the following line after the require statements to successfully deploy the app. Otherwise, I think gopher defaults to using process.env.PORT which will cause a failure during the Bluemix staging process.

    app.set(‘port’, process.env.VCAP_APP_PORT || 3000);

    Thanks for a great post and a super cool service …

    • kevinwhinnery

      Hey Sanjay,

      Actually, process.env.PORT is defined in the BlueMix environment – it points to the same value as process.env.VCAP_APP_PORT. PORT is often used as an environment variable for this purpose in Cloud Foundry-based platforms. I was able to deploy a node application to BlueMix just now and confirm this to be the case.

      If you have further problems deploying, let us know, but this particular thing shouldn’t be a problem in the current BlueMix beta. But since it’s still a beta, these things could change.


  • Arun

    Thanks for the great post. I was trying to follow these steps to deploy the app to bluemix. But i had multiple problems. First i was getting directory path name too long error, while pushing the app to bluemix using cf.exe. I had to run “npm dedup” which seemed to fix that error and i could get further. But then i get this error now:


    Server error, status code: 400, error code: 170001, message: Staging error: cann

    ot get instances since staging failed

    Any ideas?

    • kevinwhinnery

      This can happen if there’s an error somewhere in your application code, as it could cause the node process to crash on initialization. I would make sure you can deploy a simple “hello world” node app, and then start layering back in functionality to see if there’s something amiss in the libraries or code you’re using. I would also encourage you to contact IBM support and ask for better error messages when these types of deployment errors occur. Thanks!

    • susanrizzo

      I got the exact same errors you experienced.
      1 – FAILED Error uploading application. The filename or extension is too long.

      You do not need to push the twilio & gopher node modules, you only need them to run with Node.js locally.
      Delete the node_modules directory before you do the ‘cf push ‘

      2 – Staging error. I found that I got this staging error because of some issue with the dependencies added to the package.json (npm install –save twilio gopher).
      “dependencies”: {
      “twilio”: “^1.6.0”,
      “ejs”: “^1.0.0”,
      “express”: “^3.5.1”,
      “gopher”: “0.0.7”
      I changed the dependencies to use “*” for their versions and it worked. Howerver, I just tried again with above versions and it worked (no staging error).