Automate Flux AI Image Generation with Slack, Zapier and Replicate: Step-by-Step guide
Learn how to build a powerful automated workflow that connects Slack to Replicate's AI image generation models using Zapier. This comprehensive guide shows you how to create a system that generates AI images with a simple Slack message, automatically saves them to Google Drive, and returns the results - all without writing complex code.
The Basic Setup
You’ll need:
Slack (obviously)
Zapier (the glue that holds it all together and zaps it into automated life)
Replicate (the gateway to the AI models that make the images)
Google Drive (keeps everything safe and sound)
Zapier Templates
See below for lots more detail on each step of each Zap!
Zap 1:
https://zapier.com/shared/5592c9c069d7fc8c8a927ddc64ea11ca1bae0810
Zap 2:
https://zapier.com/shared/11691b5c4ef828e09b3e360f4757a99fcaf9d420
What is Replicate.com?
Think of Replicate as a massive toolbox of AI models that someone else maintains for you. Instead of setting up powerful computers and wrestling with complex AI software yourself, you just connect to their API, and away you go.
Here's what makes it brilliant:
Pay per use (only fork out when you actually generate something)
Loads of different AI models ready to go
Dead simple to use - just make an API call and the job's done
They handle all the faffy bits like servers and GPU power
For this guide, I'm using their Flux 1.1 Pro Ultra model, but you could swap that for any other image generation model they've got. It is handy if you want to test different models without getting your hands too dirty with the technical bits.
The Two-Part Magic Trick 🪄
Part 1: Getting Your Image Request Going
Set up Slack to catch your message when you type something like "Generate: A hamster wearing a hard hat"
Optional but fun: I've got ChatGPT giving each request a snarky French critique
Clean up the message using Python (get rid of any weird bits that Replicate doesn’t like)
Fire it off to Replicate (that's the AI doing the actual work)
Part 2: Saving Your Creation
“Catch” the finished image
Download it properly
Stick it in Google Drive (so it doesn't disappear into thin air)
Pop it back in Slack with a proper link
The Nitty Gritty Bits
All the technical code and configurations you need are below - these work for the Flux AI Image Generator Model: black-forest-labs / flux-1.1-pro-ultra
Zap 1: Sending the Prompt to Replicate
Zap Step 1. Trigger: Slack Message
Event: "New Message Posted to Channel."
This triggers the process whenever you send a specific Slack message in a channel (e.g., a prompt like "Generate: A hamster in an astronaut helmet").
Step 2. Optional Step: Critique the Prompt with ChatGPT
Action: Chat with ChatGPT
Use ChatGPT to provide a faux French critique of the prompt for fun. You can skip this step if unnecessary.
My prompt was:
the user has asked for the image below to be generated via a Slack message, can you use your best snobby French impression and respond in Faux-french accent (not actual French) and lambast them for using AI as it'll be the death of art and critique their prompt? Finally, tell them reluctantly that you will create their image. Short and funny length appropriate for Slack.
#their prompt” {the Slack message}
Step 3. Python Script: Clean the Prompt
Add a Python code step to clean the prompt and remove unwanted characters.
See the Pen Python - Clean Up Slack Message Text by Ben Milsom (@Ben-Milsom) on CodePen.
Step 4. Webhook: Send the Prompt to Replicate
Method: POST
URL: The Replicate endpoint for the Flux 1.1 Pro Ultra model.
Headers:
Authorization: Token <your_replicate_api_key>
Content-Type: application/json
Body:
See the Pen JSON - Send Prompt to Replicate by Ben Milsom (@Ben-Milsom) on CodePen.
Step 5. Slack: Send Confirmation
Send a message back to Slack confirming the prompt has been sent and is being processed
Zap 2: Saving the Image and Sending it Back
Step 1. Trigger: Webhook Catch
This webhook catches the output URL from Replicate once the image generation is completed.
The URL given to you here will be what you will place into the {Zap 2 webhook URL} variable in the JSON above 👆
Step 2. Download Image
Webhook GET
Use a GET request to retrieve the raw image data from the {output_url} in Step 1.
Step 3. Upload Image to Google Drive
Event: Google Drive "Upload File"
File: Use the output from Step 2
Filename: Use a dynamic filename like generated-image.png
Folder: Specify the folder where the images should be saved.
Step 4. Slack: Send Image and Google Drive Link
Use the "Send Channel Message" event to send:
A permanent Google Drive link to the saved image.
The image itself using the URL from Replicate.
Why It's Brilliant
Type in Slack, get an image back - job done
Everything's saved properly in Google Drive
No more faffing about with manual downloads
Works like a charm every time
Extra Tips
Want different sized images, or a different aspect ratio - all of those variables are configurable in the Body element of Zap 1’s API POST to replicate (Step 4)
Something gone wrong? No worries, paste in the error to ChatGPT and it will help resolve it.
What Next?
Get it set up and give it a whirl. Even if you're not a tech wizard (I'm certainly not), this is actually pretty straightforward to get going. And once it's running, it's really handy for knocking up quick visuals and significantly cheaper than paying for Midjourney and the rest.