Today we'll build a Java and Spring sample application which demonstrates how to push SMS alerts on server exceptions. We'll show you how to automatically notify your server administrators when something goes wrong, and cover the plumbing that makes it happen.
Here we create a JSON list of administrators and whomever else should be notified if a server exception occurs.
The only essential piece of data we need is a
phoneNumber for each person.
Next, let's take a look at how to configure the Twilio REST client.
To send a message we'll need to initialize the
TwilioRestClient as documented in the Twilio Java Helper Library. It requires reading a
TWILIO_AUTH_TOKEN from environment variables.
The values for your Account SID and Authorization Token will come directly from the Twilio console:
Click the eyeball icon to expose your Auth Token in a form you can copy and paste.
Next, we will see how to handle application exceptions and add in our new functionality.
Next up, let's see how to create a custom message.
Here we craft the perfect alert message to send out via text message.
You might also decide to include a picture with your exception handling message. Perhaps a screenshot of the application when the crash happened? Some infographics from somewhere?
Let's look at how to load the list of lucky administrators.
Next up, let's look at how to send a text message.
We've just implemented an automated server notification system in Java and Spring that notifies all the right people when exceptions inevitably occur.
Now let's look at some other common features that are easy to add with the Java SDK.
Twilio を使う Java 開発者であれば、他のチュートリアルも調べてみてください。
Don't let that valuable marketing data slip away! Instantly collect structured data from your users with a survey conducted over a voice call or SMSes.
Prevent no-shows by building an awesome Twilio-powered appointment reminder feature into your application.
Tweet to us @twilio and let us know how it went, or what you're building next!