Overview
Send prompts over to generate images —automated with Mindflow. In this workflow, the user simply sends an email with a prompt, and Mindflow processes the request to generate an image based on the provided text. Once the image is created, Mindflow automatically sends an email back to the user with the generated image attached. It’s like having your own personal artist, but faster and less grumpy! 🎨✨
This process not only saves time but also streamlines the creative process by turning text prompts into visual content in an instant. Whether for design, marketing, or any other purpose, this workflow allows users to effortlessly transform ideas into images with minimal effort.
In this workflow, you will explore the following Mindflow features:
Set up a emailhook trigger
Utilize data transformation and functions
Apply a ForEach loop for batch processing
Integrate an AI Agent for intelligent processing
Make HTTP requests using the connector
Send email notifications using the native email step
Use the OpenAI native integration
Step by Step
1. Get Started
Go to https://your-tenant.mindflow.io and log in. If you don’t have an account yet, click on Create Account. After clicking the button, you will receive an email with a code to complete your registration.
(Side note: If you don’t receive the email, don’t worry! The internet is a tricky place sometimes, but we’ll get you sorted.)
2. Choose integrations
Now that you're logged in, it’s time to pick the integrations you want to work with:
1. Click on the Integrations
tab and search for OpenAI. Select the first integration: OpenAI 2.3.0.
3. Build the flow
It's time to start creating your workflow in the Mindflow editor.
1. In your environment, click on the Create Flow
button to initiate a new workflow.
2. Select the flow you just created to enter the editor. If you wish to change the name or emoji of your flow, simply click on it to make the edits.
You are now in your flow editor!
3. To add a Scheduler Trigger, click the blue ➕ button and select Emailhook
from the available options.
4. Click the ⚙️ icon on the Emailhook
to retrieve the email address that will trigger the workflow.
5. Copy this address and send an email with your chosen prompt. If you’re feeling uninspired, here’s an example to get you started:
Create a 3D rendered image of a majestic lion with a flowing mane, wearing a royal crown, standing atop a cliff overlooking a vast, glowing, cyberpunk city with neon lights and floating vehicles.
Here you go, you've just set up and launch your first flow. Now, it's time to enhance it, as currently, it’s not doing anything!
6. To extract the user prompt(s), we will use an AI Agent
. This agent will convert the email body into an array of prompts. You can configure the Message with the following prompt:
From the email body, create an array with each image generation prompt asked by email.
You will answer with the array only without ```json
Don't forget to replace the input by dynamically selecting the corresponding value from your ForEach
output. This is crucial—otherwise, it’ll be like giving the agent a map without any directions.
Click the green bubble of the AI Agent
to see what it has generated. In the Output tab, you'll see the result variable, which contains all the prompts sent via email. For example, if the user requested two images, the result will contain an array with two entries.
Now, we need to process each image generation request individually.
8. After the AI Agent
, click the ➕ button to add a For each
step. You can rename it For each prompts
.
9. In the configuration menu, set up the array we’ll iterate over. In the Value field, enter /
and select result from the AI Agent
output.
Now, we will use the OpenAI
integration to generate the images.
10. Click the ➕ button inside the For each
step and select the endpoint Creates an image given a prompt from OpenAI
integration.
11. In the Input tab, configure the following:
Prompt: Select the iteration data from your
For each
step.Size: Select 256x256.
In the Settings tab, we need to select the credentials provided by Mindflow to access the OpenAI API.
We’ve just requested OpenAI to generate an image based on one of our prompts. In response, OpenAI provides us with a URL containing the generated image.
Now, let's see how, through the For each
parameters, we can prepare the content for our email.
12. Click the ⚙️ icon on the For each
to open the configuration menu.
13. Add an item in the Iteration output section. To do this, click the ➕ button, select Additional Properties, and rename the property to images. Then, configure it with the following content:
<p>Here is the result of your image generation prompt: [ITERATION DATA]</p>
<div class="image-container">
<img src="[URL FROM OPENAI]" alt="GeneratedImage">
</div>
<p>If you have any issues viewing the image, you can <a href="[URL FROM OPENAI]" target="_blank">click here</a> to view it in your browser.</p>
Replace [ITERATION DATA] and [URL FROM OPENAI] with the corresponding dynamic variables.
14. Before transforming the array into usable HTML, we need to retrigger the flow to generate the output variable from the For each
step. Click the ⚙️ icon in the top left of your flow to open the configuration menu, navigate to the Logs tab, and select the log corresponding to the email trigger (hint: it’s the one with the ✉️ icon). Then, click Rerun.
By retriggering the flow, we will generate the output variable from our For each
step, allowing us to work with it within the flow.
15. Now, we can move on to the next step by adding a new AI Agent
, which we will rename AI Agent - Email. Through its prompt, this agent will generate usable HTML. Configure the Message with the following prompt:
You are an AI agent specialized in sanityzed HTML email templates. Your task is to create a clean and well-structured HTML from this array. Return only the HTML body content without ```html and nothing else.
Input : [FOR EACH OUTPUT]
Don't forget to replace the input by dynamically selecting the corresponding value from your For each
output.
16. Now that we have all the content ready, add a Send email
step. Configure the sender and subject with the information coming from the Emailhook
. Finally, enable the HTML option in the Advanced menu to select the output from our AI Agent - Email.
3. Conclusion
Congratulations! You’ve just built an automated workflow that can generate images from prompts sent via email and send them back to the user as an HTML email. 🎉
By following the steps outlined, you’ve automated the entire process, saving time and effort. Whether you're generating content for social media, marketing, or just playing around with creative prompts, Mindflow makes it easy to transform text into stunning visuals and get them into the hands of your users almost instantly. No more waiting around for manual tasks—just efficient, automated creativity!