Example taken from https://groosha.gitbooks.io/telegram-bot-lessons/content/chapter1.html
# -*- coding: utf-8 -*- import config import telebot bot = telebot.TeleBot(config.token) @bot.message_handler(content_types=["text"]) def repeat_all_messages(message): # ΠΠ°Π·Π²Π°Π½ΠΈΠ΅ ΡΡΠ½ΠΊΡΠΈΠΈ Π½Π΅ ΠΈΠ³ΡΠ°Π΅Ρ Π½ΠΈΠΊΠ°ΠΊΠΎΠΉ ΡΠΎΠ»ΠΈ, Π² ΠΏΡΠΈΠ½ΡΠΈΠΏΠ΅ bot.send_message(message.chat.id, message.text) if __name__ == '__main__': bot.polling(none_stop=True) In message.chat.id - contains chat_id for example 123456789
I need to send a message to the user.
In the browser I type:
https://api.telegram.org/bot<ΡΠΎΠΊΠ΅Π½>/sendMessage?chat_id=123456789&text=Hello Answer
{"ok":false,"error_code":400,"description":"Bad Request: chat not found"} Where to dig?
chat_id? The user must activate the bot with the command/startand only after that the bot will be able to write to him. - Pavel Durmanov