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 still able to create a customized bot. Here we are going to create a link shortener bot which you might be knowing.
Also read:Β Anyone Can Create Telegram Bot With Advanced Features
Steps To Telegram Link Shortener Bot
Follow each step sequentially and very carefully otherwise you end up blaming me. You can follow these steps both on a smartphone & PC.
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.
Step 5:Β Now go to the hamburger menu at the top left and tap onΒ <Libs>. Click on all resources one by one and install them.
this is a very important step because without this none of the commands will execute.
Also read:Β How to Create Telegram Bot without any Programming Language
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. So below are the commands and the codes to be placed.
/start
Bot.sendMessage("*Hey "+user.first_name+",* Welcome to link shortner bot. \n\n *Send Any Link to shorten*")
*
function validURL(url) { var regex = /^(?:(?:https?|ftp):\/\/)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/\S*)?$/ return regex.test(url) } if (validURL(message)) { HTTP.get({ url: "http://tinyurl.com/api-create.php?url=" + message, success: "onSuccess" }) } else { Bot.sendMessage("Wrong URL\nExample : https://techscanner.in") }
onSuccess
Bot.sendMessage("*Hey "+user.first_name+" , Your Shortened Url is\n\n*" + content)
Final Words
This bot uses tinyurl to shorten any URL. So now start your bot and check if the bot is working as it should. 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.