O
O
orbly2021-06-21 12:52:02
Python
orbly, 2021-06-21 12:52:02

How to send messages to a private telegram channel through a bot (PyTelegrambotAPI)?

There is a telegram bot for ordering food. At the moment when the order is fully formed, the bot should send a message with the content of the order to the private tg-channel (namely, to the private one, because the public one has a link to the channel like "@channelname"). Maybe someone faced a similar problem? The bot has been added to the channel as an administrator.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
soremix, 2021-06-21
@SoreMix

Just like in another channel/group/chat - by ID

O
orbly, 2021-06-21
@orbly

I found a solution to get the channel id, you need to make the private channel public, assign it a nickname, then send any message to the channel via the bot's api:
https://api.telegram.org/botXXX:YYY/sendMessage?ch... , where XXX :YYY - your bot's token, channelname - link to the channel. The received response will contain the chat ID, save it for yourself and you can change the channel type back to private.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question