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.
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.
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 "Social post field is empty.
1. Add Data Fetcher to your base from the Airtable marketplace. Once it's been added, sign up for a free Data Fetcher account.
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.
1. For Application, select "OpenAI" to use the ChatGPT Airtable integration.
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.
3. For the Endpoint, choose "Create chat message completion".
4. Give your request a name, like "Generate Social Media Posts".
5. Click Save and Continue in the bottom right.
6. The latest ChatGPT Model, GPT-4o, should be selected automatically.
Every message sent to ChatGPT needs a role. The roles are used for the following purposes:
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.
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.
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.
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.
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.
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.
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.
Now you need to give Data Fetcher access to update your base.
4. Click + Authorize.
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.
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".
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.
Jul 25, 2024
•Zayyad Muhammad Sani
•OpenAIJul 18, 2024
•Zayyad Muhammad Sani
•OpenAIPDFJul 5, 2024
•Andy Cloke
•OpenAI