Stuart Lansdale

Creating Lists in Slack with Airtable!

I recently started to use Airtable after my previous database provider – Fieldbook declared that they would be ceasing operations from mid June. This has been somewhat of a bittersweet experience as I had to port all of our data over to a new provider and update all the integrations that we had. Zapier tells me that was about 60 zaps that we had to change so that was not ideal. 

Airtable was something that came recommended however so I decided to give it a go and see what could be done with Zapier. One of the reasons that we used Fieldbook was that you could search with multiple fields to find a record. Airtable doesn’t have this function as per say but they do let you search with a formula which does make it possible. Glad that we could solve that nice and quickly!

The next thing I wanted to do was see if I could find a way to list records. I like to use Slackfor creating ‘command lists’ which then can open up a menu of commands. You can see an example of such here in our FAQ list for approaching new properties for Roomfilla.

As you can see we have the list of fields which are from the FAQ and if you type FAQ Registration then it will pop up the information that you have requested. Building such functionality into Slack is relatively simple but not easy. For a demo of getting this done, I want to be able to list some websites in another channel so let’s get cracking.

First I will need to create a trigger, for this I’ll use the words ‘website list’. I will put this into the channel I want it to trigger, in this instance #sales and then go to Zapier to create the Zap. 

So this is pretty basic. The trigger is the message into the #sales channel and then a filter ensures it only runs if the text exactly matches ‘website list’. That is all good! Now we need to find the data in Airtable. The Airtable API docs are pretty easy to understand but there are a few things which you need to know when you start pulling stuff into Zapier. 

You can see here, the documents for the list records from Airtable themselves. To do this we want to send a webhook and here are a few things that helps to make it work in Zapier which I had to get help with from the support due to not knowing!

  • You should use the URL without any of the fields appended to it. In this image you see that max records and view are appended to it so you want to take them out. 
  • This is an important one. For some reason you need to put in a header field, User-Agent = null. The webhook won’t work without this and this was something I needed support to troubleshoot for me. 
  • Obviously you’ll need your API key which you can find by ticking the box in the top right of the image above. 

With this I have the URL and I am adding to show the grid view which is the spreadsheet style view. Below this I have the header fields where I have User-Agent = null and Authorization = Bearer API KEY. If you want to only return a few fields, you can use maxRecords in the query string params to do that. I want to return all so let’s test it. 

The test works but it returns everything like value1,value2,value3,value4. That doesn’t look so great but it is a simple fix with a few lines of javascript. The next stage of the Zap is a code by Zapier section. 

What this code does is it prepends the first record by a dash and a space and then adds a linebreak dash and space to each of the remaining records. Super simple and gets you the data in a way that you can then push to Slack. The final action is therefore a Slack action where you make a message in the same channel with the data. 

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts
Blog Updates