<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>EchoChamber: Rule-Based Semantic Webhooks</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Jackson Morgan</string-name>
          <email>jmorgan45@gatech.edu</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Georgia Institute of Technology</institution>
          ,
          <addr-line>Atlanta GA 30332</addr-line>
          ,
          <country country="US">USA</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>The semantic web is well-suited for the storage and access of static information. However, the value in many datasets derives from being current and up-to-date. A service interested in such data could periodically query a SPARQL Protocol and RDF Query Language (SPARQL) enabled database to check for updates, but periodic querying is taxing to the receiving database and only guarantees new data is received within the intervals of querying. Time-sensitive datasets are often served by event-driven architectures that allow interested systems to be alerted every time information is updated. In this poster I outline EchoChamber, an event-driven, webhook-based implementation of a Web Ontology Language (OWL) triplestore using Semantic Web Rule Language (SWRL) rules as event triggers.</p>
      </abstract>
      <kwd-group>
        <kwd>Event-Driven</kwd>
        <kwd>SWRL</kwd>
        <kwd>Webhook</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        Event-driven architectures [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] are the method of choice when building systems to
handle data that is quickly updated and requires external systems to be alerted. The need
for a service to periodically query a data source to remain up-to-date is subverted by
event-driven architectures, thus saving valuable computing resources.
      </p>
      <p>
        One popular practice in implementing event-driven architectures is webhooks [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ].
Under a webhook implementation, when a data source wants to emit an update to an
interested service, it sends an HTTP request to a route at the service’s domain or IP
address that is provided upon configuration.
      </p>
      <p>Webhooks have the potential to transform the way semantic web services interact
with the world around them. Yet, webhooks and semantic resources have disparate
paradigms that require creative solutions. Mainly, webhooks are often triggered by
welldefined events. For example, when a repository on Github receives a commit it can
trigger a webhook. Conversely, webhooks for a semantic web resource should be
flexible, allowing for user-defined triggers for any kind of update that might be made to a
dataset.</p>
      <p>
        To address this problem, I propose EchoChamber, a triplestore implementation that
takes inspiration from a solution for semantic web access control [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. EchoChamber is
designed to easily integrate with current standards and proposals for the semantic web
including SWRL rules, [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] which allow for user-defined flexible triggers, and Linked
Data Notifications, [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] within which an EchoChamber server would serve as a “sender.”
      </p>
    </sec>
    <sec id="sec-2">
      <title>Design</title>
      <p>To understand the implementation of EchoChamber, consider the hypothetical graph in
Figure 1. Three users exist in this scenario, two of which, User A and User B, are
members of separate chat rooms, chat room A and chat room B respectively. A third user,
User C, can be described as an “Admin” role. Each chat room has a variable number of
messages that can be added or deleted. Finally, each user has a “chat webhook,” a URL
that should be called if ever an EchoChamber event is encountered. These routes
presumably live on a server that will send the update to the user’s device.
example.com/A
example.com/B</p>
      <p>example.com/C
chatWebhook
User A</p>
      <p>memberOf</p>
      <p>Our chat room application has two simple rules that should be provided to
EchoChamber. 1) If a message is added or removed in a chat room within which a
user is enrolled, alert the user via their corresponding webhook, and 2) admins should
be alerted to all message changes regardless of chat room membership.</p>
      <p>When a triple is added or removed from the triplestore, EchoChamber represents
that change as a graph that is integrated with the main triplestore. Figure 2 displays a
graph representing a change adding the string “Hello” to chat room B via the
“hasMessage” property.</p>
      <p>After creating the graph representation of the change, EchoChamber applies the
SWRL rules to modify the object. Based on the two rules outlined above, Figure 3
represents the rules that would exist for our hypothetical scenario.</p>
      <p>If a message is added or removed in a chat room within which a user is
enrolled, alert the user via their corresponding webhook:
ec:AddedAction(?action)
∧ ec:actionTriple(?action, ?actionTriple)
∧ ec:p(?actionTriple, &lt;hasMessage&gt;)
∧ ec:s(?actionTriple, ?chatRoom)
∧ memberOf(?user, ?chatRoom)
∧ chatWebhook(?user, ?webhook)
⇒ ec:sholdUpdate(?action, ?webhook)
Admins should be alerted to all message changes regardless of chat room
membership:
ec:addedAction(?action)
∧ ec:actionTriple(?action, ?actionTriple)
∧ ec:p(?actionTriple, hasMessage)
∧ Admin(?user)
∧ chatWebhook(?user, ?webhook)
⇒ ec:sholdUpdate(?action, ?webhook)</p>
      <p>If a rule’s antecedent is satisfied, the action will now have a variable number
“ec:shouldUpdate” properties that correspond with the URL that should be requested
as outlined in Figure 4.</p>
      <p>Finally, EchoChamber sends an HTTP request to each of the webhooks containing
the action graph. The shouldUpdate properties are excluded for privacy reasons.
3</p>
    </sec>
    <sec id="sec-3">
      <title>Implementation</title>
      <p>
        EchoChamber is implemented in Java Spring using owlapi [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] and swrlapi [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. The
main datastore has a simple interface to include swrl rules and the ability to add triples
as seen in Figure 5. After adding a tiple to the datastore, EchoChamber loops through
all given rules and sends a request to the desired url.
      </p>
      <p>One deviation of this implementation from the proposal above is the use of SQWRL
queries in the stead of SWRL rules. When defining the query, a user is expected to
include a ?webhook variable that will include the url of the desired target. While it
would be more advantageous to use SWRL rules for the sake of simplicity, it would
require modifications to the core systems of swrlapi and owlapi as the object property
ec:p which defines the predicate of an inserted triple is an object property that
references another object property. Such a property does not currently exist in owlapi.</p>
      <p>EchochamberDatastore datastore = new EchochamberDatastore("file.owl");
datastore.addRule(
"ec:AddedAction(?action) ^ ec:actionTriple(?action, ?actionTriple) ^ " +
"ec:p(?actionTriple, hasMessage) ^ ec:s(?actionTriple, ?chatRoom) ^ " +
"memberOf(?user, ?chatRoom) ^ chatWebhook(?user, ?webhook)”
“-&gt; sqwrl:select(?webhook)");
datastore.addDataPropertyTriple("ChatroomB", "hasMessage", "Hello!");
Fig 5. An example use case for the EchoChamber datastore implemented in Java.
An implementation of EchoChamber’s core features can
https://github.com/jaxoncreed/echochamber.
be found
Further work for EchoChamber includes efficiency improvements and the construction
of a more complete interface for the datastore. Such an interface would include methods
for removing triples and compatibility with SPARQL update queries while still
maintaining the ability to send webhook requests based on updates.</p>
      <p>
        A major inefficiency in EchoChamber is the need to loop through all rules given to
the datastore to collect webhook urls. Given a datastore with millions of rules, this
would be quite taxing to do on every update. Therefore, a scheme to retrieve SWRL
consequents through indexing antecedents as boolean expressions [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] would greatly
improve the implementation’s efficiency.
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Event-Drive Architecture</surname>
          </string-name>
          Overview, http://elementallinks.com/el-reports/EventDrivenArchitectureOverview_ElementalLinks_Feb2011.pdf,
          <source>last accessed</source>
          <year>2018</year>
          /6/1.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <article-title>Web hooks to revolutionize the web</article-title>
          , http://progrium.com/blog/2007/05/03/web-hooks
          <article-title>-torevolutionize-the-web</article-title>
          ,
          <source>last accessed</source>
          <year>2018</year>
          /6/1.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Kagal</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Finin</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Paolucci</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Srinivasan</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Sycara</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Denker</surname>
          </string-name>
          , G.:
          <article-title>Authorization and privacy for semantic web services</article-title>
          .
          <source>IEEE Intelligent Systems</source>
          <volume>19</volume>
          (
          <issue>4</issue>
          ),
          <fpage>50</fpage>
          -
          <lpage>56</lpage>
          (
          <year>2004</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Horrocks</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Patel-Schneider</surname>
            ,
            <given-names>P. F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Boley</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Tabel</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Grosof</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Dean</surname>
            ,
            <given-names>M.:</given-names>
          </string-name>
          <article-title>SWRL: A semantic web rule language combining OWL and RuleML</article-title>
          . W3C Member submission,
          <volume>21</volume>
          (
          <year>2004</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Capadisli</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Guy</surname>
          </string-name>
          , Amy.:
          <article-title>Linked Data Notifications</article-title>
          . (
          <year>2017</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>The</surname>
            <given-names>OWL API</given-names>
          </string-name>
          , http://owlcs.github.io/owlapi, last accessed
          <year>2018</year>
          /7/17
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7. SWRLAPI, https://github.com/protegeproject/swrlapi, last accessed
          <year>2018</year>
          /7/17
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Whang</surname>
            ,
            <given-names>S. E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Garcia-Molina</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Brower</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Shanmugasundaram</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Vassilvitskii</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Vee</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          , &amp;
          <string-name>
            <surname>Yerneni</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          :
          <article-title>Indexing boolean expressions</article-title>
          .
          <source>Proceedings of the VLDB Endowment</source>
          ,
          <volume>2</volume>
          (
          <issue>1</issue>
          ),
          <fpage>37</fpage>
          -
          <lpage>48</lpage>
          (
          <year>2009</year>
          ).
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>