[No Longer Supported] Twilio Notifications Driver - Supports SMS and Voice Calls

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.

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

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.

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

1 Like

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

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.

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

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.

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

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.

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.

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.

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 ?

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

1 Like

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

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.

1 Like

I would like to use Alphanumeric sender in Twilio - can this be supported? (you will save the cost of a Twilio number when using alphanumeric ID as sender)?

In Twilio sending a SMS text by alphanumeric ID can be done by this curl command (I can also send the Jaca, Ruby, PHP, Python, C# or Node.js commands if this will help):

curl 'https://api.twilio.com/2010-04-01/Accounts/AC772ee08aeXXXXXXXXXXX0b4ed4/Messages.json' -X POST
--data-urlencode 'To=RECIEVER'
--data-urlencode 'From=SENDER'
--data-urlencode 'Body=MESSAGE'
-u AC772ee08aXXXXXXXXXX15360b4ed4:[AuthToken]

It would be greaat if this could be done as it would save the cost of a phone number.

Twilio support has made it clear that they would like to help with this if it is needed :slight_smile:

The SMS API requires a “from” phone number otherwise it rejects the API call. I am not understanding what you mean by alphanumeric sender. Can you please provide a link to their documentation on what you are referring to? You above example is exactly what my code is using where the ‘SENDER’ is the from phone number.

The link is here: What is an Alphanumeric Sender ID? - Twilio an here Alpha Sender ID Resource for Messaging Services - Twilio.

You cannot setup a static alphanumeric id in Twilio (as far as I can figure out). Every time I send an SMS I specify the ID (for instance my name or a street address).

As I cannot setup a static sender ID in Twilio as I do not get a phone number possibility in the twilio notification setup.

Still not connecting the dots here on this feature and the ability to send free SMS messages. But knowing a few things about Twilio it seems you are using a free developer account which allows free voice and SMS. Because you have to pass in your account SID and Auth token to send an SMS you obviously have an account. I’ve always had my own number but can explore if this is an option as I find time.