Home / All Integrations / Airtable

free

Connect Airtable to your chatbot

Use Airtable as a database


In order to use this library, you need to create an account on airtable, free accounts provide sufficient rights to use the API and are good enough to get started.

Rate limit
The API is limited to 5 requests per second per base. If you exceed this rate, you will receive a 429 status code and will need to wait 30 seconds before subsequent requests will succeed.

IMPORTANT
Once you have created your first spreadsheet, you will need the spreadsheet API ID and the table name.

To find them:

do records = App(
  "airtable",
  spreadsheet_id="MY_SPREADSHEET_ID",
  table_name="AN_AWESOME_TABLE",
  method="getRecords"
)

Usage

The target spreadsheet ID and table name must be passed to all functions.

Create a new record

A record on airtable is similar to a row in excel. To create a new record, simply pass to the function an object with the fields and values as follows:

  • You can select which fields you would like with the fields parameter.
  • Formulas are to be passed in the filterByFormula parameter. Here we get all the rows that have a field job not empty:
do fields = {
  "firstname": "Bastien",
  "email": "bastien@csml.dev",
  "job": "COO"
}
do newRecord = App(
  "airtable",
  method="createRecord",
  spreadsheet_id="MY_SPREADSHEET_ID",
  table_name="AN_AWESOME_TABLE",
  fields=fields
)

Create several new records

do records = [
  {
    "firstname": "Bastien",
    "email": "bastien@csml.dev",
    "job": "COO"
  }, {
    "firstname": "François",
    "email": "francois@csml.dev",
    "job": "CTO"
  }
]
do newRecords = App(
  "airtable",
  method="createRecords",
  spreadsheet_id="MY_SPREADSHEET_ID",
  table_name="AN_AWESOME_TABLE",
  records=records
)

Get records

You can get an array of records from Airtable, and you can also pass a query to filter the rows.
More information about Airtable formulas: https://support.airtable.com/hc/en-us/articles/203255215-Formula-Field-Reference

do fields = ["firstname", "email"]
do filterByFormula = "NOT({job} = '')"
do sort = {"field": "firstname", "direction": "asc"}
do records = App(
  "airtable",
  method="getRecords",
  spreadsheet_id="MY_SPREADSHEET_ID",
  table_name="AN_AWESOME_TABLE",
  fields=fields, // optional
  sort=sort, // optional
  filterByFormula=filterByFormula, // optional
)

Update a record

You can update a record by sending the updated version of the specific record returned by the getRecords method.
This updated object should include the Airtable internal record id that you'll get with the getRecords method.

// Let's use the `records` variable set above and edit the first record of the array
do record = records[0]
do record.firstname = "François"
do records = App(
  "airtable",
  method="updateRecord",
  spreadsheet_id="MY_SPREADSHEET_ID",
  table_name="AN_AWESOME_TABLE",
  record=record
)
Discover similar integrations:
Amazon Dynamodb
Firebase
MongoDB
MySQL
Notion
PostgreSQL

Join the Community
on Slack Slack

Come and learn all about CSML with other chatbot enthusiasts on the CSML Community Slack! 🤗