Skip to content

Instantly share code, notes, and snippets.

@snay2
Created February 3, 2011 18:30
Show Gist options
  • Save snay2/809919 to your computer and use it in GitHub Desktop.
Save snay2/809919 to your computer and use it in GitHub Desktop.
Twilio integration for the Office Hours app
rule call is active {
select when twilio onanswer
if officehours:onnow("Office hours") then {
noop();
}
fired {
raise explicit event call_present;
} else {
raise explicit event call_not_present;
}
}
rule call_present is active {
select when explicit call_present
twilio:say("Steve is holding office hours right now in Cubicle 13. Go visit him!");
}
rule call_not_present {
select when explicit call_not_present
twilio:say("Steve's not in his office right now, but check the Google Calendar for more information on when he'll be back.");
}
rule sms is active {
select when twilio sms
pre {
messagetext = event:param("Body");
sender = event:param("From");
}
if officehours:onnow("Office hours") then {
noop();
}
fired {
raise explicit event sms_present;
} else {
raise explicit event sms_not_present;
}
}
rule sms_present is active {
select when explicit sms_present
twilio:sms("Steve is holding office hours right now in Cubicle 13. Go visit him!");
}
rule sms_not_present is active {
select when explicit sms_not_present
twilio:sms("Sorry, but Steve isn't there right now. Check the Google Calendar for when he gets back (http://bit.ly/fugrJ1).");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment