Stardog and Zapier

Oct 10, 2018, 6 minute read
Stardog Newsletter

Get the latest in your inbox

We’re using Zapier with Stardog. Now you can, too.

At Stardog we use a number of third-party applications to make our lives a little easier. One problem we discovered, however, is that these applications often won’t talk to one another, and in some cases they don’t expose an API so that we can easily get them into our workflows without manual intervention. We came across Zapier, and have found it to be quite helpful with automating our workflows, and we decided that our users might want to get Stardog integrated into theirs!

Background

Zapier is a web application that allows users (both technical and non-technical) to create pipelines/workflows for their data to flow between hundreds of applications. These pipelines are referred to as “Zaps,” and they are made up of two different flavors of integration:

  • Triggers: Zapier polls a source application (or, in some cases, the source application pushes data to Zapier directly). Upon receiving new data, the Zap will begin.

  • Actions: Using data from an earlier step in the Zap, poll an application for specific data or push new data to an application

The Stardog integration into Zapier includes several of both of these. Let’s dive into the details.

Triggers

With triggers, your Zap will poll Stardog and kick off a run whenever a specific condition has been met. As of the initial implementation, we support the following triggers:

  • Database Created - When a new database (that the authenticated user can see) is created, this trigger returns a subset of its metadata, including name, creator, reasoning type, and size.
  • Document Added - Monitors a specific database for new documents loaded via BITES. Returns metadata about the file, including name, length, and MIME type, as well as the document itself as a stream.
  • User Created - Triggers when a new user is created on the server, returning the username, the user’s roles, and whether the user is enabled and/or a superuser.
  • New Named Graph - Monitors a specific database for data being added to a new context/named graph. Returns the URI of the graph.

Actions

Data doesn’t just flow from Stardog in Zapier. You can also take data provided by any of the above triggers, triggers from any other supported app, or intermediate results of actions earlier in the pipeline. As of the initial implementation, we support the following actions:

Searches

  • Find Database - Given a database name, retrieves its metadata.
  • Find Entity - Executes a SPARQL query against a chosen database with the goal of finding the URI of some entity in that database. Returns the first bound variable in the first binding that it finds, with the assumption that it is a URI.
  • Find SPARQL Binding - Executes a SPARQL query against a chosen database and returns every binding in the first returned binding set.
  • Find SPARQL Bindings - Executes a SPARQL query, however the return value is a blob of JSON/XML/CSV text containing the entire result set.

Creates

  • Add Data to Database - Adds a block of RDF data to the specified database or to a new database that can be named by the zap.
  • Add Document to Database - Adds a file to a database’s document store via BITES. File can either be a file streamed from an earlier action, a URL pointing to a file, or a block of text entered directly into the zap.
  • Execute SPARQL Update - Runs a SPARQL update query against a given database. Recommended for advanced users only, as data can be deleted this way.

Example Zaps

Gmail attachment to BITES

The first example use case is a simple Zap that monitors a Gmail inbox for emails with attachments that match specific criteria and automagically loads them into a Stardog BITES store for storage, metadata, NLP, etc. First, we set up the Gmail trigger:

Setup for Gmail attachment trigger

The next step is to choose the action we want the data from this trigger to flow into. Obviously, we want Stardog!

Stardog in list of apps

Finally, we need to set up our “Add Document to Database” action by populating the database name from the drop down (Zapier will reach out to the server to get the available databases) as well as the file name, which we choose from Step 1. Our options are then to send in a File object itself or a block of text. Since Gmail happily gives us the file with the Attachment key, we choose that.

Setup for Add Document action

Now we just turn our zap on and wait for it to run. Or, for the impatient, Zapier provides an option to manually run any Zap. Once it runs, we’ll see it in our task history:

Zapier task history

And we’ll also see the attachment in our database’s BITES store. Piece of cake!

✔ stephen:~ ➭ stardog doc count zapier
Count: 1 documents
✔ stephen:~ ➭ stardog doc get zapier myDoc.doc
Wrote document 'myDoc.doc' to file 'myDoc.doc'

New Stardog database to Google Sheets

Let’s say, for the sake of a contrived example, that I have a spreadsheet in my Google Sheets account that I use to keep track of Stardog databases. It’s nice and simple:

Google Sheet

I don’t want to have to keep this updated myself, and why should I when Zapier can do it for me? I’ll create a database to test it out:

New Zapier database

In a new Zap, I set up my Stardog trigger and Google Sheets action (pulling values from the trigger):

Database Trigger Sheets Action

After my zap runs, sure enough, there’s a new row with my new database:

New Google Sheet

Multi-step Zaps

Trigger->Action may be the most common type of Zap, but you can combine multiple actions to do some pretty powerful stuff. For example, what if when we added a document to BITES we also wanted to store it in a Dropbox account, and then put metadata from that Dropbox file back into Stardog? We can absolutely do that.

Overall 3-step zap

We just need to add an action after the Dropbox action that massages the metadata into a block of RDF:

Metadata Trig

And once it runs, we can see the data in Stardog alongside the metadata Stardog extracted:

3-step Results

Future plans

This work represents a minimal suite of what we’d like to implement with Zapier. Going forward we plan to listen to user feedback to implement triggers and actions that people find necessary. We’d also love to write up some transformation tools from <insert data type here> to RDF, so that Zaps like the Dropbox one above are a little easier to pull off without needing to create RDF manually.

Conclusion

Hopefully this post has piqued your interest in Stardog’s integration with Zapier. At the time of this writing, the zapier app has not gone publicly available, however this early-access page will allow your account to access it and play around. Let us know what you think!

Download Stardog today to start your free 30-day evaluation.

download our free e-guide

Knowledge Graphs 101

How to Overcome a Major Enterprise Liability and Unleash Massive Potential

Download for free
ebook