Global Constant
Steve Nay's ramblings

Extending the Office Hours app using Twilio

This is the second in a series of three posts about this app. The other pages are here and here.

I extended my CS 462 office hours app this morning to include some Twilio features. I used Sam’s auction example heavily, since the Kynetx docs don’t talk about SMS much.

Basically, this app lets you call or text a phone number and find out whether I’m in my office hours.

I started by registering a phone number with Twilio. The number for this app is 801.855.6574. Once I had the number, I added two handlers, one for voice and one for SMS. They look like this:

http://webhooks.kynetxapps.net/t/a163x40.dev/onanswer

http://webhooks.kynetxapps.net/t/a163x40.dev/sms

I’m using the “.dev” extension since I was developing this actively. I might change that for the production app.

The KRL was pretty simple. I just needed two rules: one to handle the “twilio onanswer” event, one to handle the “twilio sms” event. That code looks like this:

I’d like to extend this in a few ways. One will tell you the next time I have office hours if I’m not there right now. Another might be allowing more options through SMS (asking whether I’m there, what the next time slot is, etc.). Other ideas you have?