On startup, clients should fetch the animated emoji stickerset by calling the messages.getStickerSet method, providing inputStickerSetAnimatedEmoji to the stickerset field.
+The returned stickerset will contain a set of animated stickers, one for each of the supported emojis.
+
Clients should substitute messages containing only one instance of one of the allowed emojis with the respective animated sticker.
+
Animated emojis should loop only once when first sent or received, or when clicked.
+
For special dice emojis like , , or , clients are supposed to behave differently both when sending and receiving such emojis: click here for more info ».
+
Emojis with sounds
+
Certained animated emojis should play sound when clicked, as specified by server-side configuration.
+
The returned JSON object will contain the following map, with a list of file IDs to download:
When working with the API, it is sometimes necessary to send a relatively large file to the server. For example, when sending a message with a photo/video attachment or when setting the current user’s profile picture.
+
Uploading files
+
There are a number of API methods to save files. The schema of the types and methods used is presented below:
Before transmitting the contents of the file itself, the file has to be assigned a unique 64-bit client identifier: file_id.
+
The file’s binary content is then split into parts. All parts must have the same size ( part_size ) and the following conditions must be met:
+
+
part_size % 1024 = 0 (divisible by 1KB)
+
524288 % part_size = 0 (512KB must be evenly divisible by part_size)
+
+
The last part does not have to satisfy these conditions, provided its size is less than part_size.
+
Each part should have a sequence number, file_part, with a value ranging from 0 to 2,999.
+
After the file has been partitioned you need to choose a method for saving it on the server. Use upload.saveBigFilePart in case the full size of the file is more than 10 MB and upload.saveFilePart for smaller files.
+
Each call saves a portion of the data in a temporary location on the server to be used later. The storage life of each portion of data is between several minutes and several hours (depending on how busy the storage area is). After this time, the file part will become unavailable. To increase the time efficiency of a file save operation, we recommend using a call queue, so X pieces of the file are being saved at any given moment in time. Each successful operation to save a part invokes the method call to save the next part. The value of X can be tuned to achieve maximum performance.
+
When using one of the methods mentioned above to save file parts, one of the following data input errors may be returned:
+
+
FILE_PARTS_INVALID - Invalid number of parts. The value is not between 1..3000
+
FILE_PART_INVALID: The file part number is invalid. The value is not between 0 and 2,999.
+
FILE_PART_TOO_BIG: The size limit (512 KB) for the content of the file part has been exceeded
+
FILE_PART_EMPTY: The file part sent is empty
+
FILE_PART_SIZE_INVALID - 512KB cannot be evenly divided by part_size
+
FILE_PART_SIZE_CHANGED - The part size is different from the size of one of the previous parts in the same file
+
+
While the parts are being uploaded, an MD5 hash of the file contents can also be computed to be used later as the md5_checksum parameter in the inputFile constructor (since it is checked only by the server, for encrypted secret chat files it must be generated from the encrypted file).
+After the entire file is successfully saved, the final method may be called and passed the generated inputFile object. In case the upload.saveBigFilePart method is used, the inputFileBig constructor must be passed, in other cases use inputFile.
messages.uploadMedia - Uploads a media file to a chat, without sending it, returning only a MessageMedia constructor that can be used to later send the file to multiple chats, without reuploading it every time.
Telegram allows grouping photos into albums and generic files (audio, docuemnts) into media groups.
+
To do this, messages.sendMultiMedia is used, wrapping each InputMedia constructor (uploaded or pre-existing, maximum 10 per media group) into an inputSingleMedia constructor, optionally providing a custom per-file caption in message.
+
For photo albums, clients should display an album caption only if exactly one photo in the group has a caption, otherwise no album caption should be displayed, and only when viewing in detail a specific photo of the group the caption should be shown.
+Other grouped media can display a caption under each file.
For some types of documents like GIFs, messages.getDocumentByHash can be used to search for the document on Telegram servers.
+The SHA256 hash of the file is computed, and it is passed along with the file's mime type and size to the method: if the file type is correct and the file is found, a document is returned.
Animated profile pictures are also supported, by populating the video constructor: square MPEG4 videos up to 1080x1080 are supported, 800x800 is the recommended resolution.
+The video_start_ts is a floating point UNIX timestamp in seconds, indicating the frame of the video that should be used as static preview.
id, file_reference and access_hash taken from the photo constructor
+
thumb_size taken from the type field of the desired PhotoSize of the photo
+
+
+
+
For profile pictures of users, channels, supergroups and groups, since in most occasions they are encountered as simple fileLocationToBeDeprecated constructors without an associated photo, inputPeerPhotoFileLocation has to be used:
+
+
peer is the identifier of the peer whose photo we want to download
+
volume_id and local_id are extracted from the fileLocationToBeDeprecated of the desired quality (the logic for selecting the quality of profile pictures will be changed soon)
id, file_reference and access_hash taken from the document constructor
+
If downloading the thumbnail of a document, thumb_size should be taken from the type field of the desired PhotoSize of the photo; otherwise, provide an empty string.
For previews of sticker sets, inputStickerSetThumb is used (note: to download stickers and previews of stickers use the document method described above):
volume_id and local_id are extracted from the fileLocationToBeDeprecated from the thumbPhotoSize of the StickerSet (the logic for downloading stickerset previews will be changed soon)
+
+
+
+
For old deprecated photos, if the client has cached some old fileLocations with the deprecatedsecret identifier, inputFileLocation is used (this is mainly used for backwards compatiblity with bot API file IDs, all user clients must use the modern inputPhotoFileLocation file IDs):
+
+
All fields are taken from the previously cached fileLocation except for id, file_reference and access_hash taken from the photo constructor
+
+
+
+
The size of each file in bytes is available, which makes it possible to download the file in parts using the parameters offset and limit, similar to the way files are uploaded.
+
If precise flag is not specified, then
+
+
The parameter offset must be divisible by 4 KB.
+
The parameter limit must be divisible by 4 KB.
+
1048576 (1 MB) must be divisible by limit.
+
+
If precise is specified, then
+
+
The parameter offset must be divisible by 1 KB.
+
The parameter limit must be divisible by 1 KB.
+
limit must not exceed 1048576 (1 MB).
+
+
In any case the requested part should be within one 1 MB chunk from the beginning of the file, i. e.
The file download operation may return a FILE_REFERENCE_EXPIRED error (or another error starting with FILE_REFERENCE_): in this case, the file_reference field of the input location must be refreshed.
+The file download operation may return an upload.fileCdnRedirect constructor: in this case, these instructions must be followed for downloading CDN files.
+The file download operation may also return one of the following data input errors:
+
+
FILE_ID_INVALID: The file address is invalid
+
OFFSET_INVALID: The offset value is invalid
+
LIMIT_INVALID: The limit value is invalid
+
FILE_MIGRATE_X: The file is in the datacenter No. X
In order to confirm the integrity of the downloaded file, clients are recommended to verify hashes for each downloaded part, as for CDN DCs.
+upload.getFileHashes contain FileHash constructors. Each of these constructors contains the SHA-256 hash of a part of the file that starts with offset and takes limit bytes.
+
Before saving each portion of the data received from the DC into the file, the client can confirm that its hash matches the hash that was received from the master DC. If missing a hash for any file part, client developers must use the upload.getFileHashes method to obtain the missing hash.
Telegram attaches a vector of thumbnails with reduced resolution to all uploaded media.
+The server also generates a trimmed and scaled down video preview for videos, GIFs and animated profile pictures.
+
Image thumbnail types
+
Each photo preview has a specific type, indicating the resolution and image transform that was applied server-side.
A photoStrippedSize (with type i) is an extremely low-res thumbnail, embedded directly inside media location objects.
+It should be shown to the user in chat message previews, or while still downloading the most appropriately sized photoSize through the media DCs as described above.
+
The stripped bytes payload should be inflated to a JPG payload as seen here ».
Messages with animated stickers can have a compressed svg (< 300 bytes) to show the outline of the sticker before fetching the actual lottie animation.
+Animated sticker outlines will have a j type photoPathSize thumbnail.
+
This specific vector thumbnail consists in an SVG path, specially encoded to save space.
+This path will be the outline of the animated sticker, and should be shown to the user while downloading the actual sticker.
+
As for stripped sizes, the payload should be inflated using the following algorithm:
A videoSize constructor is typically used for [animated profile pictures]() and video previews.
+
+
+
+
Type
+
Description
+
Format
+
+
+
+
+
u
+
Animated profile picture
+
MPEG4
+
+
+
v
+
Video preview
+
MPEG4
+
+
+
+
Downloading webfiles
+
Remote HTTP files sent by inline bots in response to inline queries and in other places are represented by WebDocument constructors.
+When forwarding such remote HTTP files, they should be sent using external InputMedia constructors.
+Remote HTTP files can only be downloaded directly by the client if contained in a webDocumentNoProxy constructor: in this case, the file is deemed safe to download (this is the case for HTTPS files from certain trusted domains).
+
However, if the remote file is contained in a webDocument, to avoid leaking sensitive information the file must be downloaded through telegram's servers.
+This can be done in a manner similar to normal files, with the difference that upload.getWebFile must be used, instead.
w - Map width in pixels before applying scale; 16-1024
+
h - Map height in pixels before applying scale; 16-1024
+
zoom - Map zoom level; 13-20
+
scale - Map scale; 1-3
+
+
+
+
General Considerations
+
It is recommended that large queries (upload.getFile, upload.saveFilePart, upload.getWebFile) be handled through a separate session and a separate connection, in which no methods other than these should be executed. If this is done, then data transfer will cause less interference with getting updates and other method calls.
We answer questions. This document holds general ideas on how to handle them. This was intended for volunteers of the Telegram Support Force, but anyone else is free to take a look as well.
+
General
+
+
Our goal is to bring human support to human beings. To achieve this goal, we rely on volunteers. Your pay is perfection in what you do, so be cool.
+
+
Corporate support standards do not apply here. Treat people in a kind, personal, informal manner. No need to pretend to be something you are not (unless you're a dog in disguise — keep human appearances in this case).
+
+
Never lie to people.
+
+
Check everything before you reply. Things change or may no longer work the way you remember. This includes interface details, links (!) and, well, everything.
+
+
Support is a form of Art, so be fun and creative.
+
+
+
The result
+
As support volunteers, we need to provide a solution for the user. Remember, that this doesn't always have to be the solution the user was asking for. So first, we want to understand the problem that drove them to ask the question. And then find a way of solving — completely or partially — that problem.
+
For example, some users ask us for an option to send sketches or drawings to their friends. While this is not possible directly, one could take a photo with their thumb on the camera (to get a black picture), then use the drawing tools built into the photo editor to make their doodle.
+
This isn‘t what the user was looking for, but it solves the problem — and it is even more flexible and customizable than the original idea (since you could also add stickers and emoji out of the box). Some solutions are less elegant. For example, right now you can’t email your Telegram conversations. While there is much less need to do so, since you can access everything in the cloud from any of your devices, this may be a problem in some cases. What one could do then, is open the conversation in Telegram Web (or any other desktop client), select multiple messages with the mouse, then copy and paste them into a text document. Any solution is better than no solution at all.
+
There will be cases, when it is not possible to solve the problem at all. As a user in this situation, I want that people on the other end of the line understand me and care about the whole thing. Therefore, two things become important:
+
+
Make it clear that you understand the issue. ‘No, you can’t do that‘ is not a good answer. ’No, I‘m afraid it is not possible to make Telegram wash your dishes in a fast and securely encrypted way’ — is better.
+
Be gentle. Gentle doesn‘t mean soft — if we really can’t do something, it means just that — we can‘t. But adding ’Sorry about that' helps a lot.
+
+
Lastly, whatever the outcome, I always look for help from a human being, not a dumb interface. When you're casual and witty, the user feels more at ease. On the other hand, human beings, as opposed to dumb interfaces, usually understand what is appropriate in which situation. For example, when a user is in distress, he most likely needs help first — and jokes can wait until the crisis has been dealt with.
+
+
To sum up, we need to be: smart (to identify the problem and find an approach to the user), inventive (to find a solution, not always the obvious one), compassionate (in case there is no immediate solution) — and witty (otherwise it gets boring). I'm sure we are.
+
What if I don't know the answer
+
Happens to all. Don't worry, you can always find one. The TSF BIOS will tell you what to do in most situations. In case it doesn‘t or you’re not sure, ask your fellow volunteers in the group — they should know. If worst comes to worst, consult Markus.
+
Admitting you don't know something is infinitely better than trying to cover it up. So when cornered use this mantra: ‘I’m afraid I don‘t know this. Will ask my teammates and get back to you’. Just make sure that the question is not in the FAQs before you say this.
+
Handling user suggestions
+
The three rules for requests and suggestions are: don‘t lie, don’t promise anything, and don't give an exact timeframe.
+
+
The internal Suggestions board on Trello has a list of most frequently suggested features together with estimations on how likely, when and why they will be introduced.
+
For insights into the decision making process, check our Feature Philosophy.
+
+
Plans change frequently, so it‘s best if we only talk about things that exist. Never say that something will be done. ’We may do this‘, ’we will definitely add this at some point in the future‘ or ’this is coming soon' — is as far as we can go.
+
Same applies to the negative: never say we will never do something (except steal users‘ spouses and enslave their children, as mentioned in the general FAQ). The worst thing that can happen is ’we are currently not working on this‘, ’we may consider this', etc.
+
Even if you know something is happening tomorrow, say ‘in the next few days’. People love it when they get things earlier than they expected — and get downright angry if we get 5 minutes (or a few months) late.
+
Reporting bugs in Telegram
+
Every now and then you will get actual bug-reports. We have an internal board on trello, so you will be able to search all known issues and get the relevant info.
+
+
The Handling Bugs manual covers all you need to know about bug reporting in Telegram.
+
The internal Issues board on Trello lists all known issues.
+
+
If you are not part of the team and are looking for advanced troubleshooting tips, you may find the Troubleshooting section interesting.
+
Chatting
+
Truth is, most users come to simply say ‘hello’. Hello them back if you have the time. Sometimes these users do have a question after all. In other cases they may be new to Telegram, without many friends to chat with or show them around. So you can tell them more about Telegram, point to interesting features — or even other Telegram apps. No need to advertise, just explain what needs explaining.
+
Remember: we’re here to help those we can help and talk to others that we feel we have the time to talk to, but not more. If kids get too insistent without any real needs, it’s ok to ignore them after a few replies. If somebody seems to be a nice conversation partner, it’s always a good idea to discuss Telegram, see what the user thinks is missing. Maybe tell them about our Support Initiative.
+
Real-life problems
+
Unfortunately, we cannot really help people with real-life problems. A few kind words wouldn‘t hurt, but generally we should send those users to places where they can get actual help, like a crisis line or chat. (Now, if you want to be a member of the TSF and read this far, go send a picture of a kangaroo to the auditions account. No, this is not a joke. It is a test that helps us understand whether or not you actually read this. And don’t tell others. If you're already a member, you know what to do: humpa viceroy squid)
+
Insults
+
Yep, everyone gets their share of those. First of all, remember that these people are not really talking to you. They just see an abstract ‘Telegram’ entity. My advice is to humor them — I usually send a ‘well, that escalated quickly’ picture and it helps many users. Joke around with them and you’ll be surprised how that can humble people. And never insult back, even if they manage to get you angry for some reason. Nonviolent irony is always your best — and only — weapon.
Log in here to access your TSF stats. Please enter your phone number in the international format and we will send a confirmation message to your account via Telegram.