Telegram API: Send Message – Personal Notification Bot

How about to get a push notification when some long-running job in Linux is completed?

Or how about to have a script in crontab that collects some data and periodically sends the reports to your mobile device?

This tutorial describes how to create a personal notification bot, that can send messages from the Linux command-line through the Telegram API.

Telegram Messenger

Download and install the telegram messenger for your platform.

Start the telegram client and follow the registration process.

Cool Tip: Mass emails sending from a Bash script in Linux! Read more →

Create Telegram Bot

Start a conversation with the BotFather:

🔍 GLOBAL SEARCH -> BotFather

BotFather: The BotFather is the one bot to rule them all. Use it to create new bot accounts and manage your existing bots.

Create a new bot:


Choose a user-friendly name for your bot, for example:


Choose a unique username for your bot (must ends with “bot”), for example:


Once the bot is created, you will get a token to access the Telegram API.

TOKEN: The token is a string that is required to authorize the bot and send requests to the Telegram API, e.g. 4334584910:AAEPmjlh84N62Lv3jGWEgOftlxxAfMhB1gs

Get The Chat ID

CHAT_ID: To send a message through the Telegram API, the bot needs to provide the ID of the chat it wishes to speak in. The chat ID will be generated once you start the first conversation with your bot.

Start a conversation with your bot:


Send the /start command:


To get the chat ID, open the following URL in your web-browser:<TOKEN>/getUpdates (replace <TOKEN> with your bot token).

If you are a Linux guy and prefer the command-line interface, you can simply request the above URL from shell with curl, for example:

$ curl

Cool Tip: Send emails through SMTP server using telnet from the Linux command-line interface! Read more →

Telegram Bot API: Send Message

Below i will show the examples of how to send a message through the Telegram API using a web-browser, curl and a Bash script.


To send the “Hello World” message using a web-browser, just open the URL:<TOKEN>/sendMessage?chat_id=<CHAT_ID>&text=Hello%20World

Linux Command Line

Send a message from the Linux command-line interface, using curl:

$ curl -s -X POST<TOKEN>/sendMessage -d chat_id=<CHAT_ID> -d text="Hello World"

Bash Script

A simple Bash script that sends the “Hello World” message through the Telegram API:


MESSAGE="Hello World"

curl -s -X POST $URL -d chat_id=$CHAT_ID -d text="$MESSAGE"

13 Replies to “Telegram API: Send Message – Personal Notification Bot”

  1. Спасибо за статью.
    При установленном торе в линукс пользуемся curl таким образом:
    curl –socks5-hostname -s -X POST -d chat_id=12345678 -d text=”proizvolniy text”

  2. а как прокси применить? только для этого баш-скрипта чтоб,

  3. Debian 9, OpenSSL 1.1.0f
    >curl: (60) SSL certificate problem: self signed certificate

  4. Нужно заменить решётку на ее код %23 кажется.

  5. Спасибо, отличный скрипт!

  6. Если в теле сообщения есть #, то сообщение не отображается, можно ли это обойти?

  7. Отличная статья! Большое спасибо)))

  8. Большое спасибо!

  9. Отличная статья! Все работает.

  10. Спасибо, работает!

  11. Ошибочка:
    Отправить сообщение из командной строки а Linux, с помощью curl:

    $ curl -s -X POST -d chat_id= -d text="Hello World"

    Нет слеша перед sendMessage.
    А так спасибо за статью!

    1. Поправил. Спасибо.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.