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

Strange - it says:

dev:5472019-11-05 07:24:26.276 errorgetAlphaSenders: Invalid Service SID was probably entered. Twilio Server Returned: groovyx.net.http.HttpResponseException: NOT FOUND

dev:5472019-11-05 07:24:25.623 debugGenerating Alpha Sender list...

dev:5472019-11-05 07:24:25.616 debugPhone list generated, phoneNumbers: []

dev:5472019-11-05 07:24:24.709 debugGenerating Twilio phone number list...

dev:5472019-11-05 07:24:24.705 debugAPI credentials validated

dev:5472019-11-05 07:24:23.810 debugValidating API Credentials...

dev:5472019-11-05 07:24:23.712 debugInitializing Virtual Container

I have asked Twilio to look at this topic as it says I have put in an invalid Service SID.

That error is part of my code, not an official Twilio error.

Is their message.

Try this API and see if you can get a list of your Alpha Senders as that is what my updated code is executing. If you have success please post your curl example.

When I use this curl: curl 'https://messaging.twilio.com/v1/Services/MG03c2654cf67dXXXXXXX6f6607/AlphaSenders/AIce7a88XXXXXXXXX44a9c751a' -u AC772ee0XXXXXXXX0b4ed4:[AuthToken] I get this responce (I have anonymised several numbers via X'es):

200 - OK - The request was successful.
{
"date_updated": "2019-11-01T07:39:26Z",
"alpha_sender": "Hubitat",
"capabilities": [
"SMS"
],
"account_sid": "AC772XXXXXXXXXXXXXXXX5360b4ed4",
"url": "https://messaging.twilio.com/v1/Services/MG03c2654XXXXXXXXXXXXX6f6607/AlphaSenders/AIXXXXXXXXXXXXXXXXXX9c751a",
"sid": "AIce7XXXXXXXXXXXXXXX844a9c751a",
"date_created": "2019-11-01T07:39:26Z",
"service_sid": "MG03c2XXXXXXXXXXXXXXX6f6607"
}

And this curl: curl 'https://messaging.twilio.com/v1/Services/MG03c26XXXXXXXXXXX6f6607/AlphaSenders' -u AC772eeXXXXXXXXXXXXXXXX4ed4:[AuthToken] gets me this:

200 - OK - The request was successful.
{
"meta": {
"page": 0,
"page_size": 50,
"first_page_url": "https://messaging.twilio.com/v1/Services/MG03c2654XXXXXXXXXXXXXX607/AlphaSenders?ServiceSid=MG03c265XXXXXXXXXXXXXX8b6f6607&__referrer=sms-mms&PageSize=50&Page=0",
"previous_page_url": null,
"url": "https://messaging.twilio.com/v1/Services/MG03c26XXXXXXXXXXXXXXd38b6f6607/AlphaSenders?ServiceSid=MG03c26XXXXXXXXXXXXXXXXXX38b6f6607&__referrer=sms-mms&PageSize=50&Page=0",
"next_page_url": null,
"key": "alpha_senders"
},
"alpha_senders": [
{
"date_updated": "2019-11-01T07:39:26Z",
"alpha_sender": "Hubitat",
"capabilities": [
"SMS"
],
"account_sid": "AC772eXXXXXXXXXXXXXX415360b4ed4",
"url": "https://messaging.twilio.com/v1/Services/MG03c2654XXXXXXXXXXXXXXX38b6f6607/AlphaSenders/AIce7a88XXXXXXXXXXXXXXX4a9c751a",
"sid": "AIce7a8XXXXXXXXXXXXXXXXXX751a",
"date_created": "2019-11-01T07:39:26Z",
"service_sid": "MG03c26XXXXXXXXXXXXXXbd38b6f6607"
}
]
}

OK I had some extra parameters similar to the phone numbers API call to force a JSON response - something I am used to including for other Twilio APIs. Maybe this newer API doesn't allow those so I removed them on line 133 of the driver.

Please download and give it a try to see if it works. If not please provide debug output. Also please feel free to play around with line 133 of the code.
https://raw.githubusercontent.com/mlritchie/Hubitat/master/Drivers/Twilio%20SMS/Twilio-Container

Okay, now there is progress - the logs shows that it has found the alphasender "Hubitat"!

However, after I clicked save prefferences all prefferences dissapear, and in the device settings it just says: "No prefferences defined for this device", and also state: ContinerSize: 0, State Variables: vsIndex: 1.

I tried to create a device with label and phonenumber which also is shown in the logs:

dev:5772019-11-06 13:33:53.230 warnUnable to create device.

dev:5772019-11-06 13:33:53.189 debugAttempting to create Virtual Device: Label: SMS, Phone Number: +4530703119

dev:5772019-11-06 13:33:10.913 warnjava.lang.String cannot be cast to java.util.Map$Entry

dev:5772019-11-06 13:33:10.870 debugphoneList: '[]', alphaSenderList: '[Hubitat]'

dev:5772019-11-06 13:33:10.864 debugAlpha Sender list generated, alphaSenderList: [Hubitat]

dev:5772019-11-06 13:33:10.857 debugAlphaSenders response: 200

dev:5772019-11-06 13:33:10.038 debugGenerating Alpha Sender list...

dev:5772019-11-06 13:33:10.034 debugPhone list generated, phoneNumbers: []

dev:5772019-11-06 13:33:09.217 debugGenerating Twilio phone number list...

dev:5772019-11-06 13:33:09.213 debugAPI credentials validated

dev:5772019-11-06 13:33:08.244 debugValidating API Credentials...

dev:5772019-11-06 13:33:08.154 debugInitializing Virtual Container

I really appreciate your help!!!

@henrik.kristensen I believe I have a working solution as I asked a UK coworker to validate the receipt of a SMS. Please delete your Twilio devices in your device list and start over.

  • Add the Twilio Container driver in your Drivers Code area
  • Add the Twilio Device driver in your Drivers Code area
  • Navigate to Devices and create a new device using the user Twilio Container driver you just uploaded
  • Set your Account SID and Auth Token and toggle the Alpha Sender preference and click Save Preferences
  • Assuming your SID and Token validate, you will have an opportunity to enter your Alpha Sender preference and click Save Preferences again.
  • At the top enter your Device Label and E1.64 formatted phone number and click Create Device
  • Reload the browser page and scroll to the bottom and you should see a child Component Device for your phone
  • Click that link and enter text in the Device Notification box and the top and click the Device Notification and validate the receipt of the SMS
  • Assuming success you can now utilize this notification device in Rules and other areas of HE.
1 Like

YES!!!!! IT WORKS!!!!!!

Thank You so MUCH for your help - this is so awsome!!!!!!!!

1 Like

Awesome glad to hear it’s working.

1 Like

Is this driver no longer around? I get a no page exists when I click on the Github link above.

https://raw.githubusercontent.com/mlritchie/Hubitat/master/Drivers/Twilio%20SMS/Twilio-Container

https://raw.githubusercontent.com/mlritchie/Hubitat/master/Drivers/Twilio%20SMS/Twilio-Device

Excuse my Ignorance. So I put both the Container and Device code in Drivers Code. Then I would first have to select the Container as device, not Device?

Hope that made sense.

Thank you @aaiyar for posting links.

@j715 I have neglected to update this post since @chuck.schwer included this as a stock driver.

Differences from mine:

  1. Have parent container driver that creates children so you only have to enter the Twilio API once. It will create children versus button at top.
  2. Added support for Alpha Sender for @henrik.kristensen. This is something I’ve been meaning to alert @chuck.schwer about to consider for stock driver.

Otherwise unless you need the above features the stock driver works great.

Reason I was looking at this, was wondering if it could be modified to use the voice API also. Looks like a minor modification. I thought I would play around with it a little then let you know what I found out.

I have a friend who still likes to get phone calls when an alarm occurs. Can't budge him from this.

That’s much more involved and something g I have done at work. Twilio needs a callback URL for the actual content to speak which will more involved.

1 Like

When I first looked at the documentation on Twillio I guess I didn't read it quite right. Looked again and yes, it would be quite involved. So forget that idea. Not that important to me.

@j715, @Dustyd5, @jwprovencher I have updated this driver to make voice calls. Please see the first post for detailed instructions.

1 Like

That’s great. Be a few days before I can try it out but looking forward to it.

1 Like

This sounds amazing. I will have to try it soon.

1 Like

I am attempting to set this up. Everything seems to work fine, my Twilio account verifies ok, etc. But when I create a device I just get an error saying 'Unable to Create Device'.

I enter a name, a phone number in the form +1xxxxxxxxxx.

What might be the problem?

I deleted everything and started over and now it works. Thanks for your efforts.

1 Like