Have you ever wondered how people do automation on Telegram? You may know that Telegram has a big user base and so it is one of the preferred social media to read people. What good thing with Telegram is that it provides a bunch of API’s methods, unlike Whatsapp which restricts such things. So in this post, we will be sharing how to send messages to a Telegram user using Python.
First of all, create a bot using Telegram BotFather. To create a BotFather follow the below steps –
- Open the telegram app and search for @BotFather.
- Click on the start button or send “/start”.
- Then send “/newbot” message to set up a name and a username.
- After setting name and username BotFather will give you an API token which is your bot token.
Then create an app on the telegram. Follow the below steps –
- Log into the telegram core: https://my.telegram.org
- Go to ‘API development tools’ and fill out the form.
- You will get the api_id and api_hash parameters required for user authorization.
You need several Python library imports for the script functioning.
- telebot: To install this module type the below command in the terminal.
pip install telebot
- telethon: To install this module type the below command in the terminal.
pip install telethon
Below is the implementation.
- Send message to FB friend using Python
- Send mail from your Gmail account using Python
- Send mail with attachment from your Gmail account using Python
- Send SMS updates to mobile phone using python
- Python | Send SMS using Twilio
- How to send SMS alert using Python and MSG91 API
- Send Text messages to any mobile number using Fast2SMS API in Python
- Send PDF File through Email using pdf-mail module
- Python | Message Encode-Decode using Tkinter
- Create a Yes/No Message Box in Python using tkinter
- How To Encode And Decode A Message using Python?
- Creating a Keras Callback to send notifications on WhatsApp
- Message Boxes using PyAutoGUI
- Python | Issue Warning Message
- Python | Prompt for Password at Runtime and Termination with Error Message
- Python Program that Sends And Recieves Message from Client
- Python Tkinter - Message
- Python PyQt5 – How to change font and size of Status Bar Message
- Python EasyGUI - Message Box
- hmac - Keyed-Hashing for Message Authentication
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.