Send Text Messages from SIL

Some alerts are more important than others and there are times when it is very important that the message is received. When I was a Jira admin (way back when) we had a problem with our server and it would randomly restart. I wanted to know when this happened because sometimes Jira would start correctly, sometimes it wouldn’t. This was way back in the days of Jira 5 (I think). I don’t remember exactly what the issue was with the server but I do know what I did to solve the problem of getting notified of when it went down, I sent myself a text message.

With the use of Start and Stop scripts you can configure Power Scripts to run a script whenever Jira starts or stops. Note that this is assuming that Jira starts/stops correctly. If the server crashes the procedures to shut JVM instance down get skipped. So, if you configure a script to run when Jira starts it tends to be more reliable. If you install Jira to run as a service it will automatically start when the server reboots and the script will run whenever the server crashes and restarts. That is what I used it for anyway, perhaps you have something else in mind. Either way the steps to send the message will be the same.

For a long time SIL had SMS capabilities built directly within it. However, these SMS gateways had to be configured with each service provider. That way has become obsolete now that (just about) every carrier has an email to SMS service that will automatically convert an email to a text message if the email is sent to the right address. Each provider has a different email address but they all basically work the same way. The phone number servers as the username and then each carrier has a unique domain. See a list of some of the most common carriers below.

But, before you run off and start creating a script to do something similar there are some considerations to be made. Like, how to associate the phone number and carrier to a user. You could just write a script like this:

sendEmail("", {}, "Jira has restarted!", "The Jira server has been restarted. Maybe you should check it out?");

But, I wouldn’t recommend it. Maybe you don’t want your phone number out there for everyone to see. Plus, what happens when another admin wants this super cool feature? You would need to put there info in the script as well. What happens when it becomes 20? Suddenly you make everyone's personal information available for everyone to see.

One option would be to use persistent variables. That way the personal information would be a little more out of sight and would not be stored in the script.

persistent string [] textUsers; JEmailMessage email; = textUsers; email.subject = "Jira has restarted!"; email.message = "The Jira server has been restarted. Maybe you should check it out?"; sendEmail(email);

This method is okay, however, personally I like to build solutions that don’t require the script to me modified in order to maintain them. I also like to keep user data with the user. The way I prefer to do, which admittedly, is a little more involved, is to store the information as a user property.

Then the users who whish to receive the text messages can be added to a group. The script will loop through the users in the group and get the emails from the users properties.

string [] smsEmails; for(string user in usersInGroups("SMS Recipients", true)) { string email = getUserProperty(user, "SMS Email"); if(isNotNull(email)) { smsEmails += email; } } JEmailMessage email; = smsEmails; email.subject = "Jira has restarted!"; email.message = "The Jira server has been restarted. Maybe you should check it out?"; sendEmail(email);

Yes, it is a little more code but in this way a users email can easily be updated in the Jira admin UI and not the script. And, users can easily be added or removed from the user group.