Latenode

Telegram AI Image Generator with Quota Tracking in Google Sheets

This template listens for Telegram bot messages, checks that user's daily quota in Google Sheets, asks ChatGPT to tighten the prompt, generates a still with OpenAI Image Generation, and sends the photo back in the same chat. Each successful run is logged in the sheet. Put the bot token on the Telegram connection. ChatGPT and image generation are Latenode AI steps, so you do not paste an OpenAI key.

Updated Sep 16, 2026Est. run: 51sEst. cost: $0.0032
How Latenode estimates time and cost

Latenode bills workflow runtime in CPU seconds. The first 10,000 CPU seconds are free each month, then usage follows pay-as-you-go CPU-second pricing. Plug-and-Play (PnP) AI nodes are billed separately—each PnP token is $1 USD, charged pay-as-you-go at vendor cost plus a small processing fee, with no API keys required.

Full pricing — how CPU seconds work →

Workflow preview

What this template does

  • Turns a Telegram message into a generated image in the same chat
  • Enforces a daily quota from Google Sheets
  • Writes a stronger prompt with ChatGPT
  • Renders the still with OpenAI Image Generation
  • Keeps the bot token on the Telegram connection

How it works

1
Trigger

Listen for Telegram prompts

The scenario starts when the bot receives a text message. JavaScript reads that prompt and the user id.

2
Logic

Check the daily quota

Google Sheets holds the usage log. JavaScript counts today's rows for that user and stops the run when the cap is reached.

3
AI

Write the image prompt

ChatGPT turns the message into a clear image prompt. ChatGPT is Latenode AI, so you do not paste an OpenAI key.

4
AI

Generate the image

OpenAI Image Generation renders a still picture from that prompt.

5
Action

Send the photo and log the run

Telegram sends the file back to the same chat. Google Sheets adds a row with user, date, prompt, and image URL.

Setup guide

1

Connect Telegram

Add a Telegram connection with your bot token. Add the bot to the chat that will send prompts.

2

Connect Google Sheets

Add a Google Sheets connection. Use a tab with columns for user id, date, prompt, and result URL. Set the daily cap in JavaScript, then count today's rows for that user before generating.

3

Add ChatGPT and image generation

Read the Telegram text in JavaScript. Ask ChatGPT to rewrite it as an image prompt, then generate the picture with OpenAI Image Generation. ChatGPT and image generation are Latenode AI nodes.

4

Send the photo and log

Send the generated file as a Telegram photo. Map the chat id from the trigger. Add a Google Sheets row for the run. Send a test prompt and confirm the picture returns in chat.

Requirements

A Telegram bot token stored on the Telegram connection
A chat the bot can read and send photos to
A Google Sheet Latenode can read and append
A daily request cap you set in JavaScript

FAQ

Common questions about this template

Each run uses credits on your Latenode plan. We charge for processing time (1 credit = 30 seconds). Your actual cost depends on your plan and how long the run takes. See pricing plans for plans and how credits work. Plug-and-Play AI nodes are billed separately.