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… ![]()
Edit: my branch GitHub - Jean-PhilippeD/Gladys at sms · GitHub
