skip to Main Content

Many different media types on Telegram have a file_id and file_unique_id property, such as Stickers, Audio, and Document.

The file_id property is unique to each Telegram bot, so one Telegram bot will not report the same file_id as another Telegram bot will, even if it’s the same piece of media.

I want to have two Telegram bots communicate with each other, but they are currently unable to do so because the file_id property is meaningless when one bot tries to talk to the other.

The file_unique_id property is consistent between the bots, but it does not seem like you can do much of anything with that identifier.

Is there any way to pass a reference to a file stored on Telegram’s servers from one bot to another, without having to re-upload the file on both bots?

3

Answers


  1. There aren’t any official methods to share fileIds between bots. In fact, you can’t even get 2 bots talk to each other, also you won’t get bot updates in groups. So bot to bot communication is not possible at all at this moment.

    But what you can do is to use Mtproto api and sign-in to telegram as a normal user (with phone number). And follow these steps using the logged in account:

    1. Start both of your bots.
    2. Forward messages you receive from bot 1 to bot 2.

    This way you’ll be able to access any files in bot 1 in bot 2.

    You can use Telethon to write a script that does the job for you, listening to updates coming from bot 1 & forwarding them to bot 2.

    Also using normal bot api you should forward received messages to your logged-in account.

    Login or Signup to reply.
  2. Bot can’t interact with each other. But there’s a workaround,
    we can use channels as a medium (with only BotAPI)

    Steps,

    1. Add two bots as admin in channel

    2. Broadcast the messages from Bot A to channel

    3. Now, the Bot B will get these as channel posts and your new fileid
      for the same file which will be unique for Bot B (obviously)

    4. You have officially transferred all fileid to Bot B

    Login or Signup to reply.
  3. The only way is to use a shared channel. Both bots have admin access. However, you may encounter error 429 while transferring the file.
    The solution is to send the files to the channel at longer intervals.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search