Twilio plugin coming soon...

Posted on
Sun Jun 12, 2016 3:35 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Twilio plugin coming soon...

I'm working on a plugin for Twilio to replace (at least for me) the Google Voice SMS plugin. Why? Because the GV plugin is pretty fragile. It works by screen-scraping the GV web interface, and is prone to breaking anytime Google changes anything on that page. Also, the developer of that plugin is no longer actively maintaining it, so fixes are pretty sparse. And I only have one GV number and if I want to use it for anything else, I can't use it for the plugin.

So, Twilio. Yes, it's a pay service, rather than free like GV. That doesn't bother me if I think it's worth what it costs. And it doesn't really cost much. For a local (not toll free) number, it's $1/month in the US. And $0.0075 (less than 1 cent) per SMS. For my usage, I'll rarely go much over $2/mo.

Also, they have a very well developed API with libraries for lots of languages.

And, they have voice services as well. So you can pre-record a message (or use a TTS solution that creates an mp3 file on a server), and have Twilio call someone and play the message. Included in the monthly number cost, and outgoing calls are only $0.015/min.

I've got basic SMS sending working now, and receiving is mostly working. They archive all SMS messages, in and out, so I have to filter for incoming messages still.

I'm posting this in advance so that you can get a Twilio account set up in advance. They do have trial accounts you could use, but you don't have as much control over them as a paid account. Probably good enough for trying the plugin out, anyway. To set up the plugin, you'll need a Twilio phone number (you can have more than one), plus the SID and Token for your account.

Depending on big stomping on other plugins, expect something usable in a couple days.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Jun 12, 2016 3:45 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Twilio plugin coming soon...

Sounds pretty sweet, I'll be anxious to try it out. I'll probably still keep the GV plugin as well (even if I have to rewrite it :P) since I've had the number for years and lots of folks have it, but for my HA stuff I might move over to Twilio instead.

Thanks FD!

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Sun Jun 12, 2016 3:57 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Twilio plugin coming soon...

You can port numbers to Twilio, but that might not be right for you.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Jun 12, 2016 3:59 pm
Colorado4Wheeler offline
User avatar
Posts: 2794
Joined: Jul 20, 2009
Location: Colorado

Re: Twilio plugin coming soon...

I think I recall on my GV signup that porting that number would never be allowed, I could be wrong of course, I would have to check. However, if it CAN be then I likely will, I've never liked most software programs that scrape, too prone to failure.

My Modest Contributions to Indigo:

HomeKit Bridge | Device Extensions | Security Manager | LCD Creator | Room-O-Matic | Smart Dimmer | Scene Toggle | Powermiser | Homebridge Buddy

Check Them Out Here

Posted on
Sun Jun 12, 2016 4:04 pm
Bollar offline
Posts: 528
Joined: Aug 11, 2013

Re: Twilio plugin coming soon...

Cool! I'll get one.

Insteon / Z-Wave / Bryant Evolution Connex /Tesla / Roomba / Elk M1 / SiteSage / Enphase Enlighten / NOAA Alerts

Posted on
Sun Jun 12, 2016 4:17 pm
mclass offline
Posts: 312
Joined: May 13, 2015
Location: Melbourne, Australia

Re: Twilio plugin coming soon...

WOOHOO. Just what I'm looking for! Many thanks.
Mclass


Sent from my iPad using Tapatalk

Posted on
Mon Jun 13, 2016 9:39 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Twilio plugin coming soon...

How to handle already processed messages?

The Twilio API has no concept of "unread" or "read" messages. When I do a getmessages() type call, I get all messages that have not been deleted. Inbound, outbound, whatever. Right now I'm filtering on "inbound" messages only (ones sent TO your Twilio number), and only those messages will cause triggers to fire (or update device state).

I have an option in the plugin prefs to delete messages once processed. Right now, that applies to ALL messages (inbound or outbound).

Currently, if I don't delete the messages any triggers for them will re-fire on the next scan.

I can implement an already-processed list, like I do for POP servers in the BetterEmail plugin. The problem is that it's stored locally in the pluginPrefs file, and if it gets deleted or corrupted then all the messages will get processed again. But that's probably the best option, as reprocessing a bunch of old messages is a really bad idea. OTOH, I could just force deletion (no option to keep).

Thoughts?

Other than basic SMS send and receive, what other features are people looking for? I know the GV plugin had some way to write data into variables. Is built-in variable storage or device control important? If so, how to authenticate the sender?

I will probably put in a way to initiate a voice call, but customizing the recording to play if answered is tricky. Users of that feature may need to get an Amazon S3 account to store the recordings in. I think that's the only option Twilio supports.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Jun 13, 2016 10:29 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Twilio plugin coming soon...

Does the API return a timestamp for when the message was received? If so, you could instead just store the most recent date that you processed and any message older than that date can be skipped...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Jun 13, 2016 10:57 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Twilio plugin coming soon...

jay (support) wrote:
Does the API return a timestamp for when the message was received? If so, you could instead just store the most recent date that you processed and any message older than that date can be skipped...


Yeah, that might work. I can't request messages based on that timestamp, as the granularity for requesting the messages is from a specific date (not time). But I could round down for the request and then filter after that. Let's see....

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Jun 13, 2016 3:44 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Twilio plugin coming soon...

I got the last processed timestamp working per Jay's suggestion. I'll work on restricting the initial query to a later version.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Jun 13, 2016 5:48 pm
mclass offline
Posts: 312
Joined: May 13, 2015
Location: Melbourne, Australia

Re: Twilio plugin coming soon...

Great stuff! For the immediate application I have in mind, deletion of messages after processing would be ok.

I also just need to dial a number - the GSM controller I'm integrating into Indigo responds to a call from an authorized inbound number, and does not answer the call. Instead it actions in response to the incoming call, and responds with an SMS message in confirmation. It also has two digital inputs. Each can be programmed to initiate a preprogrammed text message that I would like the plugin to "translate" into modifying a variable and/or triggering an event.

But with this exciting plugin, anything's possible .......

Mclass



Sent from my iPad using Tapatalk

Posted on
Tue Jul 12, 2016 9:29 am
zachhcaz offline
Posts: 6
Joined: Dec 02, 2014

Re: Twilio plugin coming soon...

This is great news! I'd be happy to help anyway possible. I've used Twilio for several years on website I maintain and it is very handy. They have a great API and detailed documentation.. I am also having trouble with the Google Voice SMS plugin as it requires me to manually login to the GV account each month and restart the plugin before it will start working again. I'm more than happy to add a number to my Twilio account and pay for SMS with our home automation. If you need any help testing or just someone to bounce ideas off of, I'm happy to help.

Posted on
Tue Jul 12, 2016 9:33 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Twilio plugin coming soon...

zachhcaz wrote:
This is great news! I'd be happy to help anyway possible. I've used Twilio for several years on website I maintain and it is very handy. They have a great API and detailed documentation.. I am also having trouble with the Google Voice SMS plugin as it requires me to manually login to the GV account each month and restart the plugin before it will start working again. I'm more than happy to add a number to my Twilio account and pay for SMS with our home automation. If you need any help testing or just someone to bounce ideas off of, I'm happy to help.


Plugin has been available for a few weeks now: viewtopic.php?f=177&t=16265

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Wed Jul 27, 2016 4:25 pm
dshj offline
User avatar
Posts: 84
Joined: Jan 16, 2010
Location: San Francisco, CA

Re: Twilio plugin coming soon...

I'm a heavy user of the variables with the Google SMS Plugin. I create text strings in variables based on events. For example, I'll create a string "Front Door opened at [date] [time]. Then I trigger a send to multiple addresses based on other variables (who should see this message, when should it send, so-on). Is this something I can do with your plugin?

Posted on
Wed Jul 27, 2016 4:36 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Twilio plugin coming soon...

dshj wrote:
I'm a heavy user of the variables with the Google SMS Plugin. I create text strings in variables based on events. For example, I'll create a string "Front Door opened at [date] [time]. Then I trigger a send to multiple addresses based on other variables (who should see this message, when should it send, so-on). Is this something I can do with your plugin?


I don't see why not. The text field to be sent has full device state and variable substitution. As does the recipient number. All the other stuff is normal Indigo scheduling and action conditionals, I think.

Per your posting in the GV SMS thread - all the Twilio messages come from YOUR Twilio number, so there's no confusion there.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Who is online

Users browsing this forum: No registered users and 2 guests

cron