Drafts 37 or greater required for Airtable integration
Airtable is an online database service that allows you to create and maintain tabular data. Drafts integrates with Airtable through its API. The most common use of this integration is to create new rows in an Airtable from text captured in Drafts, for purposes like logging events.
The Airtable action step provides an easy-to-configure step to create a new record in a table in your Airtable account.
This step requires configuration. To get setup, follow these steps:
- Setup and configure a table you want to add to in your Airtable account. This action requires the table and fields already exist in Airtable.
- Install the Send to Airtable example as a starter, or create a new action and add an “Airtable” action step.
- Edit the action, tap on steps, then the “Airtable” step.
- Assign a base ID. You can select from your Airtable bases using the “Select” button or paste in a base ID you got from your Airtable account (learn about Airtable IDs).
- Assign a table ID or name. This can be the unique ID of a table or the exact (case-sensitive) name of a table in the base selected above.
- Configure field names and values. These names and values are configured using Drafts Templates, so you can put static text values or dynamic values provided by tags. Field names should be the exact (case-sensitive) names of existing fields in the table. There is no need to include all fields of a table; fields not included will get default values. See the next section for more details on fields and values, and the section after for a concrete example of how you might configure a step. The step can send up to five fields and values for a record (if you need more, see “Scripting” section below).
As database tables, Airtable tables are configured with fields with different data types – like text, rich text, dates, selects, etc. When the Airtable action step sends data to Airtable, it uses the API’s
typecast option, which tells Airtable to do the best it can to coerce values passed to fit the data type of the field.
When the action step is sending information to Airtable, it is sending text, so if you wish to send data to different field types, it’s important that your value is in a format that can be interpreted by Airtable. Some notes on common fields:
Single line text: Just text. No problem there. Typically you might do something like use the
[[title]]tag to set a field to the first line of the draft.
Long text: Long text fields can also take just plain text. If the field is configured to support rich text in Airtable, it will convert Markdown input to rich text, making headers bigger, bolding
**bold**markup, etc. (If the API is used to read these fields, it will also return a Markdown version).
Date: Airtable will successfully convert date strings in the ISO 8601 format to valid date field values. That format can be generated with Drafts’ tags using format strings. For example, to send the creation date of a draft to a date field in Airtable, use
- Single select: Will set the field to the text sent. If the value sent is not already one of the defined options for the field it will add that option in the field’s settings.
Multiple select: You can send a comma-separated list of values for this field. For example, if you want to send the tags you have assigned a draft, use the
[[tags]]template tag, and those tags will appear as multiple selected values in this field.
- Checkbox: If you want to create a record with a checkbox field already checked, send a “truthy” text value - like “true”, or “1”. Any other value or the absence of this field will result in an unchecked field.
Number: Best I can tell, Airtable will take any text passed to a number field, strip out any non-numeric characters, and try to make it a number. So, if you were to send a value like
1klk3, the number field would be set to
13, so be careful of your input.
Let’s say you are tracking your weight and have decided you want to log those values to a table in Airtable each time you weigh yourself - but you want to save the hassle of opening the Airtable app, finding the right table, and making the entry. You’d rather just launch Drafts and type your weight…then, either send it to Airtable right away or later. This demo video walks through a simple setup like logging.
For more advanced uses, Drafts provides access to the full Airtable API with the
Airtable script object. This object has convenience functions for a couple of common requests, like creating records, but also provides the
request function to make any API call desired. This opens up the ability to read, write, update records, perform queries, and more – while getting the convenience of Drafts taking care of the authentication and OAuth flow.
Details are beyond the scope of this article, but some sample actions below give you an idea of some of the possibilities.
- Airtable: Create Record: Show scripted creation of a record.
- Airtable: Import Records: Shows importing existing records from Airtable and creating a new draft with those values.
Integrating in this way connects directly to the API and does not use the credentials saved in Drafts for Airtable, so be sure to read the example action description for details on configuration.
If you have other things you would like to accomplish with Airtable and Drafts, let us know.