# Airtable

{% hint style="info" %}
The following documentation is for **Airtable v2.0.0** *(BDK)*.
{% endhint %}

## Overview

Airtable is a database platform that works like a spreadsheet. This integration allows you to create records, sync data, and manage workflows in your Airtable bases.

## Prerequisites

### 1. Required Books

The following Book(s) need to be added to your agent so it can learn and understand the automation procedures defined within them:

* **Airtable**

#### How to Add the Book(s)

1. Go to **Books** → **All Books**.
2. Search for the name of the book and click on it.
3. Click on <kbd>**Install**</kbd> or <kbd>**Add Connection**</kbd> to add the book to your agent.
4. If adding a connection, you'll be prompted for [**connectivity**](#connectivity) details.

## Connectivity

This section outlines the available methods for connecting to the Book, along with the required configuration details for each.

### Connect using personal access token

Connects using a Personal Access Token from Airtable.

| Label                 | Description                | Type        |
| --------------------- | -------------------------- | ----------- |
| personal access token | The Personal Access Token. | `sensitive` |

## Procedures

### to create a record in a (table)

Creates a new record in a table

**Input Concepts**

| Concept                    | Description                                               | Type             | Required | Default Value |
| -------------------------- | --------------------------------------------------------- | ---------------- | -------- | ------------- |
| [`table`](#airtable-table) | The Airtable table to get records from                    | `airtable table` | Yes      | (no default)  |
| `record data`              | A dictionary with the fields and values of the new record | `json`           | Yes      | (no default)  |

**Output Concepts**

| Concept                     | Description              | Type              |
| --------------------------- | ------------------------ | ----------------- |
| [`table`](#airtable-record) | the newly created record | `airtable record` |

**Examples**

Create a record in a table

```generic
get a table from the bug tracker base whose name is "Bugs"
use the above as the bugs table
>>>
the string is '{"Title": "New Bug found"}'
get the string as json
use the above as the new bug
>>>
create a record in the bugs table
    the record data is the new bug
```

### to get some (base's tables)

![FILTER - CAPABLE](https://img.shields.io/static/v1?label=FILTER\&message=CAPABLE\&color=blue)

Gets a list of all tables from a specific base

**Input Concepts**

| Concept                  | Description                          | Type            | Required | Default Value |
| ------------------------ | ------------------------------------ | --------------- | -------- | ------------- |
| [`base`](#airtable-base) | The Airtable base to get tables from | `airtable base` | Yes      | (no default)  |

**Output Concepts**

| Concept                            | Description      | Type             |
| ---------------------------------- | ---------------- | ---------------- |
| [`base's tables`](#airtable-table) | A list of tables | `airtable table` |

**Examples**

Get all tables from a base

```generic
get the base whose name is "Bug Tracker"
use the above as the bug tracker base
>>>
get the bug tracker base's tables
```

Get a single table from a base

```generic
get the base whose name is "Bug Tracker"
use the above as the bug tracker base
>>>
get a table from the bug tracker base whose name is "Bugs"
```

### to get some (bases)

![FILTER - CAPABLE](https://img.shields.io/static/v1?label=FILTER\&message=CAPABLE\&color=blue)

Gets a list of all bases

This procedure can get a list of all bases, as well as getting a single base filtering by its name or id.

**Output Concepts**

| Concept                   | Description     | Type            |
| ------------------------- | --------------- | --------------- |
| [`bases`](#airtable-base) | A list of bases | `airtable base` |

**Examples**

Get all bases

```generic
get some bases
```

Get a single base by name

```generic
get a base whose name is "Bug Tracker"
```

### to get some (table's records)

![FILTER - CAPABLE](https://img.shields.io/static/v1?label=FILTER\&message=CAPABLE\&color=blue)

Gets a list of all records from a specific table

**Input Concepts**

| Concept                    | Description                            | Type             | Required | Default Value |
| -------------------------- | -------------------------------------- | ---------------- | -------- | ------------- |
| [`table`](#airtable-table) | The Airtable table to get records from | `airtable table` | Yes      | (no default)  |

**Output Concepts**

| Concept                               | Description             | Type              |
| ------------------------------------- | ----------------------- | ----------------- |
| [`table's records`](#airtable-record) | A list of table records | `airtable record` |

**Examples**

Get all records from a table

```generic
get a table from the bug tracker base whose name is "Bugs"
use the above as the bugs table
>>>
get the records from the bugs table
```

Get a single record from a table

```generic
get a table from the bug tracker base whose name is "Bugs"
use the above as the bugs table
>>>
get the records from the bugs table whose Severity is "High"
```

## Concepts

### Airtable table

Represents an Airtable table.

| Field Name    | Description                                              | Type             |
| ------------- | -------------------------------------------------------- | ---------------- |
| `id`          | The unique identifier of the table.                      | `text`           |
| `base_id`     | The unique identifier of the base containing this table. | `text`           |
| `name`        | The name of the table.                                   | `optional[text]` |
| `description` | Optional description of the table.                       | `optional[text]` |

### Airtable record

Represents an Airtable record. A record is a row of a table.

| Field Name | Description                                         | Type   |
| ---------- | --------------------------------------------------- | ------ |
| `id`       | The unique identifier of the record.                | `text` |
| `fields`   | Dictionary containing the field data of the record. | `json` |

### Airtable base

Represents an Airtable base. A base is a collection of tables.

| Field Name | Description                        | Type             |
| ---------- | ---------------------------------- | ---------------- |
| `id`       | The unique identifier of the base. | `text`           |
| `name`     | The name of the base.              | `optional[text]` |
