Setting up a Telegram userbot

November 30, 2020

Why do I need one?

A Telegram userbot helps you manage groups, sticker packs, your inbox; do quick web searches, download music, mirror files to your Google Drive, and hundreds of other commands. It’s not an actual bot that has its own username like Miss Rose bot. Userbots run as a session of your own account, it responds to commands you give out, as you. For example, if I send .currency 100 inr usd in any group/PM, the userbot will detect it, convert the currency from INR to USD, and will edit that message to give you the output in that message itself.

Is it safe to use one?

The short answer is yes. The long answer is that it depends on your usage of the bot. There are certain commands that you must use with extreme caution, such as .term, .exec and .eval. These commands allow you to run snippets of code from the userbot’s host. There is some basic protection applied to these commands but you’ll have to check the code and make sure it’s safe before using it. There are a few commands that spam Telegram’s servers such as .spam, .scam and anything else that sends out messages/edit in rapid succession. The bot or its devs are not responsible for your misuse of these commands, use them at your own discretion.

Where do I host it?

The easiest way to host the userbot is on Heroku. They give you 500 hours per month for free. If you add your billing info (no need to pay anything, just giving them your address and credit card numbers), they give you an additional 500 hours for free.

Which bot do I use?

I maintain a userbot called KensurBot, which has a few exclusive modules that I wrote, and is overall sane. As of writing, it supports 210 commands. I keep it up-to-date and I fix bugs relatively fast. You can use other userbots too, the procedure is mostly the same but I’ll use my bot for this guide.

What do I need?

First of all you’ll need Telegram’s API. To get your own API ID and API Hash, do this:

Next up, you’ll need to generate a session string. This will allow your bot to login as you. Think of it as a separate device that’s logged in to your account. I’ve simplified this process, do this:

Do NOT share this session string anywhere, as this is essentially a key that allows someone (or in our case, the userbot) to log in to your account.

That’s pretty much everything you need for getting the userbot up and running, there are other stuff that you might want in the future such as GDrive management, LastFM integration, and these will need their own credentials and API keys but that’s out of the scope of this guide.

You’ll need to make a separate group in your Telegram for the userbot to store its logs and other info.

Make a Heroku account, add in your billing info if you want the additional 500 hours of uptime. Google will help you with this part. Head to https://dashboard.heroku.com/account and get your API key.

How do I deploy the bot in Heroku?

Now that the hard part is done, the rest is pretty straightforward.

Updates

Send .update and the bot will check for updates. If there are any, you can send .update deploy and the bot will update itself.

Support group

In case you face errors during deploying the bot, face any crashes, have questions, or just want to hang out in a dumb off-topic group, head to my Telegram group. Check out my Telegram channel, I post all my projects there and share some stuff/resources.

Peace out!