I want to perform some automation on a telegram channel and/or group using bot, one of the main features I need to use is capturing the referring URL and make some conditions based on that (In order for and action to be performed the user must come from a specific URL) Again, by referring URL, I mean the website the user will come from, for example I give some authorizations for users coming from my website. This is the concept, I wish to get guidance on how to achieve it. Thanks
Asked
Active
Viewed 658 times
-3
-
Welcome to SO! To get a helpful answer, you'll have to provide more context for your question. E.g. what do you mean by a "referring URL"? Please have a look at https://stackoverflow.com/help/how-to-ask – CallMeStag Sep 20 '21 at 10:52
1 Answers
0
Telegram does not capture what URL did the user open t.me
links to start a conversation with your bot. What you can do however, is to utilise Telegram's deep linking functionality with one-time auth codes that you generate. The idea is this:
- Your website generates a one time code that is assigned to a specific user
- Present the link to your user start a conversation with your bot using the link:
https://t.me/yourbot?start=aXsVB231278G
(the random string is the one time code) - When your bot receives the message, it sees it as
/start aXsVB231278G
. You can then extract that code and verify with your website's backend if it is a valid code.
The tokens should be short lived and ideally add an additional layer of verification as anyone (like me above) can craft random payloads to send to the bot.

chesnutcase
- 500
- 2
- 7
- 20