Loading
Loading
  • Home

  • Automation with Zapier

  • Zapier tutorials

Zapier tutorials

7 min read

How to generate blog images with DALL·E and Zapier

By Michael Toth · April 13, 2023
The OpenAI logo connected to the Zapier logo on a light purples background.

Creating visually appealing content has become critical to any successful online presence. But the process of finding the right images to accompany your blog articles or social media posts can be time-consuming, frustrating, and even expensive. Fortunately, Zapier users can now take advantage of the powerful image generation capabilities of OpenAI's DALL·E to simplify this process.

With the help of Zapier's integrations with DALL·E and Airtable, users can quickly generate unique and high-quality images for their blog articles by simply entering a description of the desired image. This innovative approach saves time and eliminates the need to search for suitable stock photos online.

In this tutorial, we'll guide you through making a Zap—Zapier's automated workflows—to create stunning visuals for your blog articles. Whether you're a blogger, marketer, or content creator, this approach is sure to take your visual content game to the next level.

New to Zapier? It's workflow automation software that lets you focus on what matters. Combine user interfaces, data tables, and logic with 6,000+ apps to build and automate anything you can imagine. Sign up for free.

How it works

For this project, we'll use Airtable to store details for all of the images for our blog. In total, our Zap has 4 steps:

  • Trigger: New or Updated Record in Airtable

  • Action: Filter to eliminate unwanted runs and infinite loops

  • Action: Send a prompt to OpenAI's DALL·E to generate an image

  • Action: Send a response back to Airtable with the generated image

A Zap in the Zap editor with four steps.

You can create your own Zap from scratch without any coding knowledge, but we also offer quick templates to get you started.

If you'd like to start with a template, click on the Zap template below to go to the Zap editor. You'll need to create a Zapier account if you don't already have one. Then, follow the directions below to set up your Zap.

Create images with DALL-E for new Airtable records

Create images with DALL-E for new Airtable records
  • Airtable logo
  • Airtable logo
Airtable + Filter by Zapier + OpenAI (GPT-3, DALL-E, Whisper)

This workflow requires a multi-step Zap, which is available on a paid Zapier plan or during a free trial. Learn more about multi-step Zaps.

Before you begin

Before we begin developing our Zap, you'll need an OpenAI account if you don't already have one. Go to platform.openai.com to sign up for your account. You'll also need an Airtable account, which you can sign up for at www.airtable.com.

You'll also need to create a base in Airtable for your hero images, if you don't already have one. From your Airtable dashboard, click Create a base on the bottom left. Next, give your base a descriptive name. I called mine "Blog Images."

Next, create six columns in your base:

  • Blog Post as a Single Line Text Field

  • Generate as a Checkbox Field

  • Image Style as a Single Line Text Field

  • Image Description as a Single Line Text Field

  • Image as an Attachment Field

  • Last Modified Time (Needed for the Zap to work properly)

Finally, add in a row with image details so we can test the Zap. For this article, I'm using an example food blog post, and the image description I provide asks for an image of a few spice bowls on a countertop. Fill out your own details for the Blog Post and Image Description fields. Upload a sample image as an attachment to the Image field, which will simplify development of our Zap. Finally, be sure to check the Generate checkbox (more on this later). Here's what my completed base looks like:

An Airtable database called Blog Images.

Step 1: Set up your Airtable trigger step

Head over to Zapier, and click the Create Zap button to create a new Zap. 

Search for and select Airtable for the trigger app and New or Updated Record for the trigger event (if you're using the Zap template, these will already be selected for you).

Next, connect your Airtable account, if you haven't already. You'll be asked to paste in your API key. Click the link to go to your account page:

A popup that asks permission for Zapier to access your Airtable account.

From the account page, click the link to go to the developer hub, and copy and paste the API key from the text box. Return to the pop-up and enter your API key there.

Now that you've connected to your account, it's time to set up your trigger step. In the Base and Table fields, select the items you just created in Airtable from the dropdowns. In the Which timestamp field should this Zap use to check for updates? field, select Last Modified Time.

Here's how your completed trigger step should look:

An Airtable trigger step in the Zap editor.

Finally, test this trigger by selecting one of the records coming from Airtable. Airtable will send a few incomplete test records of its own, so be sure to select the record you added from the dropdown menu so we can test everything properly:

A dropdown that shows available Airtable records.

If everything looks correct with your test results, it's time to set up your action step.

Step 2: Set up a filter action step

This Zap will trigger any time an Airtable record is updated. This means it may trigger while we are adding new records, but before we've added all the information we want DALL·E to use for our image. It also means that we'll have an issue with infinite loops. Each time our Zap sends an image back to Airtable, it's seen as an update to our record, which will cause the Zap to run again. We need a way to filter it so our Zap only runs when we want it to.

To prevent the Zap from running in a loop or before we've added all the information we need to our Airtable row, we'll add a Filter action step based on the Generate checkbox field in Airtable.

Immediately after the New or Updated Record in Airtable trigger, add a new action step and choose the Built-in Filter tool on the right. 

Under Only continue if... select the Generate field from Airtable. In the next dropdown, choose the option (Boolean) Is true.

A filter action step in the Zap editor.

Test the filter, and you should see the result Your Zap would have continued:

The results from a filter step test that show your Zap would have continued.

Now, the zap will only run when the checkbox in the Generate field is checked. This will ensure that the Zap won't run until you're ready.

Step 3: Set up your OpenAI action step

Next, we'll send the details from Airtable to DALL·E to generate the images for a blog post. If you haven't set up your Zapier connection to OpenAI, you'll have to do that now. 

To start, head back over to platform.openai.com to log into your account. At the top right of the page, click on your profile icon and select the View API Keys option:

The settings tab of an OpenAI account with View API keys highlighted.

From that page, click on the + Create new secret key button to generate a new API key. You'll need this key to connect to your OpenAI account within Zapier. Copy this key and store it somewhere safe.

A list of OpenAI API keys.

Head back over to Zapier and add a new action step at the bottom of your Zap. Search for the OpenAI (GPT-3 & DALL·E) app and choose the Generate Image event.

Click on Choose your account, and set up a new account by providing the API key you just generated in OpenAI. If you already have set up your account connection, simply select your existing account.

Now it's time to set up the action step. In the Prompt field, add the Image Style and Image Description results from your Airtable trigger by clicking in the field and selecting both of those entries from the dropdown.

As we're generating images for a blog post, we'll want them to be the highest quality possible, so select 1024x1024 from the dropdown in the Size field. 

Here's what the completed setup will look like:

An OpenAI action step in the Zap editor.

Step 4: Set up your Airtable action

Once DALL·E generates an image, you'll want to add this as an attachment in Airtable so you can review the results. Add a new action step to the bottom of your Zap and select the Airtable app. Choose the Update Record event.

Select the Airtable account you added before. Next, select the same Base and Table that you set up earlier. Click in the Record field, and go to the Custom tab. In the dropdown, select the Record ID from your Airtable trigger:

An Airtable action step in the Zap editor with a dropdown menu open under the Record field.

Click the Refresh fields button to load the fields from Airtable. Then click in the Image field, and select Image URL from your Airtable trigger step and Image URL from your OpenAI action step with no spaces between them. 

Why do we do this? By default, Airtable will replace anything in the Image attachment field when you pass it new attachments, rather than keeping the old images and adding a new one. Our workaround is to tell Airtable that we want it to attach our new image but also attach the images it already has stored in the field. We can do this by specifying all the images we want to attach in the Image attachment field.

Even though we're only including two URL fields here, this will work even if you have multiple attachments already in Airtable. This is because Zapier treats the collection of Image Url attachments it receives from the Airtable trigger similar to a comma-separated list. When we return that back to Airtable, it will reattach all of the images rather than only one. 

This solves our problem of handling multiple attachments, and this means that each time we re-run our image generation, we'll have a new image to select from rather than losing all of our existing images.

An Image field in a Zap with two image URL data points added to the field.

Next, set the value in the Generate field to false. Setting the Generate value to false here will uncheck the checkbox in Airtable, which will prevent our Zap from re-running when the table updates and avoid any issues with infinite loops.

Test your action step and, if everything looks right, you're now ready to use your Zap!

Now when you're ready to create a hero image for a blog post, just add descriptions and click the Generate checkbox for each new row you've added. Then you should see new attachments with your DALL·E images appear in your Airtable base.

Don't like what you see? Change your Image Description prompt to be a bit more specific, and click the Generate checkbox again. You should see a second image populate shortly. 

You now have an automated image generator that you can use to create images for any blog posts you're working on. I encourage you to experiment with this and expand on this example. I'd love to see what you build!

Get productivity tips delivered straight to your inbox

We’ll email you 1-3 times per week—and never share your information.

tags
mentioned apps

Related articles

Improve your productivity automatically. Use Zapier to get your apps working together.

Sign up
A Zap with the trigger 'When I get a new lead from Facebook,' and the action 'Notify my team in Slack'