Latenode

Automate Telegram AI Chatbots with OpenAI Integration

This template listens for Telegram bot messages, routes plain chat to ChatGPT, and routes image requests to OpenAI Image Generation.

It then replies in the same chat with text or a photo. 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: 48sEst. cost: $0.0031
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

  • Answers Telegram messages as they arrive
  • Writes chat replies with ChatGPT
  • Renders pictures with OpenAI Image Generation
  • Keeps the bot token on the Telegram connection

How it works

1
Trigger

Listen for Telegram updates

The scenario starts when the bot receives a message in a chat it can read.

2
Logic

Choose text or image

JavaScript treats the message as chat, or as an image request when the user asks for a picture.

3
AI

Write a reply or generate an image

ChatGPT answers questions. Image generation renders a visual from the prompt.

4
Action

Send the Telegram reply

Telegram posts the text, or sends the photo, back to the same chat.

Setup guide

1

Connect Telegram

Add a Telegram connection with your bot token. Add the bot to the chat it should read.

2

Set the trigger

Add a Telegram trigger for new updates. Skip non-text updates if you only want written messages and image prompts.

3

Route chat and images

In JavaScript, send normal questions to ChatGPT. When the user asks for an image, send the prompt to image generation instead. ChatGPT and image generation are Latenode AI nodes.

4

Reply in Telegram

Send the ChatGPT text as a Telegram message, or send the generated file as a photo. Map the chat id from the trigger.

Requirements

A Telegram bot token stored on the Telegram connection
A chat the bot can read and reply in
A rule in JavaScript for when a message is an image request

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.