Automate Stable Diffusion’s Image Creation Powers in a Handy Telegram Bot with No Code Using Make
With the rise of AI image generation, Telegram Image Generation Bot can create images on demand are becoming popular. In this article, we’ll walk through how to build your own Telegram bot that generates images using Stable Diffusion – the new powerful image AI system.
To build the bot, we’ll use Make – the easy automation platform that connects apps and services. Previously known as Integromat, Make allows tying together Telegram, Stable Diffusion, and other components through visual workflows and no code.
We’ll set up a Make scenario that is triggered when a user sends the Telegram bot an audio file. Make will pass that audio to Whisper AI, and it will transcribe that file and send it to Stable Diffusion to generate a corresponding image. It will then return the AI-created image to the user through the Telegram bot.
By using Make’s library of pre-built modules and intuitive drag-and-drop editor, we can get this bot up and running without needing to code. Make handles all the underlying infrastructure and orchestration automatically.
In just a few simple steps, this tutorial will show you how to leverage Stable Diffusion’s cutting-edge image generation capabilities in a handy Telegram bot. You’ll learn how Make democratizes access to powerful AI through easy automations accessible even to non-developers.
So let’s dive in and build our own AI-powered image creation Telegram bot with Make and Stable Diffusion!
Creating a Telegram Bot to Generate AI Images with Make
In this tutorial, we will walk through how to create a Make automation that allows you to send a text prompt to a Telegram bot and have it generate an image using AI services like Whisper and Stable Diffusion. This is a fun way to experiment with AI and create unique images with just a text description.
Make’s easy drag-and-drop interface makes it simple to connect services like Telegram, Whisper, and Stable Diffusion. We’ll go through each step in detail to set up the automation. By the end, you’ll have a Telegram bot that can generate images from any text prompt you send it!
Step 1: Create a Telegram Bot
The first step is to create a Telegram bot that will receive messages and send back the generated images. Here is how to create a bot:
- Open Telegram and search for BotFather. This is Telegram’s bot creation service.
- Type “/newbot” and follow the prompts to create a new bot. Give it a unique name and username.
- BotFather will generate an API token for your new bot. Copy this – we’ll need it soon to connect Make.
- Open your new bot’s chat window and type /start to activate it.
- Now you have a Telegram bot ready to integrate with Make!
Step 2: Watch for New Messages
Next, we need to set up Make to watch for new messages sent to your Telegram bot.
- In Make, create a new automation.
- Add the “Watch for New Message” trigger from the Telegram connector.
- Select your new bot and enter the API key when prompted.
- Set it to watch for any message type.
This trigger will now fire every time your Telegram bot receives a new message, kicking off your automation!
Step 3: Download the Message File
When our trigger fires, Make will load the new Telegram message into the context. Let’s add a step to download any file sent with the message.
- Add the “Download Message File” action from Telegram after the watch trigger.
- Map it to the message output from the previous step.
This will download any images, documents or other files sent in the message for further processing.
Step 4: Make API Call to Whisper
Now we’re ready to generate the audio file that will serve as our AI prompt.
- Add an HTTP request action to Make.
- Configure it to make a POST request to the Whisper API at https://api.whisper.ai/request
- Set a JSON body with your API key, text, and audio configuration.
- Add headers for the API.
This POST request will have Whisper turn the message text into an audio file we can use.
Step 5: Transform Audio to JSON
Whisper returns audio files in MP3 format. Let’s transform this into JSON for easier processing.
- Add a “Transform to JSON” operation after the Whisper API call.
- Set it to parse the MP3 data.
Now we have the audio file data extracted in JSON format.
Step 6: Generate Image with Stable Diffusion
Almost there! Now we can generate the image from the Whisper audio prompt.
- Add an HTTP request to the Stable Diffusion image generation API.
- Configure it to make a POST request with the audio data.
- Set parameters like image size, sampling method, etc.
This will generate an image from the Whisper audio using Stable Diffusion.
Step 7: Route Based on Status
The Stable Diffusion API may return right away, or require some processing time. Let’s add conditional logic based on the response status.
Add a Router after the API call, configured for 3 routes:
- Anything else
Check the status field and route accordingly:
- Success: Save image URL and send to Telegram
- Processing: Delay and retry API call
- Else: End workflow
This handles the different API response scenarios.
Step 8: Send Image to Telegram
Finally, we can complete the automation by sending the generated image back to Telegram.
- Add an “Upload File” action from Telegram after the router.
- Configure it to send the image file to the original chat.
Now when an image is successfully generated, it will be sent back to the Telegram user automatically!
That covers the main steps to create a Make automation that can generate AI images from any text prompt sent to a Telegram bot. The key points are:
- Creating a Telegram bot to receive messages
- Using Whisper to generate an audio file prompt
- Calling the Stable Diffusion API to create the image
- Handling different API response scenarios
- Sending the finished image back to Telegram
You now have a cool way to request AI generated images on demand. Try sending your Telegram bot fun text prompts and see what images it comes up with!
With Make’s easy drag-and-drop builder and access to powerful AI services, the possibilities are endless for what you can create. This automation is just one example – you can adapt these steps to integrate Make with other messaging apps, image generators, and more.
Claim Your Pro Plan For Free, Click the Button Bellow.
Let us know if you have any other questions! We’re excited to see what unique AI creations you build.