Skip to content


The standard file download path looks like this:

  • Call getFile with file_id
  • Extract file_path from response
  • Construct a link of the following type<token>/<file_path>
  • Send request and download the requested media
  • ? Maybe save file in FS ?

but in our case it looks more convenient and simpler.

Via context methods

bot.on("message", async (context) => {
    if (!context.document) return;
    // download to ./file-name
    await || "file-name");
    // get ArrayBuffer
    const buffer = await;

    return context.send("Thank you!");


One message contain only one attachment. Therefore, to download an attachment, you can simply use the method But you can solve this using the media-group plugin.

Via bot instance method

const chat = await bot.api.getChat({ chat_id: "@not_found" });

if (! return;

// download to ./not_found_chat_photo.png
await bot.downloadFile(, "not_found_chat_photo.png");
// get ArrayBuffer
const buffer = await bot.downloadFile(;