Building
How a Telegram bot sends photos, documents and other files
By the Botable team
A bot can send a file three ways: uploading bytes, giving Telegram a public URL to fetch, or reusing a file_id from a file Telegram already has. The third is instant and free, and is what you should use for anything sent repeatedly.
The short version
A Telegram bot sends files by one of three routes, and choosing correctly is most of the performance difference. You can upload the bytes directly, which is necessary the first time and is the slowest path; you can pass a public URL and let Telegram fetch it, which offloads the transfer but depends on that URL staying reachable; or you can pass a file_id, an identifier Telegram returns for every file it has already stored. Reusing a file_id costs no upload at all and is effectively instant, which makes it the correct approach for any asset sent more than once — a logo, a menu image, a price list. Choosing the right send method also matters: sending an image as a photo compresses it and displays it inline, while sending the same image as a document preserves the original file exactly and shows it as an attachment.
Step by step
How should you send an image that is sent repeatedly?
Upload it once, store the file_id Telegram returns, and send that identifier from then on. The subsequent sends transfer nothing and complete immediately. Not doing this is why some bots feel slow on every image.
Photo or document?
Photo for anything meant to be looked at: it displays inline and is compressed. Document when the file must arrive intact — a PDF, a spreadsheet, a high-resolution original, or a PNG whose exact pixels matter. Sending a screenshot as a photo and then being asked why the text is blurry is the classic version of this mistake.
How do you send several images together?
As a media group, which renders as one album rather than a run of separate messages. Note that a media group carries a single caption on the first item, so per-image captions require separate messages instead.
What are the size limits?
Telegram documents limits for what a bot can send and, separately, a smaller limit for files a bot can download through getFile. These are published values that have changed over time, so check the current Bot API documentation rather than trusting a number from a blog post — including this one.
What catches people out
- A file_id is tied to the bot that obtained it; it cannot be shared between bots
- Sending a URL means Telegram fetches it — if it is behind auth or goes down, the send fails
- Media groups take one caption for the whole album, not one per image
Questions
Can a bot receive files from users?
Yes. Incoming photos and documents arrive with a file_id you can store and re-send later, and the file itself can be downloaded through getFile within the documented download limit.
Can it edit a photo it already sent?
Yes — the media on an existing message can be replaced, which is useful for a refreshing chart or a status image that updates in place rather than posting a new message each time.
Want a bot that does this?
Describe it in plain language and Botable writes the code, gives the bot its own database, deploys it and keeps it running. Everything on this page is handled for you — the token, the webhook, the storage, the hosting.
Keep reading
- Buttons and keyboardstelegram inline keyboard vs reply keyboard
- Rate limitstelegram bot rate limits
- Storing datatelegram bot database