• Home

  • Automation with Zapier

  • Zapier tutorials

Zapier tutorials

5 min read

How to build an AI image generation playground in Discord with DALL·E and Zapier

By Michael Toth · June 15, 2023
A hero image of the Discord app logo connected to the OpenAI app logo on a light yellow background.

If you're anything like me, you've been obsessively playing with different AI tools for the past few months. Some tools, like ChatGPT, are pretty user-friendly, but others, unfortunately, aren't so simple.

While ChatGPT has a clean textbox interface, and GPT-3 has a similar offering in the OpenAI Playground, I've found that image generation AI options are more limited. For example, there isn't an option to generate DALL·E images in the OpenAI Playground. And while there are third-party tools to help with this, I always like to work directly with the API where possible.

To solve this problem, I built myself a personal DALL·E Playground in Discord using Zapier and the OpenAI API. In this tutorial, I'll show you how you can set up your own version of this, building out a simple chat playground in Discord to generate your own DALL·E AI images whenever you like!

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

This project is a relatively straightforward one, and it only requires 3 steps in Zapier:

  • Trigger: New message posted to channel in Discord

  • Action: Send the Discord message to OpenAI's DALL·E for image generation

  • Action: Retrieve the generated image from DALL·E and send it back to Discord

A 3-step Zap in the Zap editor with Discord and OpenAI steps.

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

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.

Generate AI images with DALL-E from new Discord messages

Generate AI images with DALL-E from new Discord messages
  • Discord logo
  • OpenAI (GPT-4, DALL-E, Whisper) logo
  • Discord logo
Discord + OpenAI (GPT-4, DALL-E, Whisper)

Before you begin

Before you set up your 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. 

Next, you'll need a Discord account, which you can sign up for at www.discord.com

You'll also need to create a Discord server if you don't already control one. To set this up, open the Discord app and click the Add a server (+) symbol in the bottom left corner, then select Create My Own. Finally, give it a descriptive name–I created one called DALL·E Playground for this project. 

Once you have your accounts set up, you're ready to start building your Zap!

Step 1: Set up your Discord trigger step

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

Search for and select Discord for the trigger app and New Message Posted to Channel for the trigger event (if you're using the Zap template, these will already be selected for you).

A trigger step in the Zap editor with Discord selected as the trigger app and New Message Posted in Channel selected as the trigger event.

Next, connect your Discord account, if you haven't already. You'll be asked to select the server you want to use for this project in the Add to Server dropdown.

A permissions pop-up asking the user to give Zapier access to a Discord account.

Click Continue and grant Zapier all of the requested permissions to ensure you have full access to your Discord server. 

Now that you've connected to your account, it's time to set up your trigger step. In the Channel field, select the Discord channel you want to monitor for prompt messages to send to DALL·E. I created one called DALL·E for this project, but you could also simply select the general channel if you prefer.

Here's how your completed trigger step should look:

In the channel field, dall-e has been selected.

Finally, you'll need to test this trigger to make sure it's set up properly. Head over to Discord and send a prompt message in the channel you just selected. I sent the text "A cat riding a motorcycle." 

Then, go back to your trigger step in the Zap editor and click Test Action. You should see the message you just sent:

A successful test message in the Zap editor.

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

Step 2: Set up your OpenAI DALL·E action step

Next, we'll send the details from Discord to DALL·E to generate the image based on your prompt. 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 window in an OpenAI account with View API keys selected in the menu.

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 API keys in an OpenAI account.

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

An action step in the Zap editor with OpenAI selected for the action app and Generate Image selected for the action event.

Click 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, map the Discord message data from your trigger step by clicking in the Prompt field and selecting Content from the dropdown.

Leave the value for the n field equal to 1, which indicates that we want DALL·E to create one image based on this prompt. I'm selecting 1024x1024 for the Size field, but lower-resolution options will be cheaper for OpenAI to generate, so select those if you prefer.

Here's what your completed setup will look like:

An action step for OpenAI with a Discord message mapped to the Prompt field.

Next, you'll want to test your action to send the Discord message over to OpenAI. If everything is working correctly, you should receive a test response similar to the image below, which contains a timestamp and a URL to the image that DALL·E has generated.

A successful test message with the URL for an AI image generated by the OpenAI step.

Step 3: Return the generated image to Discord

Once DALL·E generates an image, you'll want to send this back to Discord so that you can see the result. Add a new action step to your Zap and select the Discord app. Choose the Send Channel Message event.

An action step in the Zap editor with Discord selected for the action app and Send Channel Message selected for the action event.

Select the Discord account you added before. Next, in the Channel field, select the channel you used in your previous trigger step. 

In the Message Text field, add the image to your message by clicking in the field and selecting Image URL from the Insert Data dropdown. Discord will automatically load the image from this URL, displaying it in line in your channel. 

Give your bot a descriptive name like "DALL·E Bot," or leave it blank to maintain the default Zapier bot name. Your complete action step should look like this:

A Discord action step with the completed AI image added to the message field.

Finally, test your action step. You should receive an image message in your Discord channel based on the prompt you sent before. In my case, here's what I received:

An AI-generated image of a cat riding a motorcycle in a cartoon style.

If everything looks good, you're ready to use your Zap! Now you can simply send image prompt messages to the Discord channel, and you should receive back your DALL·E generated images within about 1 minute. Don't like what you see? Modify your message to be a bit more specific, and simply send it again to have DALL·E regenerate. You should see a second image populate shortly. 

You now have an automated image generation playground that you can use to generate DALL·E images whenever you want. I encourage you to experiment with this and expand on this example. I'd love to see what you build!

Related reading:

  • Automate art inspiration with OpenAI's DALL·E and Zapier

  • Generate blog images with DALL·E

  • Create logos with DALL·E

  • How to automatically share new YouTube videos on Discord

  • The top AI image editors

Get productivity tips delivered straight to your inbox

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

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'