I have prepared one api in php for send message to bot. Every time, I need to pass chat_id
in api call.
Anyone know how can i create unique chat id for send message to bot.
Thanks in advance.
I have prepared one api in php for send message to bot. Every time, I need to pass chat_id
in api call.
Anyone know how can i create unique chat id for send message to bot.
Thanks in advance.
2
Answers
According the documentation:
You need to write (or user need to write) first to bot. After it, in response (that getting via webhook or getUpdates method) you can get chat_id that uses to write messages to user.
Update: If I understand your comment right, you can do that:
Whom? You can manage this. I see two options:
Each user’s chatID is unique and therefore you can send a message from your own Telegram account to your bot and save the chatID. After that when the website user sends a message in your site you can pass that message to your bot via php and force the bot to send it to yourself using your chatID .
You don’t need to communicate with the user with telegram you should just use PHP to get the message and give it to the bot for sending to yourself.
Note that bots can only send messages to people who have sent at least one message to them before.