Skip to content

The moment it happens

Generate images from Telegram messages and keep them in Drive

Describe an image to your Telegram bot and it sends back the picture and saves a copy in your Drive AI images folder.

Runs
The moment it happens
Apps
Google Drive, Telegram
AI
Yes, uses the built-in AI allowance
Access
Telegram bot token; Drive write

Send this to your assistant

Create a ClickRuntime automation: when I message my Telegram bot an image idea, improve the prompt, generate the image, send it back to me and save it in my Drive 'AI images' folder.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

A social media manager gets ideas for post images at odd moments: on the train, between meetings, while scrolling. Opening an image tool on her phone, writing a careful prompt and then saving the result somewhere her team can find it is too fiddly, so the idea is gone by the time she is at her desk.

Sending a one-line idea to a chat bot and getting back a finished image, already filed in a shared folder, captures ideas when they happen and keeps every result in one place.

What you get out of it

  • Ideas captured from your phone

    A quick message is all it takes, from any device where you use Telegram.

  • Better images from rough ideas

    Your short description is expanded into a detailed prompt before the image is made, so results look more finished.

  • Every image is kept

    Each picture is saved to Drive with its prompt in the name, so you can find and reuse it later.

  • Easy to share with your team

    Colleagues with access to the folder see new images without you forwarding anything.

How it works

What happens, step by step

  1. When you send your Telegram bot a message, ClickRuntime receives it.

  2. AI turns your short idea into a detailed image description.

  3. The image is generated and sent back to you in the Telegram chat.

  4. A copy is saved to your AI images folder in Google Drive.

Before it runs live

  • Connect Google Drive
  • Connect Telegram
  • Paste your automation's link into the other app's webhook settings

What you get

RunsThe moment it happens
Generate images from Telegram messages and keep them in Drivejust nowSucceeded
Telegram · Image botFlat-lay of Northwind coffee beans and a ceramic cup on a linen table, soft morning light. Saved to AI images.

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Act only on the items that match your own rules, and skip the rest
  • Change what the AI looks for, or how it writes the result
  • Add another app, for example also send it to Slack
  • Combine it with other Google Drive and Telegram steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
ai_images_from_telegram_prompts_kept_in_drive.pyexample
import base64, json
from clickruntime import on_event, credentials, http, ai

ALLOWED, FOLDER = {123456789}, "your-ai-images-folder-id"

@on_event
def handle(event):
    msg = (event.json or {}).get("message", {})
    chat = msg.get("chat", {}).get("id")
    if chat not in ALLOWED or not msg.get("text"):
        return {"ignored": True}
    prompt = ai.generate(f"Rewrite as a detailed image generation prompt (style, lighting, composition), under 80 words:\n{msg['text'][:500]}",
                         max_output_tokens=150).text.strip()
    img = http.post("https://api.openai.com/v1/images/generations", headers={"Authorization": f"Bearer {credentials.secret('IMAGE_API_KEY')}"},
                    json={"model": "gpt-image-1", "prompt": prompt, "size": "1024x1024"}, timeout=120).json()["data"][0]["b64_json"]
    png = base64.b64decode(img)
    tg = f"https://api.telegram.org/bot{credentials.secret('TELEGRAM_BOT_TOKEN')}"
    http.post(f"{tg}/sendPhoto", data={"chat_id": chat, "caption": prompt[:1000]}, files={"photo": ("image.png", png, "image/png")})
    h = {"Authorization": f"Bearer {credentials.connection('google', 'work')}"}
    name = f"{msg['text'][:50]}.png"
    http.post("https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart", headers=h, files={
        "metadata": (None, json.dumps({"name": name, "parents": [FOLDER], "description": prompt}), "application/json"),
        "file": (name, png, "image/png")})
    return {"saved": name}

FAQ

Common questions

Which image service does it use?
The image generation service whose API key you save in your ClickRuntime dashboard. The script sends it the improved prompt and receives the image.
Can other people use my bot?
Only the chat IDs you allow. Messages from anyone else are ignored.
What size are the images?
Square 1024 pixel images by default. You can choose portrait or landscape sizes if your image service supports them.
What permissions does it need?
Telegram bot token; Drive write. Nothing else in your accounts is used.
Does it need AI?
Yes. It uses ClickRuntime's built-in AI, so you don't need an OpenAI or Anthropic key. Every plan includes a monthly AI allowance.
How many runs does it use?
One run for each event the app sends.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Generate images from Telegram messages and keep them in Drive” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.