Skip to content

Install Telegram Bot

shayaantx edited this page Feb 23, 2020 · 5 revisions

Prerequisites

  • Install telegram on desktop
  • Create a telegram account (requires a phone number)

Setup

So this setup goes through setting up telegram bot and private channel the bot can use. I don't support public channels, since anyone can access public channels in telegram.

  1. After you've installed telegram, start by initiating a conversation with the "BotFather" https://t.me/botfather

  2. If you've installed telegram at this point you should get the following option in your browser

  1. You should see below chat window appear in telegram desktop, now we can start talking to the BotFather

  1. Type /start and hit enter. Then type /newbot and hit enter

  1. In above image I grayed out the your new bots url and token, save these items aside, we will need them shortly.

  2. So telegram doesn't have same security for bots as slack or discord. Anyone in theory can message your bot, so the botdarr application only sends responses to channels you configured in your properties file. This prevents people from trying to use your bot if they guess the bots url or someone gave it out.

  3. Next lets create a private channel, goto the top left of telegram and click Settings button

  1. Then click "New Channel" and enter your new channel name

  1. Then set the channel privacy to "Private Channel" save the invite link aside.

  1. Next you have the option to add any members, you will be automatically added as an administrator. But here you can pick your bot as a user to add. Bot's can only be added as administrators, so telegram will force you to make the bot an admin. The bot only needs ability to post messages

  1. You're almost done, now we need to get the private channels id. Unfortunately there is nothing in there api that supports getting a private channel id via channel name without sending a message to the channel. So to get the channel id, type any message in telegram. Then right click the message->copy post link

  1. Paste the url somewhere, it should look like below. The channel id is between c/ and /post id (which in below example is 2)

https://t.me/c/1156742262/2

  1. Save this id, you will use it when you setup properties file

  2. That's it, you're done setting up the telegram bot

Clone this wiki locally