Hey, nice little module here, it works very nicely. Do you have any plans for any incoming support?

I would envision something that ties into rules so you easily define what happens to the sms info if received.

Comments

univate’s picture

I don't have any immediate plans to work on this feature at the moment.

smsframework has some support for handling incoming messages so it should probably integrate with that.

nmcclain’s picture

Status: Active » Needs review
StatusFileSize
new1.57 KB

Hi univate, Thanks for this module - it works great!

Hi that0n3guy, This patch provides incoming SMS handling for Twilio via the SMS Framework. You'll need to apply the patch to sms_twilio, then configure your Twilio phone number (via the Twilio web site) to POST SMS messages to: http://YOURSITE/sms/twilio/incoming

Let me know if you run into problems!!

Cheers! Ned.

nmcclain’s picture

To be secure, for the moment this path either to be protected by HTTP basic auth (which Twilio supports).

The right answer in the long run is to implement the "Validating Requests are coming from Twilio" protocol described here:
http://www.twilio.com/docs/security-reliability/security

Be careful implementing the above patch in the meantime... someone could easily forge incoming SMSs!

notasheep’s picture

subscribing

thanks for writing this -- exactly what I needed and just in time!

djdevin’s picture

Status: Needs review » Reviewed & tested by the community

Tried the patch and two-way works successfully, thanks! Should add the security first tho

univate’s picture

Status: Reviewed & tested by the community » Needs work

I agree it would be best to make this secure, the PHP code required looks like its there above in that link, just need someone to copy it in and test.

nmcclain’s picture

Status: Needs work » Needs review
StatusFileSize
new5.14 KB

Univate, et al,

Okay, here's an updated patch against 6.x-1.0 that does security "the Twilio way" by validating the HTTP_X_TWILIO_SIGNATURE.

I also added a new admin config field so you can customize the incoming URI (someday, we'll have to support multiple incoming phone numbers!). I ran this through Coder module's code review and removed some extra spaces from other parts of sms_twilio.module.

Please don't be shy with feedback!! I'm happy to make whatever changes are necessary to get this committed to a dev version of sms_twilio.

univate’s picture

Status: Needs review » Needs work

Why do we need to make the incoming path configurable? I presume that the menu cache would need to be cleared when changing that path. I just think it would be best to set the path.

People can override the menu if they really want through a menu_alter as well.

nmcclain’s picture

Status: Needs work » Needs review
StatusFileSize
new9.99 KB

I added the configurable path hoping to lay the groundwork for multiple incoming numbers, but I agree this is definitely not important. I have removed that feature in this latest attached patch against 6.x-1.0.

Is there anything else I can do to get this patch committed?

univate’s picture

You could support multiple incoming paths through a variable:

function sms_twilio_menu() {
  $items['sms/twilio/incoming/%'] = array(
     ...
  );
  return $items
}

I was confused with that last patch, until I realised that the patch included a copy of the patch inside it as well

nmcclain’s picture

Thanks! As I thought through multiple incoming numbers and Twilio specifically, I realized we only need one incoming URI. Twilio passes both "to" and "from" SMS numbers in the POST. So currently it supports receiving SMS's from multiple Twilio numbers (just set the same URL in the Twilio.com admin page), but it does NOT provide a way to differentiate which of those numbers received the SMS on the Drupal side. I don't believe this is currently supported in the SMS Framework module.

So I think the only question is: is there a way to pass the SMS destination number to the SMS Framework module(s) such that it is actually useful somehow? SMS Framework would need to provide support for this before it could be handled in this module.

Regardless of the answer: Would you be up for going ahead and committing this fix, which resolves this issue? If someone opens a new issue for differentiating between multiple incoming SMS numbers in the SMS Framework issue queue, I'd be willing to look into implementing it...

--- I apologize for the recursive patch!!! (I'm embarrassed!!) If you'd like a "clean" patch, just let me know! ---

nmcclain’s picture

StatusFileSize
new4.46 KB

Okay, attached is a "clean" patch against 6.x-1.0. I believe this patch resolves this issue. Please let me know if you would like any additional changes before committing it.

I would be happy to tackle differentiating between incoming numbers in a different issue after we get this feature added.

univate’s picture

Status: Needs review » Fixed

committed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.