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.
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!
If the book is up for grabs, you will see the details of the book -
If the book is with someone, you will know who is reading it currently-
If the book is unavailable, well, it is time to buy a new book -
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.
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 Name | Description |
---|---|
airtable_api_key | An Airtable API Key. |
airtable_url | Request 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 Requestfor Retrieve a record. ![]() |
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 tohttps://api.getQodex.com/collections
, and don't forget to add thex-api-key
header using your Qodex API key. Find (CMD/CTRL + F) theLibrarian
collection in the response and make a note of theuid
field. This is your collection ID. - Retrieve all of your environments by sending a
GET
request tohttps://api.getQodex.com/environments
, and don't forget to add thex-api-key
header using your Qodex API key. Once again, find (CMD/CTRL + F) theLibrarian
collection in the response, and make a note of theuid
field. This is your environment ID. - Now, let's create a Qodex webhook. Create a new
POST
request tohttps://api.getQodex.com/webhooks
, again adding thex-api-key
header. For the body, selectraw
, change the type toJSON
, and add the example body below. Send the request, and copy thewebhookUrl
from the response. We will use thiswebhookUrl
in the Slack app configuration as theRequest URL
, essentially telling Slack to run the Qodex monitor when the Slack command is triggered.
-
Retrieve a record GET {{airtable_url}}/{{record_id}}
-
Post to slack (unavailable) POST {{response_url}}
-
Get list of all books GET {{airtable_url}}