Telegram ChatGPT Poster - AI-driven autoposting
A bot that writes posts through ChatGPT and publishes them to a Telegram channel, splitting the model's long answer into readable messages that stay inside the messenger's limits.
Problem
A channel needs regular posts, but a language model's output does not match Telegram's format: it arrives as one block, easily exceeds the message limit, and falls apart at paragraph boundaries.
Result
The bot generates text to configured parameters, cuts it into messages in whole paragraph groups, spaces the sends out, and publishes to the channel with nobody involved.
Tech Stack
Overview
A small but durable tool: a bot that writes posts through ChatGPT and publishes them to a Telegram channel. The brief was a single line - “build AI-driven autoposting” - and all of the substantive work turned out to sit not in generation but in reconciling two formats: how a language model answers, and how messages work in Telegram.
Problem
The model returns text as one block of arbitrary length. Telegram is a messenger with a hard per-message limit and its own typography, where a wall of text goes unread. Publishing the answer as-is produces two failures at once: a long answer hits the limit and gets truncated, and one that fits reads as an unbroken slab.
Plus two operational questions that always surface in week two: where to keep the API keys so they can be swapped without editing the script, and how to avoid firing messages back to back with no pause.
Solution
The bot receives Telegram updates on its own HTTP server (the port is configurable), generates text through the OpenAI API, and publishes the result to the channel.
The key parameters live in the resources dialog and change without touching the logic: MaxTokens and MaxTemperature control the length and temperature of the text, the delay between messages in milliseconds spaces the sends out, and the paragraph-split multiple decides how many paragraphs go into one message. That last parameter is what solves the original problem: a long model answer becomes a series of readable messages cut on paragraph boundaries rather than by a character counter in the middle of a word.
OpenAI keys are read from a separate file instead of living inside the script, so they can be replaced without rebuilding the bot.
Features
- Post generation through the OpenAI API with configurable
MaxTokensandtemperature - Publishing to a Telegram channel via its own webhook server on a configurable port
- Long answers split into messages by paragraph groups - on meaning boundaries, not on a character count
- Configurable pause between message sends
- OpenAI keys kept in a separate file, swappable without editing the script
- All parameters supplied through the resources dialog at launch
Development Process
The task arrived as a one-line brief, and the first version did exactly what was asked: ask the model, send the answer. It fell over on the first long text.
From there the work came down to describing Telegram’s format in parameters rather than hard-coding it. Splitting by paragraph groups instead of by characters is the only way not to tear text mid-thought. The pause between messages exists so a series of posts does not go out in one volley. Both values sit in settings, because the “right” split depends on the channel and on the kind of texts it publishes, and gets tuned in practice.
Results
- The channel fills without a person in the loop: generation and publishing run as one chain
- Long model answers no longer hit the message limit or arrive as a wall of text
- The publishing format is tuned to the channel through parameters, not code edits
- Keys and tokens are separated from the logic and change in the resources dialog
What Was Learned
A small case, but a telling one: the real work in “build ChatGPT autoposting” is not on the ChatGPT side. Generating text is one API call. Making that text look like a proper post in one specific channel is splitting, pauses, limits and parameters tuned against real publications.
The same boundary between “the model answered” and “the product works” shows up in a larger project in this portfolio - Astrogenerator, where fitting the text to Telegram’s format and the client’s taste took two of the six weeks.
Services used in this project
Related case studies
- Neurox - AI Photo and Video Generation Bot for VKA bot for a VK community that turns text and photos into images and video: 12 AI models in one chat, payments through YooKassa and an owner's panel with the revenue, cost and margin of every generation.
- Astrogenerator - Horoscope Generation Telegram BotA tripwire bot for a practising astrologer: it writes the daily and the personal horoscope with ChatGPT, draws the lunar-day card itself, and warms subscribers up for one-to-one work.