Send Telegram Messages Automatically

In this article, I am going to show you one of the easiest ways to send Telegram messages automatically to a Telegram group. So without further ado, let’s get started.

If you want to learn to automate everything using Telegram Bot then watch this free tutorial.

Telegram Group Creation

You need to create a Telegram group so that later on we can add our Telegram bot to the group. If you already have a bot then just move on to the next steps.

Create Telegram Bot

We now need to create a Telegram Bot using Botfather. Follow the steps mentioned in this video to create a Telegram bot.

Steps to create a bot

  1. Search for Botfather in Telegram
  2. Write /newbot and hit Enter
  3. Provide name to this bot. I am calling it “Just Another Bot” and hit Enter
  4. Give a unique ID to your Bot. I am giving “vikasjha001_bot” and hitting Enter
  5. Write /setprivacy and hit Enter
  6. Select the Bot name which we just created and Disable the Privacy.
  7. That’s all. Now we are ready with the Bot.

Add Telegram Bot to the Group

Now you can add the newly created Telegram bot to the group. Steps are:

  1. Go to the Telegram group which you previously created.
  2. Click on Add new member
  3. Provide the name of your Telegram bot
  4. Add the member

Install and Import Requests Library

We will be using the Requests library to call Telegram /sendMessage API. So make sure to install the requests library by following the below command.

pip install requests

Send Telegram Messages Automatically

Here is a sample program that is going to send messages to any telegram group. Please replace anything which is mentioned inside angular brackets with actual value.

<your bot token> should be replaced with the bot token which you received while creating the bot.

import requests

jokes = ["joke 1", "joke 2", "Joke 3"]

for joke in jokes:
 base_url = "https://api.telegram.org/bot<your bot token>/sendMessage?chat_id=<your group id>&text=joke
 print("Message is sent")

Learn to Scrape Telegram Members

Scroll to Top