SMS Integration

Hi!

I wanted to share something with you. While looking into Gladys V4 (which is great, by the way, I can’t wait to put it into production at my place), I started rewriting some integrations I had in V3, and one of them was the Free SMS module. I don’t think it was mine… well…

So, I thought about how to do it and looked at how the Telegram integration works. I wanted to show you what I wrote at home this weekend.

Basically, Telegram is great, but for me, for example, if I’m on vacation and I want to receive a security notification (intrusion, fire…) and I don’t have Internet, I need SMS.

So, by looking at the message.sendToUser.js library, I saw that the call to the Telegram integration was hardcoded here. I tried/implemented a small modification like this:

// We send the message to the favorite service
const smsService = this.service.getService('sms');
const telegramService = this.service.getService('telegram');
try {
  // try to send through sms
  await smsService.message.send(user.id, messageCreated);
} catch(err) {
  // it may fails because of service does not exist or not configured
  // if the service exist and the user had telegram configured
  if (telegramService && user.telegram_user_id) {
  // We send the message to the telegram service
    await telegramService.message.send(user.telegram_user_id, messageCreated);
  }

(we could very well send by SMS AND by Telegram…)

And I wrote an SMS integration.
Not wanting to make a FreeSms integration dedicated to Free (and then one for Orange… etc.), I came up with something that could eventually manage multiple operators, the user having to choose their country and operator.

Of course, I didn’t touch anything on the part of the discussions with Gladys, SMS not allowing it.

I wanted to have your opinion, to see if you hadn’t already thought of another method…
I will push my code as soon as possible on my branch at home, and if you want to take a look… :wink:

Edit: my branch GitHub - Jean-PhilippeD/Gladys at sms · GitHub

Hello!

Cool! That’s great! :slight_smile:

Awesome! :slight_smile:

Indeed, as the Telegram integration was the only one so far, I hardcoded the behavior.

In your case, if I understand correctly, you want to receive an SMS only in very specific cases, right?

In that case, why not just have an SMS integration that has an action in the scenes « Send an SMS » (an action that would be different from the action to send a classic message)

This would allow having a special SMS behavior only for the cases where the user wants to receive an SMS, right?

I think the SMS case is quite different from the Telegram use case, which is bidirectional communication, whereas SMS is really just an alert

What do you think?

PS: Do you mind if I make this post public? I think it’s always better when discussions are public and other developers can intervene, I’m not the only maintainer :smiley:

No problem making it public.

Regarding my need, adding a Send an SMS option would be interesting, BUT not always optimal.

In my case, my wife has a Free subscription, so I want her to receive an SMS, I’m with Orange, and I don’t have/ no longer have an API to receive an SMS, so I want to receive a Telegram notification (this is the behavior on my current V3).

Oh.. or would Send an SMS to user XXX + Send a message to user YYY work? Would that work?

Exactly :slight_smile: As everyone has different needs, the goal is to create something super flexible.

It’s done and pushed to my branch.

How’s your integration going? Is it working well? :slight_smile:

Don’t hesitate to create your PR when you’re ready, and tag me for a code review!

Yes it works, I need to write the tests first.

Hello @Jean-Philippe,

I am very interested in your SMS integration for the same reasons as you.
I am setting up a home alarm, and I would like to send an SMS in case of intrusion.
Will it be available soon?
Thank you.

Hi,

Currently, it only searches for Free.
It works, but I haven’t had time to write the tests or push a PR.

I don’t have time for that :frowning:

Thanks @Jean-Philippe Keep me posted in case.

Hello,

this is exactly what I would need as well :slight_smile:

Currently, I manage to send messages using the free API with the address https://smsapi.free-mobile.fr/sendmsg?user=XXX&pass=YYY&msg=ZZZ
But it would be nice to have a small module to send an SMS!

Hope you find the time to finalize it…

Oh bother, I hadn’t seen that.
I wanted to work on it tonight and I started to create a freesms service: MAJ page : Développement sous Windows

@Jean-Philippe: Yours seems more generic and should be prioritized. If you’re short on time, I’d be happy to complete/test/merge the PR if you’re okay with it :slight_smile:

Hello,

No problem if you take over the SMS service I started writing. Currently, I don’t have any time to work on Gladys :frowning:

Thanks Jean-Philippe!

As soon as I manage to set up a working development environment, I’ll take care of it and keep you updated :wink: