In this guide, we'll demonstrate how to use AI with Airtable by linking the GPT-4 API to Airtable. We'll use AI and Airtable to generate various descriptions for online courses. We'll also be using the free Airtable extension Data Fetcher, which means there is no need for code.
GPT-4 is the latest AI language model developed by OpenAI and is different to ChatGPT. You'll need to have a card set up for payments for the OpenAI API. This is a different service to ChatGPT Plus.
Airtable is also releasing its own AI, which is currently in the beta stage. Once it's out of the trial phase, this will be released as an optional paid add-on.
First, create a table called 'Courses' in an Airtable base. This is where we'll generate our AI content.
In the primary 'Name' field, enter these titles course titles:
(Or feel free to use your own.)
Create a new field called 'Prompt' with type 'Formula' and then copy and paste the follwing code into the Formula field:
CONCATENATE("user:Write an encouraging and interesting description for an online course with the title '",Name, "''. Do not include the course title.")
Click 'Create field'.
For some additional help on writing prompts for AI, you may find these these basic tips and instructions for writing good prompts for OpenAI useful.
Create a field in your Airtable 'Courses' table called 'Description' with a type of 'Long text'. This is where our AI-generated text will appear.
Create another new field in your Airtable table called 'Description (formatted)' with type 'Formula' and copy and paste the following code into the Formula field:
SUBSTITUTE({Description},'"','')
(By adding this formula, we are solving an occasional issue where the AI output from GPT-4 starts with a speech mark, consequently causing errors.)
Now you'll need to create a Grid view in your table called 'Needs description' with these conditions (The conditions are set using the 'Filter' menu);
The 'Name' field is not empty.
The 'Description' field is empty.
To use AI in Airtable, we're going to install Data Fetcher from the Airtable marketplace. You'll need to either sign up for a free Data Fetcher or log into an existing one.
Data Fetcher requests enable you to fetch and import data from various sources, such as websites or APIs, into Airtable. In this case, we are using Data Fetcher to connect to OpenAI in Airtable.
Click on 'Create your first request' on the home screen of Data Fetcher.
Under Application, select 'OpenAI'.
Under Authorization, copy and paste your OpenAI API key.
Under Endpoint select 'Create chat message completion'.
Give your request a name such as 'Create Course Descriptions'.
Click 'Save and Continue.'
Select the 'gpt-4' Model.
Click the + button next to Messages to add a reference to the prompt we specified in the Airtable table using the formula in the prompt field.
To find out more about how you can use messages in AI, we recommend reading more about how OpenAI prompts work here.
Next, Select your output Table, 'Description' for Field and 'Needs description' for Run for every record in view.
Click 'Confirm'.
Your parameters should look like this. Click 'Save & Run'.
The Response field mapping modal will now open. Set the 'Message' field to map to the 'Description' field in your output table and click 'Save & Run'.
The AI course descriptions will now be generated and added to your Airtable table in the 'Description field'.
Currently, we'd have to run the Data Fetcher request each time we added a new course title to Airtable in order to create the AI description.
However, using Data Fetcher's Trigger feature, it's easy to automatically generate AI text in Airtable.
Triggers let you automatically run a request whenever a change is made to an Airtable record. For example, when a new record is created, updated or deleted.
Triggers are a paid Data Fetcher feature, so you'll need to upgrade your account. Scroll to the tabs that say Schedule / Trigger / Webhook URL and click on the Upgrade button underneath.
Select a plan to suit you and enter your payment details.
In Data Fetcher, click 'I've done this'.
Next, select the 'Trigger' tab and underneath, click '+ Authorize'.
Accept the prompt 'I understand, let's Authorize'.
Click '+ Add a base'.
By selecting 'All current and future bases in all current and future workspaces', we'll avoid the need to re-authorize access for individual bases in the future.
Click on 'Grant access'.
Back in Data Fetcher, ensure the Trigger tab is selected. For this tutorial, we'll use the trigger type of 'Record created' (meaning the request will be triggered every time a new record is created.) Then select your 'Courses' table and the 'Needs description' view.
Click 'Save'.
Now, every time you add a new course title to Airtable, the Data Fetcher request will trigger, and a new AI text description will be generated and added to the 'Description' field.
Jul 25, 2024
•Zayyad Muhammad Sani
•OpenAIJul 18, 2024
•Zayyad Muhammad Sani
•OpenAIPDFJul 5, 2024
•Andy Cloke
•OpenAI