Sending Librato Alerts As SMS with Group Messaging


In our last post we discussed the outcome of our 2-hour hackathon, where we used our NodeJS SDK to allow Hubot to send SMS, that was cool!

But there were other ideas that we left behind… for a while. Today we’re showing you how to integrate your Librato account with PortaText by using our PHP SDK , so you can receive SMS alerts on your mobile.

We have made the code available at our GitHub account, at

How it works

To accomplish this we are going to take advantage of the Custom WebHooks that Librato offers. The webhook integration will deliver a JSON payload through HTTP whenever an alert occurs, so we’re going to build a small PHP script that can handle that HTTP request and send an SMS through PortaText to a group of Contact Lists with the alert information (just don’t tell your ops team that you got the idea from us!).

Setting up Librato

Login to your account, and you should notice an icon with 4 hexagrams linked together, much like the following one. Click it!

Screen Shot 2016-01-26 at 17.52.21

You should now see a menu with the available integrations for your account. Locate the one for webhooks, it looks like this. Click it.

Screen Shot 2016-01-26 at 17.52.13

Then another menu should be present, where you can setup the integration:

Screen Shot 2016-01-26 at 17.52.51

Configure the URL where your php script will “live”. Make sure that it is accessible from the “outside world” since Librato will need it. That’s it 🙂

The code

Deploy the code so it can be accessed when hitting that URL. Don’t forget to configure the script with your Contact List ids, API key, and source DID.

If you take a look at the code, you will notice that it is actually a really simple PHP script, and you’re right, this is just an example and although it is fully functional, your mileage may vary when using it for your own needs.

Most of the script deals with reading the HTTP request and extracting the right information from it. The interesting part where the SMS is sent is actually right at the end of the script, and it’s just 1 line of code written as a multiline sentence just so it can be read real pretty 🙂


As you can see, it is really easy to integrate your alert system with PortaText. In this case we used PHP, but we offer SDK for other programming languages too. With just 1 line of code we can send a message to a specific number or to a group of contact lists (meaning dozens or hundreds of numbers). Hope you enjoyed this one! 🙂

— The PortaText Team.