File Uploads
Your bot can attach files to the messages it posts and read the attachments on incoming messages.
Send files
Attach files to messages using the files property:
Typed attachments
Use attachments when you already have normalized Attachment objects and the adapter supports typed outgoing media. Telegram uses the native media method for the attachment type:
Outgoing attachments are available on { raw }, { markdown }, and { ast } messages. Card messages use files for uploads, and files is also the choice for generic uploads.
On Telegram, files always upload as documents, while attachments keep their image, audio, video, or file media type. Multiple Telegram files or compatible attachments are sent as media groups. Use data or fetchData for private or authenticated files. URL-only attachments must be public URLs that Telegram can fetch directly.
Multiple files
Files without text
Receive files
Access attachments from incoming messages:
Attachment properties
| Property | Type | Description |
|---|---|---|
type | string | Attachment type (e.g., "image", "file") |
url | string (optional) | Public URL |
name | string (optional) | Filename |
mimeType | string (optional) | MIME type |
size | number (optional) | File size in bytes |
width | number (optional) | Image width |
height | number (optional) | Image height |
fetchData | () => Promise<Buffer | ArrayBuffer> (optional) | Download the file data |
fetchMetadata | Record<string, string> (optional) | Platform-specific IDs for reconstructing fetchData after serialization |
Read more
Creating a Chat Instance
Initialize the Chat class with adapters, state, and configuration options.
History
Store and retrieve message history across user, thread, and channel scopes.
Message Subject
Fetch the parent resource that a message is about.
Overlapping Messages
Control how overlapping messages on the same thread are handled, with the burst, queue, debounce, drop, and concurrent strategies.