Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python telegram bot - can the bot send the first message in chat?

Is it possible to get a bot to send the first message in the chat without running a command like "/Start"?

Maybe it possible to save the chat_id of the requested user in advance and send him a message in the future, thus allowing the bot to send a first message in chat according to a predefined condition that will trigger him?

I searched for an answer online but could not find one. Can you send me a link to a tutorial that explains how to do this? Thanks in advance

Yoav Giladi :)

like image 609
Yoav Giladi Avatar asked Mar 23 '26 12:03

Yoav Giladi


1 Answers

One solution is to use a Telegram Bot deeplink to provide an entry point to the Chatbot that does not require the users typing the /Start command.

After the very first interaction you can the obtain the chat_id which can be stored for using it to initiate a message later:

context.bot.send_message(chat_id, text='Howdy')
like image 83
Beppe C Avatar answered Mar 26 '26 00:03

Beppe C



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!