Learn to build a Telegram bot that generates AI images and saves them in Google Drive using Pabbly Connect. Follow our step-by-step tutorial for seamless automation.

Watch Step By Step Video Tutorial Below


1. Create a Telegram Bot for AI Image Generation

To build a Telegram bot for generating AI images, we first need to create a bot using Telegram. This involves using the BotFather, which is the official bot for creating other bots in Telegram.

Search for BotFather in your Telegram account. Click on it and press the start button. Then, type /newbot to initiate the creation process. Follow these steps:

  • Send a name for your bot, e.g., ‘AI Image Generation Bot’.
  • Provide a unique username ending with ‘bot’, like ‘AIImageGenBot’.
  • Copy the API token provided by BotFather.

Now that the bot is created, we can connect it to Pabbly Connect to automate the image generation process.


2. Access Pabbly Connect for Automation

To use Pabbly Connect, navigate to the Pabbly website and log in to your account. If you are new, you can sign up for free. Once logged in, go to the ‘All Apps’ section and select Pabbly Connect.

Click on the ‘Create Workflow’ button to set up a new automation workflow. Name your workflow something relevant, such as ‘AI Image Generation Workflow’. Choose the folder where you want to save this workflow.

In the workflow, you will see two main windows: the trigger window and the action window. The trigger window will be used to connect your Telegram bot with Pabbly Connect, allowing it to receive messages sent to the bot.


3. Set Up the Trigger for Telegram Bot

In the trigger window, select ‘Telegram Bot’ as the app. From the dropdown, choose the trigger event as ‘Watch Updates’. Click on ‘Connect’ and add a new connection using the API token you copied earlier from BotFather.

After pasting the API token, click on the ‘Save’ button. Then, send a test message to your Telegram bot to check if the integration works. For example, send a message like ‘Kids playing football in the field surrounded by mountains covered with snow’.

Once you send the message, Pabbly Connect should capture this message in the trigger step. You will see the message text and other details like the update ID and message ID. This confirms that your Telegram bot is successfully connected to Pabbly Connect.


4. Generate AI Image Using OpenAI

Next, we will configure the action step to generate an AI image using OpenAI. In the action window, choose ‘OpenAI’ as the app and select ‘Generate Image’ as the action event. Click on ‘Connect’ and create a new connection using your OpenAI API key.

To get your API key, log into your OpenAI account and navigate to the API key section. Create a new secret key and copy it back to Pabbly Connect. After connecting, select the model (DALL-E 2 or DALL-E 3) you want to use for image generation. For this tutorial, we will use DALL-E 3.

  • Map the prompt received from Telegram to the prompt field in OpenAI.
  • Set the number of images to generate (1 for DALL-E 3).
  • Choose the image size and quality (e.g., 1792×1024, HD).

After setting this up, click ‘Save and Send Test Request’ to generate the image. You should receive a response with the generated image URL from OpenAI, confirming the image generation step is successful.


5. Save Generated Image to Google Drive

Now, we will configure the final action to save the generated image to Google Drive. In the action step, select ‘Google Drive’ as the app and choose the action event ‘Upload a File’. Click on ‘Connect’ and sign in to your Google Drive account.

Once connected, map the URL of the generated image from OpenAI to the URL field in Google Drive. You will also need to specify the folder ID where you want to save the image. To find the folder ID, open the desired folder in Google Drive and copy the ID from the URL.

Map the image URL from OpenAI to the Google Drive URL field. Paste the folder ID where the image will be saved. Set the file name, using the prompt text with a .png extension.

Click on ‘Save and Send Test Request’. If successful, the image will be uploaded to your specified Google Drive folder, confirming that the entire automation workflow with Pabbly Connect is functioning correctly.


Conclusion

In this tutorial, we successfully built a Telegram bot that generates AI images and saves them to Google Drive using Pabbly Connect. This automation simplifies the process, allowing for efficient image creation and storage without manual intervention.

Ensure you check out Pabbly Connect to create business automation workflows and reduce manual tasks. Pabbly Connect currently offer integration with 2,000+ applications.