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.