This Java Servlets tutorial will walk you through how you can automatically notify your system administrators if - well, when - something goes wrong on your server.
We'll dive in for a deeper look at all the wiring behind the scenes. Soon you'll see how easy it is to work notifications into your own application.
Sound good? Let's get started!
Click the button below to move to the next step of the tutorial.
Here we create a list of administrators (and your choice of others) who should be notified if a server error occurs.
The only essential piece of data we need is a text-enabled
phoneNumber for each person you list.
Next at the plate: we'll take a look at how to set up the Twilio REST client.
We'll have to read a
TWILIO_AUTH_TOKEN from environment variables.
The values for your account SID and Auth Token will come from the Twilio console:
Next, let's look at how we're handling application exceptions.
Next up, let's look at how to craft a custom message upon spotting an exception.
Here we create an alert message to send out via text message.
Feel free to also include a picture with your notification message. Perhaps a screenshot of the application when the exception happened? Some meme from a chain email?
Next, let's look at loading the list of administrators.
And for our next trick, we'll show how the text messages themselves are sent. Carry on!
And that's it!
We've just implemented an automated server notification system that can send your administrators push alerts if anything goes wrong. Twilio makes it easy to incorporate these important - and useful - functions for your own use cases.
Carry on and we'll look at some other useful ways our customers have used Twilio.
We've built a lot of sample applications with Twilio and Java, and we'd love to share them all. However, we'll limit our suggestions to just two:
Instantly collect structured data from your users with a survey conducted over a voice call or SMS text messages. That will help you quantify the impact of your support call handling, for starters.
If you're having issues with customers missing booked meetings, this tutorial is where you should head next. We look at sending automatic reminders as a meeting approaches.
Thanks for checking out this tutorial! Tweet to us @twilio to let us know what you thought or what you're building next!