Twilio Notifications Driver


#21

I can see value in Rule Machine processing the SMS messages. Thinking of scenarios where you could SMS your Twilio number things like "den" to turn on the den lights, "garage" to open the garage door, etc. Since RM already has conditions and actions, it would nice to leverage that conditional logic to perform the actions based on the SMS. For example, if SMS received is "den" then action is turn on Den Lights. It would be a rather hard coded and complex app to build with all the scenarios versus just building rules. But I would expect it to be complex to add this functionality to RM as well.

Now all of this said, how would you manage security around this? I would hate for anyone, roboSMSer, etc to text your number and it perform some action. You would likely need some app sitting in between to verify like what is mentioned in this ST Forum article where the guy has a Node.js server that queries Google Contacts for verification before automating anything. This would be more difficult to build in Rule Machine. The only idea I have there is to query devices for details, but again complex.


#22

Could you not configure a whitelist of numbers in the app?


#23

Numbers can be cloned and imitated, so I see no way to secure this other than a type of two-factor reply. It's a very good point. So you would need the receipt of SMS from a verified number to trigger a reply with a time limited code, which you would then send back to authenticate.

Another way would be to require the SMS from the authenticated number, also include the output from an authenticator app, but both of these sound much more complicated and less convenient than a secure remote connection to me.


#24

I setup the Twilio notifications and it works great, couldn't be easier to use.


#25

Can you add multiple numbers - To: Phone Numbers in preferences on the virtual device ? If so how do you separate them ?


#26

This expects individual devices one per number. My solution has a parent container device that you add and then there is a function to create child notification devices. This way you only enter the AccountSID and Token once. Then in apps you select the individual devices you want to notify.


#27

There should be a simple option in hubitat. If you purchase the Twilio service and purchase a number from twilio.


#28

Not really sure what you are after honestly and keep in mind that this thread is about my custom driver and not the one published by Hubitat. You could always submit an enhancement request through support for the out of the box one. But by and large most notifications are set where you pick the notification device you want to alert versus setting multiple SMS numbers.


#29

Hi Mike,
I'm trying to setup a trial Twilio account.
I registered it (email and phone validation) without problems.
I obtained both Account SID & Auth Token
I put them in my HE App but I'm stuck trying to put a valid Device Network ID. Where can I find it ?
If I put something fancy (like Twilio), and when I test the app (virtual button => send a message to my twilio), the HE log displays alwaus a message:

Exception when sending: BAD REQUEST. Please check your device settings.

Did I miss something (newbie here)
Thank you


#30

When you login on the dashboard right hand side you will find the account SID and token, token is hidden but you click button to view. That is what is needed in my driver and the stock HE driver. You also need to make sure you have purchased a phone number in your account t as well.


#31

Purchase a phone number ? I have seen that Twilio allow a verified phone to be used. I verified mine with them and this phone is now verified and incoporated into my account.
But is the phone number purchase mandatory ?
The idea is to send real sms to multiple phones, some without any data plan or wifi reachable, or plain old phones with unlimited sms contracts.


#32

Yes that is correct, that is how Twilio makes revenue. You have a monthly fee to have a dedicated number for your use (in US its around a $1 per month) and then you have to pay usage, SMS are less than a US Penny per SMS.

Once you purchase a number in the driver you will select that number to send the SMS message from. The reason this is required is because you can purchase multiple numbers from Twilio and you must specify the From number when sending the SMS.


#33

ok, now I understand. Correct me if I'm mistaken.

in case of events, HE will trigger a message to my twilio account and the associated number (purchased from them) will send me a notification sms (1c/sms) to my final phone destination.

HE event => Twilio gateway (internet) => Twilio purchased phone => destination cell (cellular network)

Am I right ?


#34

Mostly correct... Twilio has a REST web service API that HE is calling. Twilio had agreements with most world wide carrier networks to deliver the SMS. Since the SMS has to come from a number, that is why Twilio requires that you pay a monthly fee for the number since it is reserved for your use.

HE event --> HE Rule/App --> REST Web Service to Twilio's APIs --> Cellular Network --> destination mobile device


#35

I updated the HE device with the provided "purchased" phone number and put the registered recipient phone number and made a test: perfect without doing anything else !

I asked twilio support if we can customize (trough studio ?) the phone redirection, depending of events, like:
HE alarm => send "alarm" msg to twilio phone and forward it to registered phone 1
HE garage door problem => send "garage door problem" msg to twilio phone and forward it to registered phone 1 AND registered phone 2.

Coudl be interesting to forward HE messages to several phones through twilio. I think their studio interactive programmation could do that.

Anyway, thanks for your help


#36

I received a reply from twilio and (I quote them):

"You can certainly use a Twilio phone number to forward messages to your cell phone based on content. Using a Studio flow, you can use a split widget to send a different message or send to a different number based on the content of the originating message. You would need to send messages to multiple messages sequentially."

I find this very interesting because we can customize recipients (SMS) depending of the content of the message sent from HE. And this without the need to add (pay) additional phone numbers.