Answer the question
In order to leave comments, you need to log in
How to send a message to a user by username using python and telegram bot?
There is the following task - the user made an online entry on my site, indicating his contact details. Website in django. Also, the user entered the telegram in advance and started communicating with the bot.
Question: how to make it so that when a user sends an online application, indicating his username telegram, then a message is sent to this username by a bot?
That is, the user does not make any requests to the bot, but simply by filling out an application on the site, he was notified by the bot about the record.
Answer the question
In order to leave comments, you need to log in
When a user launches a bot, save all his data in the database, in particular, to send a message, we are interested in his username and chat id. And then, when a user leaves a request on the site with his username, you take the id of his chat from the database and send the desired message using the
https://core.telegram.org/bots/api#sendmessage method
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question