We all know how useful is Telegram bots which automate our work on Telegram. There is some public bot that is free to use but we need some customized bot for different purposes. Well, it’s easy to create some beginner bot to interact with the audience and give basic information.
Not to mention that most of the customizable bots involve heavy coding and runs on a paid server. So it requires skill as well as a small investment. But if I say you don’t have to go through these hassles and are still be able to create a customized bot. Here we are going to create a Refer and Earn bot which you might be knowing.
What Is Telegram Refer And Earn Bot
Telegram refer and earn bot basically a bot that pays users in exchange for referring the bot to some other users. And the bot owner will earn by getting a free subscription to their channels. The bot is designed in such a way that you have to subscribe to the mentioned channel before earning from the bot and you can earn from the bot as long as you are subscribed to the mentioned channel.
The procedure of bot creation obviously involves coding which is why these bots are sold for a good amount. But from now on, you don’t have to pay for this bot. Before proceeding further first checkout, how this bot works and what are the features of this bot.
Refer & earn bot: https://t.me/earninstantcashbot?start=r04563267770
So now you know that this bot offers everything which you want so, without wasting time let’s jump into the steps of bot creation.
Steps To Create Refer And Earn Bot
Follow each step sequentially and very carefully otherwise you end up blaming me. You can follow these steps both on a smartphone & PC.
Join loot deals channel 👇👇👇
Join Telegram
Step 1: Create a bot using botfather and customize your description, bio & bot pic as you like. Here you have to choose a unique username and once the bot is created an API key will be generated. Copy the API ley for future steps.
Step 2: Now Go to the bots.business and log in using any email id.
Step 3: Tap on “NEW BOT” button and then paste the API token in the token field. You can name the bot whatever you like.
Step 4: Once the bot is created click on the “LAUNCH BOT” button.
this is a very important step because without this none of the commands will execute.
Step 6: On the top of the page you can see different tabs. Switch to the next tab and tap on “NEW COMMAND”. The first command is /start so, type /start in the command box and scroll down to edit BJS.
Step 7: When you tap on edit bjs, a new window will open where you have to paste the below code. This code is designed for my channel so you have to replace my channel with yours.
/start
var button = [{ title : "✅CHECK" , command : "✅CHECK" }] Bot.sendInlineKeyboard(button , "*🛡 Subscribe Our Channels If You Want To Start The Bot And Earn From It: \n\n➤ @DealsJunctionIndia\n\n☑️ Done Subscribed! Click ✅CHECK*") function hello(message) { var greetings = "" Bot.sendMessage(greetings + message) } function doTouchOwnLink() { Bot.sendMessage("*You're Trying To Invite You're Self ❌*") } function doAttracted(channel) { hello("Referal: " + channel) } function doAtractedByUser(refUser) { hello("") var balance = Libs.ResourcesLib.anotherUserRes("balance", refUser.telegramid) balance.add(0.5) Bot.sendMessageToChatWithId(refUser.chatId, "*🏧 New Referral : +0.5 ₹*"); } function doAlreadyAttracted(){ Bot.sendMessage("*You Already Started The Bot ❌*"); } var trackOptions = { onTouchOwnLink: doTouchOwnLink, onAttracted: doAttracted, onAtractedByUser: doAtractedByUser, onAlreadyAttracted: doAlreadyAttracted } Libs.ReferralLib.currentUser.track(trackOptions);
Step 8: Similarly you have add multiple commands to run this bot. Below you can see the command name followed by code. Add one by one each command and save it.
let stat = Bot.getProperty(""+user.telegramid+"");
if (stat=="ban"){
Bot.sendMessage("*You're Ban From Using The Bot ❌*");
}else{
let channel = "@dealsjunctionindia";
let id = user.telegramid
Api.getChatMember({
chat_id : channel,
user_id : id,
on_result :"check"})
}
Note: Replace this with your channel username
check
var user = options.result.status; User.setProperty("status" , user, "string"); if (user=="member" | user =="administrator" | user=="creator"){ Bot.runCommand("main_menu") User.addToGroup("user") } if (user=="left"){ Bot.sendMessage("*❌ Must join all channels*") }
main_menu
var user = User.getProperty("status"); if (user=="member" | user =="administrator" | user=="creator"){ var balance = Libs.ResourcesLib.userRes("balance"); var withdrawn = Libs.ResourcesLib.userRes("withdrawn"); var ref = Libs.ResourcesLib.userRes("referral"); var msgid = User.getProperty("msgid") Api.deleteMessage({ message_id : msgid }) Bot.sendKeyboard("💰 Balance\n👫 Referral,🎁 Bonus,💲Withdraw,\n⚙️Set wallet,📞Support", "*▶️ Refer and Earn Cash*") } if (user=="left"){ Bot.runCommand("/start"); }
Important(after users’ feedback): First, add the above four commands ( /start, ✅CHECK, check, and main_menu) and try to run the bot. If everything works fine then only add the below commands. This is very much important for the successful implementation of code otherwise you will never be able to find the faults done.
🎁 Bonus
function canRun(){ var last_run_at = User.getProperty("last_run_at"); if(!last_run_at){ return true } var minutes = (Date.now() - last_run_at) /1000/60; var minutes_in_day = 12 * 60 var next = minutes_in_day - minutes var wait_hours = Math.floor(next / 60) next -= wait_hours * 60 var wait_minutes = Math.floor(next) var seconds = Math.floor((next - wait_minutes) * 60) if (minutes < minutes_in_day) { Bot.sendMessage("*📛 You have already received a bonus Today\n\n▶️ Come Back After ⏳ "+wait_hours+" h "+wait_minutes+" m " + seconds+ " s*" ); return } return true; } if(!canRun()){ return } User.setProperty("last_run_at", Date.now(), "integer"); let balance = Libs.ResourcesLib.userRes("balance") balance.add(0.25) Bot.sendMessage( "*🎁 Congrats , you Received 0.25 ₹*" )
Please tick wait for answer
var withdrawn = Bot.getProperty("totalWithdrawn");
withdrawn = parseFloat(withdrawn);
var wallet = User.getProperty("PaytmWallet");
var balance = Libs.ResourcesLib.userRes("balance")
if(data.message < 20 ){
Bot.sendMessage("_❌ Minimum withdraw 20_")
}else{
if(data.message > balance.value()){
Bot.sendMessage("_❌ Maximum withdraw "+balance.value().toFixed(6)+" ₹_")
}else{
Bot.sendMessage("*✅ Withdrawal sent\n\n💳 Transaction Details :\n 💰Amount : "+data.message+" ₹\n💼 wallet : "+wallet+"\n\n⛔️ May be it will take upto 24 hours*")
balance.add(-data.message)
Api.sendMessage({
chat_id: "@DEalsJunctionIndia",
text: "*🔋 New Approved Payout\n\n▪️ Status : Confirmed\n▪️ User Id :* "+user.telegramid+"\n*▪️ Amount :* "+data.message+" TRX\n\n*♦️ Paid Address ♦️\n "+wallet+"\n\n✅ Bot @bot*" ,
parse_mode: "Markdown"})
}
}
Note: Replace this with your channel username
💲Withdraw
let stat = Bot.getProperty(""+user.telegramid+"") let wdinfo = Bot.getProperty("wdInfo") if (stat=="ban"){ Bot.sendMessage("*You're Ban*") }else{ let balance = Libs.ResourcesLib.userRes("balance") let withdrawn = Libs.ResourcesLib.userRes("withdrawn") var wallet = User.getProperty("PaytmWallet") if( wallet == undefined ){ Bot.sendMessage("_❌ wallet Not set_") }else{ if (balance.value() < 20){ Bot.sendMessage("_❌ You have to earn at least 20 ₹ !_") }else{ Bot.sendMessage("*📤 Enter Amount in ₹*") Bot.runCommand("auto") } }}
⚙️Set wallet
let wallet = User.getProperty("PaytmWallet") User.setProperty("PaytmWallet" , data.message ,"string") Bot.sendMessage("✅ Paytm wallet address set To :* "+data.message+"")
Important: Additionally, you have to do the following setting while creating the ⚙️Set wallet command.
In the answer section, write something of your choice and write something which is shown in the image and check the “Wait for answer” box.
let Ask = User.getProperty("Ask") User.setProperty("Ask" , data.message ,"string") Bot.sendMessage("*📩 Message sent to admin as :* "+data.message+"")
💰 Balance
var balance = Libs.ResourcesLib.userRes("balance") var lib = Libs.ReferralLib var refList = lib.currentUser.refList.get(); Bot.sendMessage("*🤴 User : "+user.first_name+"\n\n💰 Balance : "+balance.value().toFixed(2)+" ₹\n\n⚜️Refer And Earn More*")
👫 Referral
let stat = Bot.getProperty(""+user.telegramid+"");
if (stat=="ban"){
Bot.sendMessage("*You're Ban*");
}else{
let res = Libs.ResourcesLib.userRes("referral");
let reflink=Libs.ReferralLib.currentUser.getRefLink("DJI_Refer_Earn_bot","Bot");
let lib = Libs.ReferralLib
var refList = lib.currentUser.refList.get();
Bot.sendMessage("*⏯️ Total Invites : "+refList.length+" Users\n\n⛔️ Per Referral 0.5 ₹\n\n🔗 Referral Link ⬇️\n"+reflink+"*");
}
Note: Replace the marked text with your bot username.
📞Support
let Ask = User.getProperty("Ask") var button = [{ title : "✏️Write me" , command : "Ask" }] Bot.sendInlineKeyboard(button , "*📫 Last Question :* "+Ask+"")
Step 9: Now that all command is set, the final step is to make the bot admin of the channel which you are going to promote.
If everything went bouncer over your head then you can also watch this video where everything is explained stepwise. But the only problem is that everything is explained in the Hindi language.
Final Words
Now Start your bot and check if everything is working as it was with my refer & earn bot. If you face any kind of difficulty then please drop a comment below and we will try to sort it out. If you want to support us then join our Telegram Deals channel where we post the best affiliate links.
Edit: Now I think many people are having a problem with this topic. So you can join my Telegram group and there post ur problem. If I find it relevant we can have a one-to-one personal chat.