Connect to the ChatGPT API in Airtable with No-Code

Mar 8, 2023Rosie Threlfall

In this tutorial, we'll run through the steps involved in connecting to the ChatGPT API in Airtable. To demonstrate this process, we'll use AI to create social media posts for a list of blog posts.

ChatGPT is an AI model which produces human-like text using deep learning technology.

The ChatGPT Airtable integration can be used for free, and there's no need for code.

Create Blog Posts Table

In your Airtable base, create a table called 'Blog Posts'.

In the primary 'Name' field, enter the names of the blog posts you would like ChatGPT to create AI descriptions for. You can enter the following examples or choose your own:

  • How to Clean Your Running Shoes—and Tread More Lightly on the Planet
  • ⁠Maximum Mileage: 12 Easy Ways to Extend the Life of Your Running Shoes
  • ⁠How to Work Out From Home: 5 Easy Workouts.
ChatGPT-Airtable-Integration.jpg

Create a field called 'Prompt' with type 'Formula' and add the following formula:

CONCATENATE("user:create an engaging social media post about a blog post with the title '",Name, "''. Do not include the blog post title.")
ChatGPT-Airtable-Integration2.jpg

Please note: The exact words you use for the prompt are essential for ensuring you achieve your desired results. Please read these basic tips and instructions for writing good prompts for OpenAI

Create a field called 'Social post' with type 'Long text'. This is where we'll map our AI output to.

Create another field called 'Social post (formatted)' with type 'Formula' and add the following formula:

 SUBSTITUTE({Social post},'"','')

(This is to avoid any issues with speech marks being used in error as occasionally, the output from ChatGPT may start with a speech mark.)

ChatGPT-Airtable-Integration3.jpg

Create a new Grid view called 'Needs Info' and add the following conditions (conditions are created using the 'Filter' menu option);

  • The 'Name' field is not empty.

  • The 'Social post' field is empty.

ChatGPT-Airtable-Integration4.jpg

Add Data Fetcher to Airtable

Add Data Fetcher to your Airtable base via the Airtable marketplace. Sign up for a Data Fetcher account by entering a password and clicking 'Sign up for free'. Alternatively, you can use your Google login to create a new account. If you already have a Data Fetcher account use the 'Have an account?' text in the bottom left of the screen to log in.

Data Fetcher is a powerful Airtable extension that can be used to import different types of data from APIs or websites into Airtable.

Data Fetcher Sign Up

Connect to the ChatGPT API in Airtable

Creating requests in Data Fetcher enables you to import data into your Airtable base. To begin, click 'Create your first request' on the home screen of the Data Fetcher extension.

Create your first request in Data Fetcher

For Application, select 'OpenAI' to use the ChatGPT Airtable integration.

Generate Company Descriptions with GPT3

If you don't already have an account with OpenAI, you can sign up for one here and generate an OpenAI API here. (You'll need an API key from OpenAI to connect ChatGPT to Airtable.)

With every new OpenAI account, you receive $18 worth of credit. This is plenty for this tutorial. But if you plan to use OpenAI once this has run out, you will need to upgrade your account for more credit.

For Authorization, copy and paste your OpenAI API key.

Generate Company Descriptions with GPT3

For Endpoint choose 'Create chat message completion'.

ChatGPT-Airtable-Integration5.jpg

Give your request a name such as 'Create Social Media Posts' and click 'Save and Continue.'

ChatGPT-Airtable-Integration6.jpg

On the next screen, for Model use 'gpt-3.5-turbo' (this is the default).

ChatGPT-Airtable-Integration7.jpg

Specify a Message for the ChatGPT Input

Messages are used as the input for ChatGPT. They give the AI assistant context to use for the completion (in this case to help it generate meaningful social media posts). 

Messages consist of separate objects, each with a role (either 'system', 'user', or 'assistant'). The roles are used for the following purposes: 

  • 'system' sets the behaviour of the assistant
  • ⁠'user' helps instruct the assistant
  • ⁠⁠'assistant' helps store prior responses

We also need to specify 'content', which contains the content of the message we want to send to the AI assistant.

Data Fetcher enables you to specify the messages in this format: ⁠role:content ⁠⁠(if you don't specify a role, it will use the default to the 'user' role.)

You can find further information on how the messages work here.

For our example, we are telling the AI assistant that its role is a social media manager, so we can copy and paste the following line into the Messages box and hit return.

system:You are a social media manager

Next, click the + button next to it and add a reference to our output table.

ChatGPT-Airtable-Integration10.jpg

On the modal that opens, select your output Table. Then select 'Prompt' for Field and 'Needs Info' for Run for every record in view.

ChatGPT-Airtable-Integration8.jpg

Click 'Save & Run'.

ChatGPT-Airtable-Integration13.jpg

The Data Fetcher request will run, and the Response field mapping modal will open.

Set the 'Message' field to map to your existing 'Social post' field and click 'Save & Run'.

ChatGPT-Airtable-Integration11.jpg

Data Fetcher will now run the ChatGPT Airtable integration and in your output table, you'll see that social media posts relating to each blog post title have been generated using AI and added to the 'Social post' field.

ChatGPT-Airtable-Integration12.jpg

Automatically Run the ChatGPT Airtable Integration

Currently, you'd need to manually run the request each time you want to create any new social media posts for any new blog post titles. However, you can automatically run the ChatGPT Airtable integration on a chosen schedule using Data Fetcher's paid scheduling feature.

To upgrade your account, In Data Fetcher, scroll to Schedule and click 'Upgrade'.

schedule options

Choose a plan from the different options depending on your needs and enter your payment details.

data fetcher upgrade pricing plans.png

In Data Fetcher, click 'I've done this'.

Schedule Data Fetcher

Under Schedule click '+ Authorize'.

Schedule Data Fetcher

A window will open where you'll be prompted to authorize the Airtable bases you want Data Fetcher to have access to.

We recommended selecting 'All current and future bases in all current and future workspaces' to avoid needing to unauthorize bases in the future.

Click 'Grant access'.

schedule-authorize-bases.jpg

In Data Fetcher, you'll see Schedule this request is now toggled to on.

Select a schedule for the OpenAI Airtable integration to run. You can choose intervals of 'Minutes', 'Hours', 'Days' or 'Months', then click 'Save'.

Schedule this request

Now, if you make any additions to the companies in your table, descriptions will be created by OpenAI using ChatGPT and imported into Airtable automatically on your chosen schedule.

Related Posts

How to Use AI in Airtable (2023)

How to Use AI in Airtable (2023)

Sep 15, 2023

Rosie Threlfall

OpenAI
Connect to the GPT-4 API in Airtable with No-Code

Connect to the GPT-4 API in Airtable with No-Code

May 11, 2023

Rosie Threlfall

OpenAI