0

I'm looking for a way to send a message to a bot using another bot. I have API of these two bots. The library that I am using is telebot, and with below codes I can send a message to channel or any accounts, but I don't know how can I get chat id of a bot.

bot = telebot.TeleBot(TOKEN)
bot.send_message(yourID, 'your_message')
2
  • If it's a one time thing, forward one of the first bot's messages to the second bot, save the chat ID inside the second bot (I think there was a way to store forwarded messages id) and you are good to go. Commented Jun 18, 2021 at 9:37
  • thanks I get my bot id, but I couldn't send bot to bot I get this error, telebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 403. Description: Forbidden: bot can't send messages to bots Commented Jun 18, 2021 at 9:55

1 Answer 1

1

It seems that there is not a specific way to do this and telegram is restricting bot-to-bot interactions for some reasons. However, you can use a neat trick.
You can create a dummy account as a sort of middle man for the interactions. Using the Telegram API (not to be confused with the Bot API) you can create an automatic message forwarding service for the dummy user just to forward the message from bot A to bot B. Hence creating the connection you want.
One such example of TelegramAPI is Telethon. Check here for an example of using the API. You can also check here for Telethon documentation.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a million, Could you explain with an example?
I edited the answer and added an example of TelegramAPI which you can use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.