Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: warn out of date code section

...

The TAs install a ruleset called On-call TA: Demo in their personal event networks. This ruleset is looking for aschedule:inquiry event. The ruleset uses personal data from the network’s personal data management ruleset to customize it. The ruleset’s job is to notify the TA when a schedule:inquryevent is received. The notification takes the form of anotification:status event that is handled by the Simple Notifications ruleset. In this case, the Simple Notification ruleset sends an SMS message to the TA. Notice that the TA picks which notification ruleset is installed and this determines how they will be notified. Message and channel are separated.

...

  • None of these rulesets know about the others. They are connected by the event network in a loosely coupled maner.
  • The subscriptions are made using single-channel tokens that create a one-to-one link between networks. This protects against SPAM and other communications abuses. The relationship can be revoked as easily as it is created.
  • The behavior of the rulesets isn’t specialized to an individual. The rulesets are general purpose. All the personal data is retrieved from the personal data manager installed in the personal event network.
  • Anyone who wants to see the schedule:inquiry events from the class personal event network must subscribe to them. At present, that is done by modifying a hand-coded data structure (see below), but it could, of course, be automated to varying degrees.

The Gory Details


Warning

This section needs updating.

What follows are the gory details of how it all works. Keep reading if you’re into that sort of thing.

...

Subscribing to events thus requires that the owner of the personal event network provide an ESL, or at least the identifying token from the ELS, to the event publisher. Once a publisher has an ESL, they can raise events to the subscriber whenever appropriate. In the case of the TA dispatcher, any interested parties—presumably the TAs—subscribe toto schedule:inquiry events from the Dispatcher ruleset by supplying a token event channel identifer from their personal event network. The ruleset also needs other information from subscribers. We store those subscriptions in a data structure inside the Dispatcher ruleset:

...

The ruleset performs a bit of semantic translation on thethe twilio:sms event to determine whether it is a schedule inquiry or a response from the TA since they both are SMS messages to the same ruleset. If the SMS represents a schedule inquiry, the rule raises an explicit event named schedule_inquiry, causing the following rule to be selected:

...

Notice the embedded definition of mk_esl that takes a token, domain, and type and creates an ESL. The action usesuses http:post() to make the call.

...

The TA has installed a TA ruleset that listens forfor schedule:inquiry events. If the TA has an "On Call" appointment on her calendar, then the explicit eventon_call_request is request is raised with attributes named message andfrom. The event also includes an end attribute that contains the ending time of the appointment.

...

The explicit schedule_response event is handled by theprocess_ack rule that processes the TA responses and sends an acknowledgment to the student:

Code Block
languagejavascript
themeConfluence
rule process_ack {

...


 select when explicit schedule_response
 

...

pre {
   

...

phone_number = event:attr("From");

...


   ta_record = subscribers.filter(
       

...

          function(r){

...

 phone_number.match(

...

 

...

("/"+r{"phone"}+"/").as("regexp")

...

 

...

)}

...

 

...

).head();

...


   ta_name = ta_record{"name"};
   

...

ta_msg = event:attr("msg");

...

 msg = <<
#{ta_name} has been notified and will arrive

...

 shortly in Cubicle 11. He says '#{ta_msg}'
 >>;

...


   student_num = ent:return_receipt{"x"+event:attr("cookie")};

...


 }

...


 if(student_num && ta_name) then

...


   

...

twilio:send_sms(student_num, ta_sms_num, msg);
 

...

fired {
   

...

clear ent:return_receipt{"x"+event:attr("cookie")};
 

...

}
}

...

The rule uses the incoming phone number to filter the list of subscribers to retrieve the TA record in the subscriptions. That record is used to set the TA’s name. We also use the in-band cookie to retrieve information about the student to whom we’re responding. If the student number is found and that message came from a TA in the list, then we send an SMS back to the student and clear the return receipt.

...