Telegram Referral Bot With Personal Invite Links

Give every member their own invite link, credit whoever brought each newcomer in, and let members check their count with one command.

The Referral Program template builds the whole thing for you: two flows and a table called referrals. You import it, share your bot, and the rows fill up as people join.

What a referral bot does

A referral bot hands each person a link that is theirs alone. When a friend opens the bot through that link, the bot records who sent them. Later, anyone can ask the bot how many people joined through their link, and you can see the whole picture in one table.

That is the backbone of a giveaway entry system, a community that grows by word of mouth, a shop that thanks customers for bringing friends, or an affiliate-style program where you settle rewards yourself.

Set it up in five minutesPro

  1. Connect a bot. Paste the token you get from @BotFather into the dashboard.
  2. Import the template. Open Templates, find Referral Program and press Import. You get two flows, Referral: invite links and Referral: my link, plus the referrals collection.
  3. Get your link. Send /myref to your bot. It replies with your personal invite link and your count so far. Share that link, and ask members to send /myref for theirs.

If your bot already has a flow on /myref, the import picks the next free command, such as /myref2, and tells you which one it used.

How the invite link works

Every member gets a code of 8 letters and digits, drawn at random and checked against the codes already saved. Letters and digits that are easy to confuse — 0, O, 1, I and L — are left out. A member's link looks like this:

t.me/yourbot?start=K7M2QX9P

This is a Telegram deep link. When someone opens it and taps Start, Telegram sends your bot /start K7M2QX9P instead of a plain /start. The part after the space is the code, and the template looks it up in the referrals collection to find out who shared the link.

A code is created once and saved. After that it is always read back from the member's row, so a member's link never changes. Counts are not kept in a separate number either: /myref counts the rows whose referred_by holds that member's code.

The two flows

Referral: invite links

This flow answers a /start that carries a code, and nothing else. A plain /start keeps going to your bot's usual welcome flow.

Someone opens t.me/yourbot?start=K7M2QX9P
🗄 Find Datain referrals, where user_id is their Telegram id
Already a member
“Welcome back, Sam! 👋 You're already a member, so nothing changes.” — followed by their own link
New
Look up the code, save a row with a fresh code of their own, then: “Welcome, Sam! 🎉 Glad you're here.” — followed by their own link

For a newcomer, referred_by is set to the code from the link when that code belongs to a member, and left empty when it does not.

Referral: my link

This flow answers /myref. Anyone who is not in the collection yet is added on the spot with an empty referred_by, so they can start sharing straight away.

A member sends /myref
🗄 Find Manyin referrals, where referred_by == their code
“Your personal invite link: … Share it with friends. Everyone who opens the bot through it counts as your referral. People you've referred so far: 3”

What you see on the Data tab

Open Data in the dashboard and pick the referrals collection. It is a shared collection, so every member's row sits in the same table.

ColumnWhat it holds
user_idThe member's Telegram user id
usernameTheir Telegram @username, empty when they have none
nameTheir Telegram first name
codeTheir personal 8-character code
referred_byThe code of the member who invited them, or empty
joinedThe date they were added, as YYYY-MM-DD in UTC

To see who brought whom, match a row's referred_by with another row's code.

Pro feature: the template saves and reads rows with storage blocks, which are part of Pro. Pro is $4.99/month, and a free 14-day trial starts when you connect a bot — no credit card. If your plan returns to Free, the two referral flows stop replying.

Ways to use it

🎁

Giveaways

Give extra entries to people who bring friends, using the counts from /myref and the Data tab.

👥

Communities

Let members grow a group or channel by sharing their own link, and see who is doing the inviting.

🛍️

Shops

Thank customers who send friends your way. The referred_by column shows exactly who to thank.

🤝

Affiliate-style programs

Track which partner brought each new member, then settle rewards on your own terms.

Questions

What happens if an existing member opens someone else's invite link?

They get a welcome-back message with their own link, and nothing is saved. The person who shared the link is not credited, because that member had already joined.

Can a member refer themselves?

No. A newcomer's code is created after the link has been checked, so it can never match their own code, and a member who already has a row is never registered again.

What if someone opens a link with a code that does not exist?

They still join and get their own code and link. The referred_by column is simply left empty.

Does a plain /start register people in the referrals collection?

No. A plain /start still goes to your bot's usual /start flow. People are added when they open an invite link or send /myref.

How high does the /myref count go?

The count covers up to 100 referrals per member. The referrals collection itself holds up to 50,000 rows, and every row stays visible on the Data tab.

Start your referral program

Connect a bot, import Referral Program, and send /myref to get the link you will share.

Start with a free 14-day Pro trial — no credit card, it begins when you connect your bot.

Get Started Free

More guides

Make a No-Code Telegram Bot Telegram Bot With a Database Telegram Bot Templates Free Telegram Bot Maker Telegram Reminder Bot AI Telegram Bot Builder