Node-telegram-bot-api: Unique link for telegram users

Created on 1 Nov 2018  路  7Comments  路  Source: yagop/node-telegram-bot-api

i would like to know how telegram referral links work.. how to give special link to users to track their referrals.. code examples would be appreciated.. thanks!

off-topic question

Most helpful comment

You should use message.from.username.

bot.onText(/\/start (.+)|\/start/i, function (message, match) {
    var invite_code;
    var username;
    if (match[1] != undefined){
        invite_code = match[1];
        username = message.from.username;
    }
});

All 7 comments

There is not referral for users.
Unique links for users are composed as follow: https://t.me/username or tg://user?id= if the user has not a username. Their purpose, anyway, is to bring to user profile.

You can build something by generating a url that bring to the bot with a start parameter, like this:

https://t.me/bot_username?start=xxxxxx

But I don't know how does this work exactly. Or better, how you get your parameter.

@alexandercerutti thanks for reply..
yes. thats what i was looking for.
https://t.me/bot_username?start=xxxxxx any idea?

This is known as deeplinking, there is more information here on how to use it.

@Stanbear You can grab it with:

bot.onText(/\/start (.+)|\/start/i, function (message, match) {
    var invite_code;
    if (match[1] != undefined)
        invite_code = match[1];
});

thanks @sidelux, how can i grab users joined by the link. any code example? thanks..

You should use message.from.username.

bot.onText(/\/start (.+)|\/start/i, function (message, match) {
    var invite_code;
    var username;
    if (match[1] != undefined){
        invite_code = match[1];
        username = message.from.username;
    }
});

thanks @sidelux. i'll figure out starting from your code!
sorry for the off-topic :{

Was this page helpful?
0 / 5 - 0 ratings