How to build a Telegram bot with Referral System with Laravel 11 and BotMan 2.0: Step by Step Guide

Chimeremze Prevail Ejimadu
10 min readJun 30, 2024
Photo by Lana Codes on Unsplash

Hey everyone! In this article, I want to show you how I built the referral-based Telegram bot @Prima_AI_bot: a Telegram bot with referral system using Laravel 11 and BotMan 2.0. If you haven’t tried it yet, it’s a good idea to check it out before reading this article. This will help you understand what I’m talking about.

The bot is designed to manage user referrals and reward referrers, ensuring only referred users can access the bot. Each user receives a unique referral link to share, and when someone joins using that link, the referrer gets notified and rewarded. The bot provides a seamless experience, encouraging users to engage and invite others while tracking referrals and rewards. It also has commands to show a user the total rewards ((PrimaAI Token — A dummy token as at writing this article) the user has accumulated by referring other users.

In this article, I will walk you through the step-by-step process of building this bot, from setting up your Laravel project and installing BotMan to implementing middleware for access control and handling referral tracking. Whether you’re…

--

--

Chimeremze Prevail Ejimadu

Laravel Developer + Writer + Entrepreneur + Open source contributor + Founder + Open for projects & collaborations. Hit FOLLOW ⤵