How to Use Airtable Generative AI

Jul 5, 2024Andy Cloke

In this tutorial, you'll learn how to use Airtable generative AI to create introductions and cover images for a table of blog posts.

What is Generative AI?

Generative AI is any AI tool that can produce content such as images, text, video, and audio when it receives input from a user. Generative AI models are trained with huge amounts of data (mostly human-generated). They learn the relationship between objects in their training data to produce similar content.

In this tutorial, we'll use OpenAI's GPT-4o and DALL-E 3 to generate introductions and cover images for blog posts in an Airtable base. To use these tools, we'll connect to OpenAI's API using the Data Fetcher extension for Airtable.

Setting up the Blog Posts Table

Before you can start using Airtable generative AI, you'll have to prepare the table you want to use. In this case, you'll set up the table to store blog post titles, cover images, and introductions.

Follow these steps to set up the table:

1. Create a table and name it "Blog posts", or use an existing table.

2. Add the following blog post titles to the Name field:

  • Tips for launching a book online
  • Getting started with non-fiction writing
  • 5 must-know grammar rules for writing
copy_blog_post_names.png

3. Rename the Notes field to Introduction.

4. Create a new Grid view called "Needs introduction" and add the following filters:

  • Name - is not empty
  • Introduction - is empty
needs_introduction_filters.png

The "Needs introduction" view will ensure we only generate introductions for blog posts that don't have any. Let's do the same for images.

5. Create a new field called Image with the type Attachment.

6. Create a new Grid view called "Needs image" and add these filters:

  • Name - is not empty
  • Introduction - is empty
needs_image_filters.png

With the table set up, we can move on to Data Fetcher.

Installing Data Fetcher

1. Add the Data Fetcher extension to your Airtable base. Data Fetcher lets us connect to third-party APIs, like OpenAI, without knowing how to code. This allows you to use the power of generative AI inside Airtable.

2. Once you’ve added the extension, sign in to Data Fetcher or sign up if you don’t have an account.

sign up for data fetcher.png

3. Once Data Fetcher opens in your Airtable base, click Create your first request.

create your first request logo 2 smaller.png

How to Use Airtable Generative AI

Generating Blog Post Introductions

1. Select OpenAI under Application. You can search for it or scroll down the list.

open ai application.png

2. Rename the request to something meaningful, like: "Generate blog post introductions".

rename_introductions_request.png

3. Copy and paste your API key under Authorization. If you don't have an API key, you can generate one in your OpenAI account.

api key authorization.png

4. Under Endpoint, select Create chat message completion.

ChatGPT-Airtable-Integration5.jpg

5. Click Save and Continue in the bottom right corner.

save_and_continue_introductions_request.png

You'll be taken to a new section where you'll give the AI instructions for what you want to generate.

Adding Prompts

OpenAI considers the prompts (instructions) we send as messages. Each message has the role of either system, user, or assistant. However, we're only concerned with the system and user roles in this article.

The system role tells the AI how to behave and respond to our prompts. Since our blog posts are about writing and books, we want the AI to respond like a writing and publishing expert. After we set the AI's role, we can send it a message (with the user role) instructing it to generate blog post introductions for us using data from the "Blog posts" table.

To set the system and user roles:

1. Under Messages, type/paste the following text and press Enter:

system: You are a writing and publishing expert

system_message_introductions_request.png

We'll add the prompt next. Since we'll use cell references in the prompt, we won't press Enter until we've added everything we need.

2. In the Messages field, under the system message, add the first part of the prompt (Data Fetcher will add the user role prefix to this message automatically):

Write a short introduction to a blog post with the title:

first_part_of_introduction_prompt.png

3. Click the + button to reference the "Name" field in the table.

add_reference_for_user_message.png

4. In the window that opens, select Name under Field, then select Needs introduction under Run every record in view.

insert_reference_window_introductions.png

5. Click Confirm.

6. Add the remaining half of the prompt to the Messages field and click Enter:

. Do not include the article title in the paragraph.

complete_message_introductions_request.png

TIP: Give the Airtable generativeAI detailed instructions in your prompts so it can produce more accurate content.

7. Click Save and Run in the bottom right corner.

Mapping Response Fields

After running the previous steps, Data Fetcher will take you to Response Field Mapping. On this page, you'll select the fields you want from the response data.

response_mapping_introductions_request.png

The request returns several fields, but we're only interested in the "Message" field.

Click the Existing field option under "Message", then select "Introduction" from the dropdown.

map_message_to_introduction.png

Click Save and Run in the bottom right corner.

Data Fetcher will populate the "Introduction" field with the text generated from OpenAI. Go back to the default grid view to see the changes.

introductions_generated_blog_posts_table.png

Generating Cover Images

We'll create a new request in Data Fetcher to generate the cover images.

1. In Data Fetcher, click Home in the bottom left corner to return to the homepage.

go_to_homepage_introductions_request.png

2. Click Create Request, then select OpenAI under Application.

3. Rename the request to "Generate cover images".

4. Under Endpoint, select Create an image from a prompt.

OpenAI-5.jpg

5. Click Save and Continue to proceed to the next section.

We'll now give the AI two instructions like we did earlier. Follow these steps:

1. Enter the following text under Prompt, then click the + button to reference the "Image" field in "Blog posts":

Create an artistic cover image for a blog post about this topic:

cover_image_prompt_and_add_reference.png

2. In the window that opens, select Name under Field, then select Needs image under Run for every record in view.

insert_reference_window_cover_images.png

3. Click Confirm.

4. Under Prompt, add the following instruction to complete the prompt:

. Do not add any text to the image.

complete_cover_image_prompt.png

You'll get more accurate images if you add more details and context to the prompt. DALL-E 3 understands properties such as position and colours.

5. Select DALL-E 3 under Model.

6. Select 1792x1024 under Size to get a landscape image.

select_model_and_cover_image_size.png

7. Under More options for this OpenAI endpoint, select Vivid under Style.

select_vivid_image_style.png

8. Click Save and Run in the bottom right corner to proceed to Response Field Mapping.

9. Make sure the Existing field option is toggled under "Image", then click Save and Run.

map_image_to_blog_posts_table.png

Once the request has run, check your default grid view to see the AI-generated images. You can click on each image to see it in full screen.

images_generated_blog_posts_table.png

The processes we followed for using Airtable generative AI to create text and images in our table are very similar, and we can summarize the key steps as follows:

  • Set up the table you want to add AI-generated content to.
  • Install Data Fetcher and create a new request with OpenAI as the application.
  • Authenticate with your OpenAI API key and select the action you want to perform.
  • Give the AI instructions to generate the content:
    • For text, enter the system and user messages.
    • For images, enter the prompt.
  • Configure the request with the other available settings.
  • Import the fields you want from response field mapping.
  • Run the request.

We hope you found this tutorial useful. Check out other posts on our blog to see how you can save time on Airtable with Data Fetcher.

Related Posts

Connect to the OpenAI API in Airtable with No-Code

Connect to the OpenAI API in Airtable with No-Code

Jun 25, 2024

Andy Cloke

OpenAI
How to use GPT-4o in Airtable with No-Code

How to use GPT-4o in Airtable with No-Code

Jun 17, 2024

Andy Cloke

OpenAI