Java application to send message using Twilio and IBM Bluemix™


IBM® Bluemix™ is a platform(PaaS) that helps users to build and deploy their applications easily without any worry of infrastructure setup.It abstracts and hides most of the complexities that are associated with hosting and managing cloud-based applications.Both IBM and third party services are available on IBM® Bluemix™. Twilio is a mobile service that is available on Bluemix which allows software developers to programmatically make and receive phone calls and send and receive text messages using its web service APIs.

This tutorial will help you to build and deploy a java application that sends registration successful message using Twilio and IBM® Bluemix™


Let’s start building java application,before that lets go to our Bluemix Dashboard and select required services to build it!

Step 1: Goto Catalog and then click on Java Runtime

blog1Step 2: Enter your application name. Eg: registermsg. Click on CREATE

blog3Step 3: Application is created and it can be viewed on the Bluemix DASHBOARD. Click on the application

blog4Step 4: Click on ADD SERVICE

blog5Step 5: In CATALOG goto Mobile Services and click on Twilio

headerStep 6: Change the Service name if required, Enter the Twilio API credentials and click on CREATE


Step 7: Click on Add a service again and then in CATALOG goto Data and Analytics and click on SQLDB

blog_6Step 8: Create the service by giving it a service name. Follow the steps to create a table in SQLDB as shown in my previous blog

Cool! The service is now up and running in Bluemix!! We can now proceed to Eclipse IDE to build the registration application that inserts details into database and also sends out registration successful message.

Input–>Team Name, First participant name,emailid,mobile number,Second participant name,emailid,mobile number and Hackathon idea

Copy and paste the twilio-java jar to the below shown location


Database integration ( JNDI lookup of database, can be dynamically integrated using VCAP_SERVICES)

code0 code01

Twilio API (hard coded the Twilio accountSID, Twilio authentication token.Can be taken dynamically)

codeNext step is to push the WAR file to Bluemix using cf command line interface(CLI)

Step1: Login to Bluemix account from the cf command line interface cf login -a ( Depending on the region selected your api endpoint changes). Enter the credentials

deployblog1Awesome! You have now logged into Bluemix from your cf command line interface

Step2: Now push the WAR file to Bluemix using the command

cf push appname -p <path_of_war_file>

deploy2Yipee!! The application have been successfully deployed in Bluemix!!

Common lets test it!!


Click on REGISTER after providing the required details



Awesome! The details have been inserted into database and I just received a message!! Yipeee!!

ResultThanks IBM® Bluemix™ and Twilio !! You made our life easier and simpler !!

Courtesy: ( IBM Bluemix and Twilio (

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s