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.
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:
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.")
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:
(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.)
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.
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.
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.
For Application, select 'OpenAI' to use the ChatGPT Airtable integration.
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.
For Endpoint choose 'Create chat message completion'.
Give your request a name such as 'Create Social Media Posts' and click 'Save and Continue.'
On the next screen, for Model use 'gpt-3.5-turbo' (this is the default).
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:
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.
On the modal that opens, select your output Table. Then select 'Prompt' for Field and 'Needs Info' for Run for every record in view.
Click 'Save & Run'.
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'.
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.
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'.
Choose a plan from the different options depending on your needs and enter your payment details.
In Data Fetcher, click 'I've done this'.
Under Schedule click '+ Authorize'.
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'.
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'.
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.