问题
How can a bot send a message to the user, when user just opens the chat.
Example:
- User has already added a
Telegram bot
to his list of contacts and started conversation - Later on, user opens the chat window with that bot
- Bot "sees" that user has opened the chat window, but hasn't written anything yet
- Bot should say "hello, what can I help you with?" to the user
Is there any event/trigger for a step #3 in Telegram Bot API?
回答1:
No. There is no trigger for each time user opens the chat window but for the first time as below:
When someone opens a chat with bot "FOR THE FIRST TIME", automatically Telegram sends
/start
command to bot .It is like an ordinary command when user sends a command or write/start
and send, so your bot can catch it and say hello or do any commands to that user. As soon as user opens the chat window with your bot, Telegrams send this message automatically to your bot containing info about user and so on.
来源:https://stackoverflow.com/questions/38830013/how-can-a-telegram-bot-figure-out-that-user-has-opened-the-chat-window