How do I send messages to Telegram bot using Pyrogram?

180 Views Asked by At

I've built a rather neat LLM-based Telegram bot using python-telegram-bot. I tried to figure out how to do E2E testing and found that people use Pyrogram for these purposes. However, when I try to send a message with Pyrogram to the bot using bot id, I get 'ID not found: XXXXXXXXXX' (XXXXXXXXXX replaces my bot id).

I do manage to send messages to myself using my id (they end up in "Saved" messages folder), which means this can't be Pyrogram not working/not authenticated correctly etc.

Any pointers?

1

There are 1 best solutions below

5
Andrii On

A possible solution is to create a Telegram group, add your Bot to the group (adding admin permissions to it) and then send a message to the group. The bot will react to a specific command like '/start' or will react to a group message.