Creating Telegram Bot & adding to channel

Creating a telegram bot Step-by-Step

Creating a new bot for Telegram is pretty striaght forward.

  1. Open Telegram Messanger
  2. Search @BotFather on Telegram.
  3. Type /start to get started.
  4. Type /newbot to start the bot creation process.
  5. Enter your Bot name and unique Username, which must end with the bot and send.

In the reply you will get a message like following

Done! Congratulations on your new bot. You will find it at t.me/awesomebot. You can now add a description, about section and profile picture for your bot, see /help for a list of commands. By the way, when you've finished creating your cool bot, ping our Bot Support if you want a better username for it. Just make sure the bot is fully operational before you do this. Use this token to access the HTTP API: 12345687806:AAFHvnYf_82ZkxxUMpg-szM8Xa5tBMyMdl4 Keep your token secure and store it safely, it can be used by anyone to control your bot. For a description of the Bot API, see this page: https://core.telegram.org/bots/api

Now that you have a new bot go to any existing telegram channel or create a new one, add the bot as member.

Getting channel ID.

If you are sending messages or notification to this group with your bot token you need the channel id.

  • There are multiple ways you can get the channel id.
    1. Send any message to the channel i.e "test".
    2. Send a request to telegram api with bot token.
    3. -100568736345 is the channel id.
1   curl https://api.telegram.org/<your token here>/getUpdates | jq .
 1   {
 2  "ok": true,
 3  "result": [
 4    {
 5      "update_id": 478855217,
 6      "channel_post": {
 7        "message_id": 48,
 8        "sender_chat": {
 9          "id": -100568736345,
10          "title": "Newchannel",
11          "type": "channel"
12        },
13        "chat": {
14          "id": -100568736345,
15          "title": "Newchannel",
16          "type": "channel"
17        },
18        "date": 1819278685,
19        "text": "test"
20      }
21    }
22  ]