Skip to content

Instantly share code, notes, and snippets.

@snay2
Created February 3, 2011 22:06
Show Gist options
  • Save snay2/810317 to your computer and use it in GitHub Desktop.
Save snay2/810317 to your computer and use it in GitHub Desktop.
Modified SMS rules
rule sms is active {
select when twilio sms
pre {
messagetext = event:param("Body");
sender = event:param("From");
nextevent = officehours:next("Office hours");
eventtime = nextevent => smsdate(nextevent.pick("$.when[0].start")) | "not scheduled. See the class wiki for info";
}
if officehours:onnow("Office hours") then {
noop();
}
fired {
raise explicit event sms_present;
} else {
raise explicit event sms_not_present with next=eventtime;
}
}
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
pre {
next = event:param("next");
}
twilio:sms("Sorry, but Steve isn't there right now. His next office hours are #{next}.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment