Librarian

Number of APIs: 3

Librarian is a Qodex collection that allows you to use Slack to check the availability of a book in your office library. In this case, we are searching for the book using a Slack app, and also storing the books that we have in the Qodex office using Airtable as a database.

GIF of searching in slack

Review the collection documentation for more details.

Search in Slack

You can search for your book by typing /bookbug [book-name] in Slack. No switching applications or learning a new UI!

Image of searching in slack

  • If the book is up for grabs, you will see the details of the book - Image of book available

  • If the book is with someone, you will know who is reading it currently- Image of currently reading

  • If the book is unavailable, well, it is time to buy a new book - Image of unavailable


How it works

When you type /bookbug [The Hobbit] in Slack and hit enter, the message (and its data) is sent to the configured external URL (Qodex monitor url in our case) via HTTP POST. The monitor starts the Librarian collection run.

Image of how it works

Getting Started

Create an Airtable base (database)

Create an Airtable base with the schema similar to this base. Airtable provides a nice graphical interface to add entries to the base. You can also click on Copy base on the top right of this base to create a copy for yourself. We will use the Airtable API to query this base.

Create a Slack app (frontend)

Log in to your team Slack account and create a Slack app. Then activate and configure a slash command and install this app to your Slack workspace. You will need to enter the Qodex monitor URL which we will create below in the Request URL text box.

Run in Qodex

Click the orange Run in Qodex button to import the sample collection and environment template into your Qodex app. Before you can run the Librarian collection, you need to update the Librarian.template environment you downloaded with the Run in Qodex button. Add appropriate values to the variables:

Environment Variable NameDescription
airtable_api_keyAn Airtable API Key.
airtable_urlRequest url. Select your base from here. Each base can contain multiple tables, so you will have to navigate to your specific table in the left sidebar. The airtable_url will be the curl in the Example Request for Retrieve a record. Image of airtable_url

Create a Qodex monitor

There are currently 2 ways to run a Qodex monitor on-demand. You can manually run a monitor from the Qodex web dashboard, or you can use the Qodex API to run a monitor, but these methods don't allow you to send a payload. This on-demand Qodex monitor - which functions like a webhook - will receive the payload sent by Slack and start the Librarian collection run.

Note: Qodex webhooks are still under development, and not yet recommended for commercial use.

  • Generate an API key from the integrations dashboard to access the Qodex API.
  • Retrieve all your collections by sending a GET request to https://api.getQodex.com/collections, and don't forget to add the x-api-key header using your Qodex API key. Find (CMD/CTRL + F) the Librarian collection in the response and make a note of the uid field. This is your collection ID.
  • Retrieve all of your environments by sending a GET request to https://api.getQodex.com/environments, and don't forget to add the x-api-key header using your Qodex API key. Once again, find (CMD/CTRL + F) the Librarian collection in the response, and make a note of the uid field. This is your environment ID.
  • Now, let's create a Qodex webhook. Create a new POST request to https://api.getQodex.com/webhooks, again adding the x-api-key header. For the body, select raw, change the type to JSON, and add the example body below. Send the request, and copy the webhookUrl from the response. We will use this webhookUrl in the Slack app configuration as the Request URL, essentially telling Slack to run the Qodex monitor when the Slack command is triggered.

Webhook body

  1. Retrieve a record GET {{airtable_url}}/{{record_id}}

  2. Post to slack (unavailable) POST {{response_url}}

  3. Get list of all books GET {{airtable_url}}