Connect to the ChatGPT API in Airtable with No-Code

Mar 8, 2023Andy Cloke

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 from OpenAI 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.

Set up output table

1. Create a table in Airtable if you don't already have one.

2. In the "Name" field, enter the names of the items you would like ChatGPT to create AI descriptions for.

3. Rename the "Notes" field to "Social post" (or add a new field). This is where we'll map the AI-generated social posts to.

name and social post fields.png

4. Create an Airtable Grid view called "Needs post" and add the following filters. This contains all the records that we want to process with ChatGPT.

  • The "Name'" field is not empty.
  • The "Social post field is empty.

needs post filtered view.png

Install Airtable ChatGPT connector

1. Add Data Fetcher to your base from the Airtable marketplace. Once it's been added, sign up for a free Data Fetcher account.

Data Fetcher Sign Up

2. Click Create your first request on the home screen. Creating requests in Data Fetcher enables you to import data into your Airtable base from any API.

create your first request logo 2 smaller.png

Connect to the ChatGPT API in Airtable

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

open ai application.png

You will need an OpenAI API key to use the ChatGPT API. You can create an API key in your OpenAI dashboard.

2. Under Authorization, paste in your OpenAI API key.

api key authorization.png

3. For the Endpoint, choose "Create chat message completion".

ChatGPT-Airtable-Integration5.jpg

4. Give your request a name, like "Generate Social Media Posts".

5. Click Save and Continue in the bottom right.

add name and click save and continue.png

6. The latest ChatGPT Model, GPT-4o, should be selected automatically.

gpt-4o model from openai.png

Specify messages for ChatGPT

Every message sent to ChatGPT needs a role. The roles are used for the following purposes: 

  • 'system' sets the behaviour / context of the assistant
  • ⁠'user' is the actual message you want to send
  • ⁠⁠'assistant' stores prior responses, for extra context. This isn't usually needed.

Data Fetcher lets you specify messages in this format: ⁠role:content.

If you don't specify a role, it will default to 'user'.

For our example, we will tell ChatGPT that it is a social media manager.

1. Copy and paste the following message into the Messages input and press Enter:

system: You are a social media manager

Then we need to add the user message, also known as the prompt. You can learn more about writing good prompts here.

2. Copy this message into the Messages input, but do not press Enter yet.

user: create an engaging social media post about a blog post with the following title. Do not include the blog title in the post:

Now we want to add a reference to the "Name" field in Airtable.

3. Click the + button on the right-hand side of the input.

chatgpt click + button in messages.png

4. On the window that opens, select "Name" for Field and "Needs post" for Run for every record in view.

5. Click Confirm to add the table reference.

name field reference.png

The message sent to ChatGPT will now have the blog post titled substituted in for each record when we run the request.

6. Press Enter again to finish adding the user message.

chatgpt social media messages.png

7. Click Save & Run in the bottom right.

The request will run and the Response Field Mapping modal will open. This is where you can map the fields from the ChatGPT API to those in your table.

8. Map the "Message" field to the "Social post" field, by clicking Existing field, and selecting the field in the dropdown.

9. Click Save & Run in the bottom right.

social media repsonse field mapping.png

Data Fetcher will now run the ChatGPT Airtable integration. Back in the default Grid view, you'll see that social media posts have been generated for each blog post using AI.

ai social media posts.png

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 Trigger feature.

1. Scroll to the Schedule | Trigger | Webhook URL tabs, select the Trigger tab, and click Upgrade.

schedule trigger webhook url tabs.png

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

3. Back in Data Fetcher, click I've done this.

trigger tab upgrade I-ve done this.png

Now you need to give Data Fetcher access to update your base.

4. Click + Authorize.

trigger tab authorize.png

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

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

6. Click Grant access.

schedule-authorize-bases.jpg

7. Back in Data Fetcher, under Trigger, choose the option to run the Airtable ChatGPT integration for Record created.

8. For the Table, select "Blog posts" and for the View select "Needs post".

social post chatgpt trigger.png

9. Click Save at the bottom of the screen.

Whenever a blog post is added in the "Needs post" view, a social media post will be created by OpenAI using ChatGPT.

Want to take it one step further? Check out this tutorial on using the OpenAI Assistants API in Airtable, or learn how to generate blog post images using AI.

Related Posts

How to Extract Data from Images in Airtable using AI

How to Extract Data from Images in Airtable using AI

Jul 25, 2024

Zayyad Muhammad Sani

OpenAI
Extract Data from PDFs to Airtable using OpenAI

Extract Data from PDFs to Airtable using OpenAI

Jul 18, 2024

Zayyad Muhammad Sani

OpenAIPDF
How to Use Airtable Generative AI

How to Use Airtable Generative AI

Jul 5, 2024

Andy Cloke

OpenAI