Get data filtered from Airtable with a Brick- Shop example
In this article we will see how to use Airtable as our "live" database from where getting data to feed our bot. The Airtable spreadsheet can be easily updated adding more rows or editing cells.
For this example we have the following scenario:
- We have 2 sets of filters, always the same (not dynamic):
- 1st filter: User chooses one option among: Table, Chair or Window
- 2nd filter: All three options (table, chair and window) can be of three colors: Blue, Red or Green
- Every search is going to bring only 1 result (price)
This is the base that we will use and the one in the Brick
How to get the Brick
Simple click on the Bricks icon, select Explore Bricks and write "Airtable"
How it looks in the builder
Once you have exported the brick and click to edit it this is how it looks inside:
How to set it up
- In Airtable, we are using this sample data, and is the one we will use to filter and find out the price. It's important to know that the filter is case sensitive
- In the Brick, we select the filter elements as below. In the first group we store Table, Window or Chair in the variable @product and Red, Green or Blue in the variable @Color:
- The filter formula is based on Airtable documentation. In this case what we are doing is "telling" to find a row where the Column Color matches the value in our variable @color AND that at the same time in the column Product matches the value of the variable @product:
- The Webhook is already filled with sample data so you can use it, but eventually you will need to adapt it to your base in Airtable
In this case is filled with data like the Url, Header and Save response that you will need to adapt to your needs. The formula will be already set in the prior section.
- To store the value (in this case the price) you need first to make a Test first with "dummy data" so you can use a sample response to indicate "where" will be located the value that you want to store in a Landbot variable (in this case price)
It's very important that after using the "dummy values" in the Params section and once the test is done and the Save response set up, we return the Params section to the original state where it works with dynamic variables and not static values. Like below:
- After the webhook, we will be able to display variable with the value that we wanted to filter and display (in this case price)
How to get Airtable's App ID and API Key
Get the App ID in Airtable to build the Webhook's URL
In this example the Brick is using the following url: https://api.airtable.com/v0/appfQ7NnSyo70Z5E8/Imported%20table
Here are 2 parts:
- The Base we are using is called Imported Table, so the end of our url is : Imported%20table
- The Base App Id is appfQ7NnSyo70Z5E8 To get the App ID for your base follow these steps:
- First, get to the API docs for your base, by pressing in HELP and selecting API Documentation
- Copy this part of the URL from the API docs.
Your APP ID is the long string immediately after “airtable.com/” and before “/api/” in the url of this page.
Get the API Key to set up Webhook's Header (Authorization)
To get an Airtable API Key, repeat the same process to get to the API Documentation, but this time click
Then below the place where you located the APP ID you will see the API KEY, after "Authorization:"
Please copy from "Bearer" to the end of the text.