Sending SMS to multiple phones

A while back I wanted an app to notify several people when something happened. It came in handy when my phone’s batteries had died yesterday. One of the other recipients got the message as was able to address the situation. Anyway, I thought I’d share the little snip that can be used anywhere you send an SMS in your apps.

To use it, create a phone number input in your preferences. When you want to have multiple numbers, separate them with a semicolon. Like you do in multiple email addresses.

It can be written a lot better, but I kept it basic and longhand. Here’s the snip:

def msg = "This is a message to you from my SmartThings thing"
if (phone) {
    if ( phone.indexOf(";") > 1){
        def phones = phone.split(";")
        for ( def i = 0; i < phones.size(); i++) {
            log.debug "sending SMS ${i+1} to ${phones[i]}"
            sendSms(phones[i], msg)
         }
    }
    else {
        log.debug "sending SMS to ${phone}"
        sendSms(phone, msg)
    }
}
2 Likes

Ah, so the input is just a string type textbox with numbers separated by semicolons?

I still keep hoping that “people” in SmartThings become a first class citizen that can have phone numbers and presence tags associated with them that we can enumerate, etc.

1 Like

Can I just put the two numbers separated by a semicolon in the SmartThings app where you normally put one number?

In the app highlighted above in this thread you can. The other apps that I’ve looked at won’t do this.

HTH,
Twack

Why doesn’t SmartThings have this in every app with SMS notifications?

1 Like

Thanks. I tested putting two numbers into the SmartThings native apps separated by either a semicolor or a comma. It does not work. If more than one number exists in the SMS text field, nothing is sent. This really is something that SmartThings apps should support. When the security alarm is ringing or motion is detected where it should not be, I would think most people would want to send the SMS text to more than one phone.

Just got my ST hub working today and joined the community forum. Maybe i should have waited before trying a custom app :slight_smile:

I tried to paste this code into the graphs.api.smarthings.com

but i receive this message "Metadata definition not found "

Can you help advise how to fix this

Ok, seems I need to know much more about this app than just a phone number input after look at this
http://docs.smartthings.com/en/latest/getting-started.html

Could I ask you for the Preferences, installed and updated sections?

hi,
can anyone help me how to send sms notification in particular instance even when the person doesn’t have smart app. I tries using the code “sendSms” but still not receiving any message