Lately, we’ve been talking a lot in this space about the impact of web APIs on IoT development. Specifically, how they can help you simplify development by giving you functionality you probably wouldn’t otherwise have.

One of the best – and most popular – examples of a feature-rich API comes from Twilio, a company you’ve probably heard about, and one we briefly covered in a previous post. Twilio provides a web API that makes it easy to enable IoT devices to communicate with users via SMS, without the need to build in the infrastructure or integrate with a network operator.

This fast-growing firm, whose platform is used by 700,000 developers, recently landed a new round of funding, bringing its total funding to more than $1 billion. And it counts big brands like Coca-Cola and Home Depot as customers. Even the popular car-service pioneer Uber is on board with Twilio, using Twilio APIs to give its apps better communication features.


Taking the Pain out of Messaging

One of the biggest reasons so many people are using Twilio is because of how simple it makes IoT communication. Twilio uses APIs to provide a layer of abstraction over the complexity of the public switched telephone network (PSTN), making its functions accessible to programmers. The APIs send communication requests to Twilio’s cloud data centers, where text messages or phone calls are processed and delivered back to applications via the API.

Twilio uses a simple markup language called TwiML to communicate between a web application and the Twilio API. For instance, a user could receive an SMS message at a Twilio-provided phone number, and the message is then translated to TwiML and sent as an HTTP request to your web application.

Initially, Twilio was focused primarily on voice, SMS, and video. But earlier this year, the company announced a group of powerful new features. These include:


Twilio IP Messaging Service. Using this service, developers can build messaging into any of their apps. The service provides read and write indicators, multiparty chat support, and push notifications.

Global Conference. This new VoIP conference call service gives developers the ability to add audio conference call capabilities to host calls for up to 250 people.

Copilot. Developers can use this new tool to help scale SMS messaging apps. It automates the process of provisioning more numbers, so developers won’t have to build their own feature to deal with a long messaging queue.

Twilio Monitoring. With this operational monitoring service, you can track usage, check for possible security holes, and easily audit Twilio apps for compliance.


The Benefits: Simplicity and Scalability

For IoT developers, there are some substantial benefits to using Twilio. Here are the big ones:

Simplified Development. With Twilio, you can take advantage of a simple hosted API and markup language to quickly build advanced voice and SMS communications apps. The API leverages existing web development skills, resources, and infrastructure to make it easy to develop reliable communications apps. Both the technology’s syntax and its programming model make app development as close as possible to the request/response model of web application development. The API uses a RESTful interface, with responses formatted in XML, JSON or CSV.

Scalable Platform. Scalability is not a problem with Twilio. Applications written on the service rely on the company’s global infrastructure to scale transparently. With that functionality taken care of, developers don’t have to worry about the programming and contractual challenges that are often part of supporting fast growth or traffic spikes.

Another advantage? Cost savings. The service uses a pay-as-you-go pricing model, meaning that customers pay for capacity only when they need it.


Taking a Test Run

So now that you’ve learned a bit more about Twilio’s features and functionality, why not try it out? Here are some simple instructions for using PHP to build an app that lets you control phone calls using TwiML:


When a new phone call starts or a key press or dial ends, Twilio makes an HTTP GET or POST to a web server specified by your app. If you use HTTP POST, the service sends parameters as form-encoded variables in the body of the POST. If you use HTTP GET, parameters are passed in the URL query string.

To start, you’ll need a Twilio inbound phone number, which you can get for free by using a trial account. You’ll also need a web host that lets you host PHP apps. You can also visit the sites listed below to download the code used in this example:


Building the App

  1. Create a file titled hello-monkey.php in the document root. The URL can be (for this example, let’s pretend your web server answers HTTP requests at This will be the initial voice URL for your phone number.
  2. Browse to the phone numbers page in your account on the Twilio website. Click the Edit link next to the phone number you would like to use. Next, check the Voice box, and paste the URL of your hello-monkey file listed above in the URL box. After saving, this number will now point to the new hello-monkey code.
  3. Open the hello-monkey.php file on your web server. You can then start with some basic PHP code:








header(“content-type: text/xml”);

echo “<?xml version=\”1.0\” encoding=\”UTF-8\”?>\n”;



<Say>Hello Monkey</Say>


Pick up your phone and dial the number of the application. Twilio will fetch your URL and execute the XML instructions above. It will say “hello monkey” and then hang up because there are no more instructions.

There are many more tutorials like this, as well as in-depth feature documentation, on the Twilio website.


Golgi and Twilio

Twilio also works seamlessly with the Golgi Programmable Device Cloud Platform, which gives developers the ability to connect with many API ecosystems including Twilio. Using the Golgi and Twilio APIs, developers can easily send and receive text messages from embedded IoT devices. We’re excited to partner with Twilio, which is another great tool that’s taking the complexity out of IoT development.


Back to Articles

Leave a Reply