Sending SMS to multiple recipients

I’m currently sending a SMS alert using webhooks and Twilio

Based on what I have been reading in order to send a sms to multiple recipients I would need to make a separate API request for each sms. Currently, I’m storing a single phone number in EEPROM and
and sending it using this code:

snprintf(alertSensorSms, sizeof(alertSensorSms), "{\"N\": \"%s\", \"T\": \"%s\", \"M\": \"%s\"}", dev_name, phone_str, message_str);
                    publishQueue.publish("NC_SMS", alertSensorSms, 60, PRIVATE);

Any recommendations on how I should approach the option of adding multiple recipients?

Are you doing a direct webhook from Particle Clout to say Twilio or what service are you using to initiate sending the SMS? I have webhooks that push the data to my own back-end and then my back-end makes a call to Twilio. It’s Python based… this is how I do it: How to Send SMS and MMS Messages in Python - Twilio

Not sure if you can do the same thing with a simple webhook directly to Twilio, IFTTT or some other service but you are probably better searching their documentation as this doesn’t seem like a Particle thing. Off the cuff… I’d say you could send out multiple PublishQueue events (one for each phone number) and iterate through an array of phone numbers if you are fixed in requiring storing the phone number on the device itself in EEPROM.

I don’t think the Twilio API supports sending to multiple recipients (here). Just store multiple phone numbers in EEPROM and make one publish for each recipient using your same webhook.

1 Like

I realize it’s a completely different approach, but you could use Ubidots to easily send to multiple SMS. Another advantage would be web-based phone number management without reflashing your device.

Hi, I’m in favor of Ubidots, but even with other approaches, there may be no need to reflash if you store the phone numbers in eeprom and write code to change them via a function. :phone:

1 Like

Thanks guys. I’ll go with @rickkas7 recommendation and see how that goes.