Connecting a Telegram Bot to a GPT Model: What Gets Sent

The two connections behind a GPT Telegram bot, why chat history is resent each turn, how draft streaming works, and what data each party handles.

Guide: AI Tools and IndustryLast verified: October 20265 min read

A GPT-style Telegram chatbot is built from two separate connections. Telegram's Bot API hands each user message to a program on the developer's server, and that program sends the text to a model provider's API and passes the reply back through Telegram. The model API keeps no conversation by itself, so the developer's code must resend earlier turns on every call, which affects cost, delay, and how much personal text leaves the chat.

Key takeaways

  • A message passes through at least three parties: Telegram, the bot operator's server, and the model provider.
  • Chat model APIs are generally stateless, so the bot must store and resend history; Anthropic's documentation describes its Messages API this way.
  • OpenAI's data controls guide says API data is not used for training unless an organization opts in, and that abuse-monitoring logs are kept for up to 30 days.
  • Telegram text messages are capped at 4,096 characters, and a bot should send no more than about one message per second in a single chat.
  • Sending the full history each turn makes input size, and usually cost, grow with every exchange.

The two hops

The table follows one user message from the phone to the model and back. Each hop has its own owner, so each has its own rules.

HopWho handles the textConstraint worth knowing
User to Telegram to bot serverTelegram, then the bot operatorThe operator receives the message in readable form; the Bot API caps one text message at 4,096 characters
Bot server to model providerThe provider's APIThe provider's own terms on retention and training apply to the same text
Model provider to bot serverThe bot operatorThe reply is generated text that may contain errors and should not be treated as verified
Bot server to userTelegramAbout one message per second per chat and 20 per minute in a group, per Telegram's bot FAQ

Telegram documents the first and last hops in its bot FAQ. The middle hops are governed by whichever provider the developer chooses.

What the model provider does with the text

For OpenAI, the data controls guide states that data sent through the API is not used to train or improve its models unless the customer opts in. It also states that abuse-monitoring logs are generated for API usage and kept for up to 30 days, with exceptions where law or safety requires longer retention. Organizations that qualify can arrange zero data retention for eligible endpoints. These terms are specific to one provider and have changed over time, so the current page should be read before a bot goes live. Consumer chat apps follow different rules from the developer API, which is why a bot's operator, not the chat app's privacy page, is the party to ask.

Memory is the developer's job

Anthropic's documentation says plainly that its Messages API is stateless and that the full conversational history is sent every time. Other chat APIs commonly work the same way, but OpenAI's own page on conversation state could not be opened for this article, so that detail is not confirmed for GPT models. For a Telegram bot, the practical result is a database or cache keyed by chat ID that stores recent turns.

That history is also personal data held by the operator. The arithmetic below is an illustrative example, not a measurement: it assumes each user message is 50 tokens, each reply is 150 tokens, and the whole history is resent every turn.

TurnInput tokens sent on this turnRunning total of input tokens
15050
58502,250
101,8509,500
203,85039,000

A conversation of 20 turns therefore sends about 39,000 input tokens, against only 1,000 tokens of new user text, which is why bots usually cap history, drop the oldest turns, or replace them with a short summary. Each trimming choice also decides how much of a user's earlier text remains on the operator's side.

Showing the answer while it is written

Waiting for a full model reply can leave a chat silent for many seconds. The Bot API includes a method, sendMessageDraft, that streams a partial message to a private chat. Telegram describes the draft as an ephemeral preview that lasts 30 seconds; once the output is finished, the bot must call sendMessage with the complete text so it stays in the chat. An empty draft displays a "Thinking" placeholder. Because a single message cannot exceed 4,096 characters, long answers need to be split into parts, and each part counts against the per-chat message rate.

Checklist before publishing such a bot

  • State in the bot's description that messages are sent to a named model provider.
  • Keep the model provider's API key on the server, never in chat code or public repositories.
  • Set a history limit and a deletion command so users can clear stored turns.
  • Handle provider errors and rate limits without replaying a user's message many times.
  • Warn users not to share health, financial, or identity details, and do not present replies as professional advice.

FAQ

Does the model remember earlier messages on its own?

Not through the API itself, according to the documentation of at least one major provider. The bot has to store the conversation and send it again with each request.

Does OpenAI train on messages sent through a bot?

OpenAI's data controls guide says API data is not used for training unless the customer opts in. Logs for abuse monitoring can still be kept for up to 30 days by default.

Why do long answers arrive in several messages?

Telegram limits a text message to 4,096 characters, so a bot must split anything longer.

Is a Telegram bot chat end-to-end encrypted?

No. The operator's server receives the text in readable form, and then forwards it to the model provider.

Last verified: October 2026

Sources

  • Bots FAQ, Telegram, read October 27, 2026
  • Telegram Bot API reference (sendMessage and sendMessageDraft), Telegram, read October 27, 2026
  • Data controls in the OpenAI platform, OpenAI, 2026
  • Working with Messages, Claude API documentation, Anthropic, read October 27, 2026

New to artificial intelligence?

Start with the basics, then follow the guides to tools, rules, and effects on society.

Start with AI Basics